Skip to content

Commit

Permalink
Add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSchinazi committed Aug 20, 2024
1 parent f7107b0 commit 5719dba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/jazzlights/ui/gpio_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ bool GpioButton::HasBeenPressedLongEnoughForLongPress(Milliseconds currentTime)
// static
void GpioButton::InterruptHandler(void* arg) { reinterpret_cast<GpioButton*>(arg)->HandleInterrupt(); }

// Note that regular logging functions cannot be used inside interrupt handlers because they use locks.
// Instead use: ets_printf("foobar %d\n", 42);

void GpioButton::HandleInterrupt() {
const bool newIsPressed = gpio_get_level(static_cast<gpio_num_t>(pin_)) == 0;
const bool oldIsPressedRaw = isPressedRaw_.exchange(newIsPressed, std::memory_order_relaxed);
Expand Down

0 comments on commit 5719dba

Please sign in to comment.