#ifndef _BUTTON_H #define _BUTTON_H #include #include "beacon.h" int buttonState = 0; // variable for reading the pushbutton status #ifdef _HELTEC_H_ const int BUTTON_PRG = 0; // PRG Button #endif //_HELTEC_H_ #ifdef ARDUINO_M5Stick_C const int BUTTON_PRG = M5_BUTTON_HOME; // Home Button #endif //ARDUINO_M5Stick_C const int ledPin = 13; // the number of the LED pin void pollPrg() { buttonState = digitalRead(BUTTON_PRG); if (buttonState == LOW) { Serial.println("pollPrg: Call"); switch( beacon_type ) { case EN_BEACON_TYPE_entry: beacon_type = EN_BEACON_TYPE_hazard; beaconTypeStr="Hazard "; break; case EN_BEACON_TYPE_hazard: beacon_type = EN_BEACON_TYPE_safe; beaconTypeStr="Safe "; break; case EN_BEACON_TYPE_safe: beacon_type = EN_BEACON_TYPE_exit; beaconTypeStr="Exit "; break; case EN_BEACON_TYPE_exit: beacon_type = EN_BEACON_TYPE_other; beaconTypeStr="Other "; break; case EN_BEACON_TYPE_other: beacon_type = EN_BEACON_TYPE_entry; beaconTypeStr="Entry "; break; default: beacon_type = EN_BEACON_TYPE_safe; beaconTypeStr="Safe "; break; } Serial.println("Switching to "+beaconTypeStr); #ifdef _M5STICKC_H_ M5.Lcd.fillRect(0, LINE2, 160, 10, BLACK); M5.Lcd.fillRect(0, LINE4, 160, 10, BLACK); #endif //_M5STICKC_H_ EEPROM.write(0, beacon_type); EEPROM.commit(); } DisplayButtonStatus(); #ifdef _M5STICKC_H_ if(digitalRead(M5_BUTTON_RST) == LOW){ backlight_level++; if(backlight_level >= 16) backlight_level = 7; while(digitalRead(M5_BUTTON_RST) == LOW); Serial.println("loop::M5_BUTTON_RST"); double BatteryOrUSB = M5.Axp.GetIusbinData() * 0.375; if(0 != BatteryOrUSB) { M5.Axp.ScreenBreath(backlight_level); }else{ backlight_level = 7; M5.Axp.ScreenBreath(backlight_level); } } #endif //_M5STICKC_H_ } #endif //_BUTTON_H