|
|
|
@ -71,6 +71,9 @@ const int gpioControlled[] = CONFIG_CONTROLLED_GPIO;
|
|
|
|
|
const int gpioObserved[] = CONFIG_OBSERVED_GPIO;
|
|
|
|
|
const int pwmControlled[] = CONFIG_CONTROLLED_PWM;
|
|
|
|
|
|
|
|
|
|
uint8_t shouldSwitch = 0;
|
|
|
|
|
uint8_t switchSide = 0;
|
|
|
|
|
|
|
|
|
|
/* Set these to your desired credentials. */
|
|
|
|
|
const char *ssid = CONFIG_SSID_NAME;
|
|
|
|
|
|
|
|
|
@ -96,6 +99,15 @@ void onLongButtonPressed(uint8_t pin){
|
|
|
|
|
WiFi.softAP(ssid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void onShortButtonPressed(uint8_t pin, int state){
|
|
|
|
|
SKETCH_DEBUG_PRINTLN("OnShortButtonPressed");
|
|
|
|
|
if(pin == CONFIG_SETUP_BUTTON){
|
|
|
|
|
shouldSwitch = 1;
|
|
|
|
|
switchSide = digitalRead(12) ? 0 : 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void WifiSetup(productConfig conf) {
|
|
|
|
@ -188,7 +200,7 @@ void OTASetup() {
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
|
#ifdef CONFIG_SETUP_BUTTON
|
|
|
|
|
new HIB(CONFIG_SETUP_BUTTON, HIGH, NULL, NULL, onLongButtonPressed);
|
|
|
|
|
new HIB(CONFIG_SETUP_BUTTON, HIGH, NULL, onShortButtonPressed, onLongButtonPressed, 5000, 100);
|
|
|
|
|
#endif
|
|
|
|
|
pinMode(3, OUTPUT);
|
|
|
|
|
|
|
|
|
@ -250,6 +262,7 @@ void setup() {
|
|
|
|
|
#ifdef CONFIG_ENABLE_POWER_SAVE
|
|
|
|
|
wifi_set_sleep_type(LIGHT_SLEEP_T);
|
|
|
|
|
#endif
|
|
|
|
|
pinMode(13, OUTPUT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint nbCycle = CONFIG_SAMPLING_PERIODE_MS / CONFIG_WEB_DELAY_MS;
|
|
|
|
@ -264,6 +277,12 @@ void loop() {
|
|
|
|
|
}
|
|
|
|
|
delay(CONFIG_WEB_DELAY_MS);
|
|
|
|
|
|
|
|
|
|
if (shouldSwitch) {
|
|
|
|
|
shouldSwitch = 0;
|
|
|
|
|
MqttChangeGpioValue(12, switchSide);
|
|
|
|
|
}
|
|
|
|
|
digitalWrite(13, digitalRead(12) ? 0 : 1);
|
|
|
|
|
|
|
|
|
|
nbCycle++;
|
|
|
|
|
if (nbCycle > CONFIG_SAMPLING_PERIODE_MS / CONFIG_WEB_DELAY_MS) {
|
|
|
|
|
if (!BMP180GetTempAndPressure(temp, pressure)) {
|
|
|
|
|