Removed the old way to change the current view and added the EventHandler way to do it
This commit is contained in:
parent
e0bea5fae4
commit
281e07c30a
@ -5,13 +5,15 @@
|
|||||||
#include "tasks.h"
|
#include "tasks.h"
|
||||||
#include "CFGDictionary.h"
|
#include "CFGDictionary.h"
|
||||||
#include "CFGParameterValue.h"
|
#include "CFGParameterValue.h"
|
||||||
|
#include "EventHandler.h"
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
SAB sab;
|
SAB sab;
|
||||||
|
EventHandler evHan;
|
||||||
|
EventHandler::Event evt;
|
||||||
|
|
||||||
unsigned long currentMs = 0, buttonDownMs(0), buttonUpMs(0);
|
unsigned long currentMs = 0;
|
||||||
volatile boolean ioStateChange(false);
|
volatile boolean ioStateChange(false);
|
||||||
boolean buttonPushSampled(false);
|
|
||||||
View1Packet v1p = {sab.getRtcManager().getDateTime(), sab.getSdCardManager().getSize(GBYTE), sab.getPowerManager().getPowerInfo(),0, sab.getSoftVersion(), &sab};
|
View1Packet v1p = {sab.getRtcManager().getDateTime(), sab.getSdCardManager().getSize(GBYTE), sab.getPowerManager().getPowerInfo(),0, sab.getSoftVersion(), &sab};
|
||||||
ViewAPPacket vap = {sab.getConnectivityManager().softAPmacAddress(), sab.getConnectivityManager().softAPSSID(), sab.getConnectivityManager().softAPIP(), sab.getConnectivityManager().softAPgetStationNum(), sab.getConnectivityManager().isAPEnabled()};
|
ViewAPPacket vap = {sab.getConnectivityManager().softAPmacAddress(), sab.getConnectivityManager().softAPSSID(), sab.getConnectivityManager().softAPIP(), sab.getConnectivityManager().softAPgetStationNum(), sab.getConnectivityManager().isAPEnabled()};
|
||||||
ViewSTAPacket vstap = {sab.getConnectivityManager().macAddress(), sab.getConnectivityManager().localIP(), sab.getConnectivityManager().RSSI(), sab.getConnectivityManager().isSTAEnabled()};
|
ViewSTAPacket vstap = {sab.getConnectivityManager().macAddress(), sab.getConnectivityManager().localIP(), sab.getConnectivityManager().RSSI(), sab.getConnectivityManager().isSTAEnabled()};
|
||||||
@ -115,48 +117,26 @@ void loop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(digitalRead(GPIO_0) == 0 && millis() - buttonMs > 500)
|
evt = evHan.getEvent();
|
||||||
{
|
switch(evt)
|
||||||
buttonMs = millis();
|
|
||||||
sab.getScreenManager().displayNextView();
|
|
||||||
#ifdef DEBUG
|
|
||||||
Serial.println("Changing view");
|
|
||||||
Serial.print("Selected view is : ");Serial.println(sab.getScreenManager().getCurrentViewUID());
|
|
||||||
#endif
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if(digitalRead(GPIO_0) == 0 && !buttonPushSampled)
|
|
||||||
{
|
|
||||||
buttonPushSampled = true;
|
|
||||||
buttonDownMs = millis();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(digitalRead(GPIO_0) == 1 && buttonPushSampled)
|
|
||||||
{
|
|
||||||
buttonPushSampled = false;
|
|
||||||
buttonUpMs = millis();
|
|
||||||
|
|
||||||
if(buttonUpMs - buttonDownMs < 700 && buttonUpMs - buttonDownMs > 200)//Short press
|
|
||||||
{
|
{
|
||||||
|
case EventHandler::Event::FLASH_BUTTON_PRESS:
|
||||||
sab.getScreenManager().displayNextView();
|
sab.getScreenManager().displayNextView();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID());
|
Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID());
|
||||||
#endif
|
#endif
|
||||||
}
|
break;
|
||||||
}
|
case EventHandler::Event::FLASH_BUTTON_LONG_PRESS:
|
||||||
|
|
||||||
if(digitalRead(GPIO_0) == 0 && buttonPushSampled && millis() - buttonDownMs > 700)
|
|
||||||
{
|
|
||||||
buttonPushSampled = false;
|
|
||||||
|
|
||||||
sab.getScreenManager().displayPreviousView();
|
sab.getScreenManager().displayPreviousView();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID());
|
Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID());
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Run the different services
|
//Run the different services
|
||||||
sab.run();
|
sab.run();
|
||||||
|
evHan.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
ICACHE_RAM_ATTR void ioISR()
|
ICACHE_RAM_ATTR void ioISR()
|
||||||
|
Loading…
Reference in New Issue
Block a user