diff --git a/src/app/app.ino b/src/app/app.ino index da8954b..196e0f8 100644 --- a/src/app/app.ino +++ b/src/app/app.ino @@ -5,6 +5,7 @@ #include "webApi.h" #include "CFGDictionary.h" #include "CFGParameterValue.h" +#define DEBUG SAB sab; @@ -12,13 +13,12 @@ unsigned long currentMs = 0, batteryMs = 0, buttonMs = 0; View1Packet v1p = {sab.getRtcManager().getDateTime(), sab.getSdCardManager().getSize(GBYTE), sab.getPowerInfo(),0}; ViewAPPacket vap = {sab.getConnectivityManager().softAPmacAddress(), sab.getConnectivityManager().softAPSSID(), sab.getConnectivityManager().softAPIP(), sab.getConnectivityManager().softAPgetStationNum()}; ViewSTAPacket vstap = {sab.getConnectivityManager().macAddress(), sab.getConnectivityManager().localIP(), sab.getConnectivityManager().RSSI()}; +ViewIoInfoPacket vio = {{0}}; SdCardApiPacket sdCardApiPacket = {NULL, NULL}; void setup() { // put your setup code here, to run once: - pinMode(GPIO_0, INPUT); - Serial.println("Starting setup"); CFGFileParser cfgFileParser(sab.getSdCardManager(), AP_CFG_FILE); CFGDictionary *cfgDictionary = (CFGDictionary *) cfgFileParser.parseFile(); @@ -40,8 +40,9 @@ void setup() sab.getScreenManager().addView(&(view_2), &vap, 1); sab.getScreenManager().addView(&(view_3), &vstap, 2); sab.getScreenManager().addView(&(memInfo), NULL, 3); - sab.getScreenManager().addView(NULL, NULL, 4); //for testin purposes - sab.getScreenManager().addView(&(dummy), NULL, 5); //for testin purposes + sab.getScreenManager().addView(&(ioInfo), &vio, 4); + sab.getScreenManager().addView(NULL, NULL, 5); //for testing purposes + sab.getScreenManager().addView(&(dummy), NULL, 6); //for testing purposes sab.getScreenManager().displayView(0); if(sab.getRtcManager().hasLostPower()) @@ -64,13 +65,18 @@ void setup() sab.getWebServerManager().addApiRoutine("/esp/reset", &(espResetApi), NULL, WEBServerManager::GET); sab.getWebServerManager().addApiRoutine("/sab/wifi/stainfo", &(staWifiInfoApi), &sab, WEBServerManager::GET); sab.getWebServerManager().addApiRoutine("/sab/systeminfo", &(systemInfoApi), &sab, WEBServerManager::GET); + sab.getWebServerManager().addApiRoutine("/sab/io/get/level", &(ioGetLevelApi), &sab, WEBServerManager::GET); + sab.getWebServerManager().addApiRoutine("/sab/io/set/level", &(ioSetLevelApi), &sab, WEBServerManager::GET); + sab.getWebServerManager().addApiRoutine("/sab/io/get/mode", &(ioGetModeApi), &sab, WEBServerManager::GET); + sab.getWebServerManager().addApiRoutine("/sab/io/set/mode", &(ioSetModeApi), &sab, WEBServerManager::GET); + Serial.println("End setup"); } void loop() { - if(millis() - currentMs > 1000) + if(millis() - currentMs > 100) { currentMs = millis(); v1p.dateTime = sab.getRtcManager().getDateTime(); @@ -81,7 +87,9 @@ void loop() vstap.macAddr = sab.getConnectivityManager().macAddress(); vstap.ipAddr = sab.getConnectivityManager().localIP(); vstap.sigStrength = sab.getConnectivityManager().RSSI(); - + + sab.getIoManager().getPcf().digitalReadAll(vio.ioState); + sab.getScreenManager().displayView(); } @@ -95,10 +103,11 @@ void loop() if(digitalRead(GPIO_0) == 0 && millis() - buttonMs > 500) { buttonMs = millis(); + sab.getScreenManager().displayNextView(); + #ifdef DEBUG Serial.println("Changing view"); Serial.print("Selected view is : ");Serial.println(sab.getScreenManager().getCurrentViewUID()); - - sab.getScreenManager().displayNextView(); + #endif } //Run the webServer