66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
#include "definition.h"
|
|
#include "PinMapping.h"
|
|
#include "SAB.h"
|
|
#include "views.h"
|
|
#include "CFGDictionary.h"
|
|
|
|
SAB sab;
|
|
|
|
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()};
|
|
|
|
void setup()
|
|
{
|
|
// put your setup code here, to run once:
|
|
Serial.println("Starting setup");
|
|
pinMode(GPIO_0, INPUT);
|
|
sab.getScreenManager().addView(&(view_1), &v1p, 0);
|
|
sab.getScreenManager().addView(&(view_2), &vap, 1);
|
|
sab.getScreenManager().addView(&(view_3), NULL, 2);
|
|
sab.getScreenManager().displayView(0);
|
|
if(sab.getRtcManager().hasLostPower())
|
|
{
|
|
Serial.println("Clock lost power");
|
|
sab.getRtcManager().setDateTime(DateTime(F(__DATE__), F(__TIME__)));
|
|
}
|
|
Serial.println("End setup");
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
|
|
if(millis() - currentMs > 1000)
|
|
{
|
|
currentMs = millis();
|
|
v1p.dateTime = sab.getRtcManager().getDateTime();
|
|
v1p.nbViews = sab.getScreenManager().getViewCount();
|
|
vap.ipAddr = sab.getConnectivityManager().softAPIP();
|
|
vap.macAddr = sab.getConnectivityManager().softAPmacAddress();
|
|
vap.nbOfCon = sab.getConnectivityManager().softAPgetStationNum();
|
|
|
|
sab.getScreenManager().displayView();
|
|
|
|
CFGFileParser cfgFileParser(sab.getSdCardManager(), AP_CFG_FILE);
|
|
CFGDictionary *cfgDictionary = (CFGDictionary *) cfgFileParser.parseFile();
|
|
|
|
delete cfgDictionary;
|
|
}
|
|
|
|
if(millis() - batteryMs > 10000)
|
|
{
|
|
batteryMs = millis();
|
|
v1p.powerInfo = sab.getPowerInfo();
|
|
}
|
|
|
|
|
|
if(digitalRead(GPIO_0) == 0 && millis() - buttonMs > 500)
|
|
{
|
|
buttonMs = millis();
|
|
Serial.println("Changing view");
|
|
Serial.print("Selected view is : ");Serial.println(sab.getScreenManager().getCurrentViewUID());
|
|
|
|
sab.getScreenManager().displayNextView();
|
|
}
|
|
}
|