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() {
|
2018-09-30 15:08:00 +02:00
|
|
|
portENTER_CRITICAL(&mutexButton);
|
2018-09-23 18:07:40 +02:00
|
|
|
ButtonPressedIRQ++;
|
2018-09-30 15:08:00 +02:00
|
|
|
portEXIT_CRITICAL(&mutexButton);
|
2018-09-23 18:07:40 +02:00
|
|
|
}
|
2018-07-23 08:25:23 +02:00
|
|
|
|
|
|
|
void readButton() {
|
2018-09-30 15:08:00 +02:00
|
|
|
portENTER_CRITICAL(&mutexButton);
|
2018-07-23 08:25:23 +02:00
|
|
|
ButtonPressedIRQ = 0;
|
2018-09-30 15:08:00 +02:00
|
|
|
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
|