Added an interrupt to detect io changes
This commit is contained in:
parent
1aa919c6b3
commit
7637bda305
@ -10,6 +10,7 @@
|
|||||||
SAB sab;
|
SAB sab;
|
||||||
|
|
||||||
unsigned long currentMs = 0, batteryMs = 0, buttonMs = 0;
|
unsigned long currentMs = 0, batteryMs = 0, buttonMs = 0;
|
||||||
|
volatile boolean ioStateChange(false);
|
||||||
View1Packet v1p = {sab.getRtcManager().getDateTime(), sab.getSdCardManager().getSize(GBYTE), sab.getPowerInfo(),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()};
|
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()};
|
ViewSTAPacket vstap = {sab.getConnectivityManager().macAddress(), sab.getConnectivityManager().localIP(), sab.getConnectivityManager().RSSI()};
|
||||||
@ -65,18 +66,20 @@ void setup()
|
|||||||
sab.getWebServerManager().addApiRoutine("/esp/reset", &(espResetApi), NULL, WEBServerManager::GET);
|
sab.getWebServerManager().addApiRoutine("/esp/reset", &(espResetApi), NULL, WEBServerManager::GET);
|
||||||
sab.getWebServerManager().addApiRoutine("/sab/wifi/stainfo", &(staWifiInfoApi), &sab, 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/systeminfo", &(systemInfoApi), &sab, WEBServerManager::GET);
|
||||||
sab.getWebServerManager().addApiRoutine("/sab/io/get/level", &(ioGetLevelApi), &sab, WEBServerManager::GET);
|
sab.getWebServerManager().addApiRoutine("/sab/io/get/level", &(ioGetLevelApi), vio.ioState, WEBServerManager::GET);
|
||||||
sab.getWebServerManager().addApiRoutine("/sab/io/set/level", &(ioSetLevelApi), &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/get/mode", &(ioGetModeApi), &sab, WEBServerManager::GET);
|
||||||
sab.getWebServerManager().addApiRoutine("/sab/io/set/mode", &(ioSetModeApi), &sab, WEBServerManager::GET);
|
sab.getWebServerManager().addApiRoutine("/sab/io/set/mode", &(ioSetModeApi), &sab, WEBServerManager::GET);
|
||||||
|
|
||||||
|
sab.getIoManager().setISROnIOChange(&(ioISR), GPIO_3_RX);
|
||||||
|
|
||||||
Serial.println("End setup");
|
Serial.println("End setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(millis() - currentMs > 100)
|
if(millis() - currentMs > 1000 || ioStateChange)
|
||||||
{
|
{
|
||||||
currentMs = millis();
|
currentMs = millis();
|
||||||
v1p.dateTime = sab.getRtcManager().getDateTime();
|
v1p.dateTime = sab.getRtcManager().getDateTime();
|
||||||
@ -91,6 +94,8 @@ void loop()
|
|||||||
sab.getIoManager().getPcf().digitalReadAll(vio.ioState);
|
sab.getIoManager().getPcf().digitalReadAll(vio.ioState);
|
||||||
|
|
||||||
sab.getScreenManager().displayView();
|
sab.getScreenManager().displayView();
|
||||||
|
|
||||||
|
ioStateChange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(millis() - batteryMs > 10000)
|
if(millis() - batteryMs > 10000)
|
||||||
@ -113,3 +118,8 @@ void loop()
|
|||||||
//Run the webServer
|
//Run the webServer
|
||||||
sab.getWebServerManager().runServer();
|
sab.getWebServerManager().runServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ioISR()
|
||||||
|
{
|
||||||
|
ioStateChange = true;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user