ESP32-PaxCounter/src/button.cpp

24 lines
486 B
C++
Raw Normal View History

2018-07-23 08:25:23 +02:00
#ifdef HAS_BUTTON
#include "globals.h"
2018-07-23 13:20:06 +02:00
#include "senddata.h"
2018-07-23 08:25:23 +02:00
// Local logging tag
static const char TAG[] = "main";
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