1 contributor
#ifndef _MY_ISR_H
#define _MY_ISR_H
#include "my_mqtt.h"
#ifdef ARDUINO_ESP8266_WEMOS_D1R1
uint8_t buttonDown=0;
uint8_t buttonUp=0;
uint8_t buttonRight=0;
uint8_t buttonPush=0;
void ICACHE_RAM_ATTR interrupt0() // Right
{
//Way: Opposite screen
// Disabled as it makes the board reboot
Serial.println("Right");
if(0==buttonRight) {
buttonRight = 1;
WiFiConnect();
mqtt_connect();
} else {
buttonRight = 0;
}
}
void ICACHE_RAM_ATTR interrupt12() // Down
{
//Way: Toward edge of the board
Serial.println("Down");
if(0==buttonDown) {
buttonDown = 1;
} else {
buttonDown = 0;
}
displaySetStatus(buttonDown);
}
void ICACHE_RAM_ATTR interrupt13() // Up
{
//Way: Toward hole in the board
Serial.println("Up");
if(0==buttonUp) {
buttonUp = 1;
} else {
buttonUp = 0;
}
displaySetStatus(1);
//WiFiConnect();
WiFi.disconnect(true);
//WiFi.mode(WIFI_STA);
}
void ICACHE_RAM_ATTR interrupt14() // Push
{
//Way: Toward hole in the board
Serial.println("Push");
if(0==buttonPush) {
buttonPush = 1;
} else {
buttonPush = 0;
}
}
void isr_set() {
//pinMode(0, INPUT_PULLUP);
//attachInterrupt(digitalPinToInterrupt(0), interrupt0, FALLING); // Right
pinMode(12, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(12), interrupt12, FALLING); // Down
pinMode(13, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(13), interrupt13, FALLING); // Up
pinMode(14, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(14), interrupt14, FALLING); // Push
}
#else
void isr_set() {}
#endif //ARDUINO_ESP8266_WEMOS_D1R1
#endif //_MY_ISR_H