ESP32-PaxCounter/src/button.cpp

25 lines
522 B
C++
Raw Normal View History

2018-07-23 08:25:23 +02:00
#ifdef HAS_BUTTON
#include "globals.h"
// Local logging tag
static const char TAG[] = "main";
2018-09-30 22:06:10 +02:00
portMUX_TYPE mutexButton = portMUX_INITIALIZER_UNLOCKED;
2018-09-23 18:07:40 +02:00
void IRAM_ATTR ButtonIRQ() {
portENTER_CRITICAL(&mutexButton);
2018-09-23 18:07:40 +02:00
ButtonPressedIRQ++;
portEXIT_CRITICAL(&mutexButton);
2018-09-23 18:07:40 +02:00
}
2018-07-23 08:25:23 +02:00
void readButton() {
portENTER_CRITICAL(&mutexButton);
2018-07-23 08:25:23 +02:00
ButtonPressedIRQ = 0;
portEXIT_CRITICAL(&mutexButton);
2018-07-23 08:25:23 +02:00
ESP_LOGI(TAG, "Button pressed");
payload.reset();
payload.addButton(0x01);
2018-08-04 15:27:58 +02:00
SendData(BUTTONPORT);
2018-07-23 08:25:23 +02:00
}
#endif