remote var toggle

This commit is contained in:
Siwat Sirichai 2024-02-09 17:49:54 +07:00
parent 3467c90e52
commit a2e1da279c
1 changed files with 8 additions and 0 deletions

View File

@ -13,13 +13,16 @@
#define DISPLAY_ENABLE
#define WEB_SERVER_ENABLE
#define LCD_OTA_ENABLE
#define REMOTE_VARIABLE_ENABLE
// Demo PLC firmware using the ESPMegaPRO OOP library
ESPMegaPRO espmega = ESPMegaPRO();
// Remote Variable
#ifdef REMOTE_VARIABLE_ENABLE
RemoteVariable testVar = RemoteVariable();
#endif
#ifdef LCD_OTA_ENABLE
ESPMegaDisplayOTA internalDisplayOTA = ESPMegaDisplayOTA();
@ -195,9 +198,12 @@ void setup()
#ifdef LCD_OTA_ENABLE
internalDisplayOTA.begin("/display", espmega.display, espmega.webServer);
#endif
#ifdef REMOTE_VARIABLE_ENABLE
ESP_LOGI("Initializer", "Initializing testvar");
testVar.begin(32, "/testvar", espmega.iot, true,"/testvar/request");
testVar.enableSetValue("/testvar/set");
#endif
ESP_LOGI("Initializer", "Setup complete");
}
void loop()
@ -232,6 +238,7 @@ void loop()
Serial.println(espmega.iot->mqttConnected() ? "Connected" : "Disconnected");
}
#endif
#ifdef REMOTE_VARIABLE_ENABLE
// Print out testvar value every 5 seconds
static uint32_t last_testvar_print = 0;
if (millis() - last_testvar_print >= 5000)
@ -241,4 +248,5 @@ void loop()
ESP_LOGI("TestVar", "Value: %s", testVar.getValue());
testVar.setValue("Hello World");
}
#endif
}