Compare commits
8 Commits
ca819f0e93
...
80ed2f2080
Author | SHA1 | Date | |
---|---|---|---|
|
80ed2f2080 | ||
|
5fc76ac6a2 | ||
|
e699b462f9 | ||
|
723132a082 | ||
|
cd6af9f99f | ||
|
424a135151 | ||
|
6dfee719a9 | ||
|
d371eeb267 |
@ -138,3 +138,11 @@ unsigned char SAB::getError() const
|
||||
{
|
||||
return _error;
|
||||
}
|
||||
|
||||
void SAB::run()
|
||||
{
|
||||
_webServer.run();
|
||||
_ftpServer.run();
|
||||
_taskSchedulerManager.run();
|
||||
_screenManager.run();
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ class SAB
|
||||
PowerManager& getPowerManager();
|
||||
TimeSpan getUpTime();
|
||||
BoardConfig getBoardConfig() const;
|
||||
void run();
|
||||
|
||||
const char *getSoftVersion() const;
|
||||
unsigned char getError() const;
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "ScreenManager.h"
|
||||
|
||||
ScreenManager::ScreenManager(Adafruit_SSD1306 &display, SDCardManager *sdCardManager) : _displayRef(display), _displayColorInverted(false), _displayDimmed(false), _enabled(true), _currentView(NO_CURRENT_VIEW), _error(OK)
|
||||
ScreenManager::ScreenManager(Adafruit_SSD1306 &display, SDCardManager *sdCardManager) : _displayRef(display), _error(OK)
|
||||
, _displayColorInverted(false), _displayDimmed(false), _enabled(true), _refreshRateHz(1), _refreshInterval(1000), _timeRef(0),_forceRefresh(false)
|
||||
, _currentView(NO_CURRENT_VIEW), _tail(NULL)
|
||||
, _viewNotFound{&(displayError), (ErrorInfo *)malloc(sizeof(ErrorInfo)), RESERVED_VIEW_UID, NULL}
|
||||
, _viewFuncUndefined{&(displayError), (ErrorInfo *)malloc(sizeof(ErrorInfo)), RESERVED_VIEW_UID, NULL}
|
||||
, _currentViewUndefined{&(displayError), (ErrorInfo *)malloc(sizeof(ErrorInfo)), RESERVED_VIEW_UID, NULL}
|
||||
@ -8,6 +10,10 @@ ScreenManager::ScreenManager(Adafruit_SSD1306 &display, SDCardManager *sdCardMan
|
||||
,_sdCardManager(sdCardManager)
|
||||
{
|
||||
_viewLinkedList = (ViewLinkedList) createEmptyList();
|
||||
//We set the error messages :
|
||||
((ErrorInfo *)_viewNotFound.pData)->errorMessage = FPSTR("View does not exist");
|
||||
((ErrorInfo *)_viewFunctionFailedToExecute.pData)->errorMessage = FPSTR("View function failed\nto execute");
|
||||
((ErrorInfo *)_viewFuncUndefined.pData)->errorMessage = FPSTR("View function is NULL");
|
||||
}
|
||||
|
||||
boolean ScreenManager::init()
|
||||
@ -66,8 +72,8 @@ void ScreenManager::setDefault()
|
||||
|
||||
boolean ScreenManager::addView(boolean (*viewLogicFunction)(Adafruit_SSD1306&, void*), void *pData, const unsigned char UID)
|
||||
{
|
||||
ViewLink viewLink ={viewLogicFunction, pData, UID, NULL};
|
||||
addNewLinkAtTheEnd(&_viewLinkedList, viewLink);
|
||||
ViewLink viewLink ={viewLogicFunction, pData, UID, NULL, NULL};
|
||||
return addNewLinkAtTheEnd(&_viewLinkedList, viewLink);
|
||||
}
|
||||
|
||||
void *ScreenManager::createEmptyList()
|
||||
@ -87,33 +93,48 @@ boolean ScreenManager::addNewLinkAtTheEnd(ViewLinkedList *viewLinkedList, ViewLi
|
||||
//Because of the const member
|
||||
memcpy(newViewLink, &viewLink, sizeof(*newViewLink));
|
||||
|
||||
if(isListEmpty(*viewLinkedList))*viewLinkedList = newViewLink;
|
||||
else
|
||||
//If this is the first link
|
||||
if(isListEmpty(*viewLinkedList))
|
||||
{
|
||||
if((*viewLinkedList)->UID == newViewLink->UID)
|
||||
{
|
||||
ViewLink *link = *viewLinkedList;
|
||||
//The link list points to the first link (aka the head)
|
||||
*viewLinkedList = newViewLink;
|
||||
newViewLink->next = link->next;
|
||||
free(link);
|
||||
//The previous pointer is still NULL;
|
||||
//The _tail pointer is the same as the head one.
|
||||
_tail = *viewLinkedList;
|
||||
}
|
||||
else //If there are some links already
|
||||
{
|
||||
ViewLinkedList *cursor = viewLinkedList;
|
||||
ViewLink *previousLink = NULL;
|
||||
|
||||
while(*cursor != NULL)
|
||||
{
|
||||
previousLink = *cursor;
|
||||
//We check if the UID already exists, if yes we replace the link
|
||||
if((*cursor)->UID == newViewLink->UID)
|
||||
{
|
||||
ViewLink *toDelete = *cursor;
|
||||
*cursor = newViewLink;
|
||||
newViewLink->next = toDelete->next;
|
||||
newViewLink->previous = toDelete->previous;
|
||||
//We check if the link as a next link registered
|
||||
if(toDelete->next != NULL)
|
||||
{
|
||||
//We update it's previous link since it's going to be deleted
|
||||
toDelete->next->previous = newViewLink;
|
||||
}
|
||||
//We do not forget to check if the link replaced is also the tail, in this case, we must update the tail
|
||||
if(_tail == toDelete)_tail = newViewLink;
|
||||
free(toDelete);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ViewLinkedList cursor = *viewLinkedList;
|
||||
|
||||
while(cursor->next != NULL)
|
||||
{
|
||||
if(cursor->next->UID == newViewLink->UID)
|
||||
{
|
||||
ViewLink *link = cursor->next;
|
||||
cursor->next = newViewLink;
|
||||
newViewLink->next = link->next;
|
||||
free(link);
|
||||
return true;
|
||||
cursor = &(*cursor)->next;
|
||||
}
|
||||
cursor = cursor->next;
|
||||
}
|
||||
cursor->next = newViewLink;
|
||||
newViewLink->previous = previousLink;
|
||||
*cursor = newViewLink;
|
||||
//We need to update the tail
|
||||
_tail = newViewLink;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -128,25 +149,28 @@ boolean ScreenManager::removeLinkByUID(ViewLinkedList *viewLinkedList, const uns
|
||||
{
|
||||
if(isListEmpty(*viewLinkedList))return false;
|
||||
|
||||
if((*viewLinkedList)->UID == UID)
|
||||
{
|
||||
ViewLink *tmp = *viewLinkedList;
|
||||
*viewLinkedList = (*viewLinkedList)->next;
|
||||
free(tmp);
|
||||
return true;
|
||||
}
|
||||
ViewLinkedList *cursor = viewLinkedList;
|
||||
|
||||
ViewLinkedList cursor = *viewLinkedList;
|
||||
while(!isListEmpty(cursor->next))
|
||||
while(*cursor != NULL)
|
||||
{
|
||||
if(cursor->next->UID == UID)
|
||||
//We check if this is the link we want to delete
|
||||
if((*cursor)->UID == UID)
|
||||
{
|
||||
ViewLink *tmp = cursor->next;
|
||||
cursor->next = cursor->next->next;
|
||||
free(tmp);
|
||||
ViewLink *toDelete = *cursor;
|
||||
*cursor = (*cursor)->next;
|
||||
|
||||
if(toDelete->next != NULL)
|
||||
{
|
||||
//We update the previous link of the next member since it's going to be deleted
|
||||
toDelete->next->previous = toDelete->previous;
|
||||
}
|
||||
//We also update the tail if the link we delete was the tail
|
||||
if(_tail == toDelete)_tail = toDelete->previous;
|
||||
|
||||
free(toDelete);
|
||||
return true;
|
||||
}
|
||||
cursor = cursor->next;
|
||||
cursor = &(*cursor)->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -186,119 +210,135 @@ ViewLink* ScreenManager::getLinkByUID(ViewLinkedList viewLinkedList, const unsig
|
||||
return NULL;
|
||||
}
|
||||
|
||||
boolean ScreenManager::displayView(const int UID)
|
||||
void ScreenManager::run()
|
||||
{
|
||||
if(!_enabled) return true;
|
||||
//Reset draw settings:
|
||||
if((millis() - _timeRef < _refreshInterval && !_forceRefresh) || !_enabled) return;
|
||||
|
||||
_timeRef = millis();
|
||||
|
||||
if(((_error == OK || _error == VIEW_FAILED_TO_EXECUTE) || _forceRefresh) && _currentView != NO_CURRENT_VIEW)
|
||||
{
|
||||
_displayRef.clearDisplay();
|
||||
_displayRef.setCursor(0,0);
|
||||
_displayRef.setTextSize(1);
|
||||
|
||||
|
||||
if(UID == -1 && _currentView == NO_CURRENT_VIEW)
|
||||
switch(_error)
|
||||
{
|
||||
//We display an error message on the screen
|
||||
((ErrorInfo *)_currentViewUndefined.pData)->errorMessage = FPSTR("Could not display current view");
|
||||
((ErrorInfo *)_currentViewUndefined.pData)->viewUID = UID;
|
||||
(*_currentViewUndefined.viewLogicFunction)(_displayRef, _currentViewUndefined.pData);
|
||||
_displayRef.display();
|
||||
|
||||
_error = CURRENT_VIEW_UNDEFINED;
|
||||
return false;
|
||||
}
|
||||
else if(UID == -1)
|
||||
case OK:
|
||||
case VIEW_FAILED_TO_EXECUTE:
|
||||
if(!(*_currentView->viewLogicFunction)(_displayRef, _currentView->pData))
|
||||
{
|
||||
if(_currentView->viewLogicFunction == NULL)
|
||||
{
|
||||
//We display an error message on the screen
|
||||
((ErrorInfo *)_viewFuncUndefined.pData)->errorMessage = FPSTR("View function is NULL");
|
||||
((ErrorInfo *)_viewFuncUndefined.pData)->viewUID = _currentView->UID;
|
||||
(*_viewFuncUndefined.viewLogicFunction)(_displayRef, _viewFuncUndefined.pData);
|
||||
_displayRef.display();
|
||||
|
||||
_error = VIEW_FUNC_UNDEFINED;
|
||||
return false;
|
||||
}
|
||||
else if(!(*_currentView->viewLogicFunction)(_displayRef, _currentView->pData))
|
||||
{
|
||||
//We display an error message on the screen
|
||||
_displayRef.clearDisplay();
|
||||
((ErrorInfo *)_viewFunctionFailedToExecute.pData)->errorMessage = FPSTR("View function failed\nto execute");
|
||||
//Error while executing the view function
|
||||
((ErrorInfo *)_viewFunctionFailedToExecute.pData)->viewUID = _currentView->UID;
|
||||
(*_viewFunctionFailedToExecute.viewLogicFunction)(_displayRef, _viewFunctionFailedToExecute.pData);
|
||||
_displayRef.display();
|
||||
|
||||
_error = VIEW_FAILED_TO_EXECUTE;
|
||||
return false;
|
||||
}
|
||||
|
||||
else
|
||||
_error = OK;
|
||||
_displayRef.display();
|
||||
return true;
|
||||
break;
|
||||
case VIEW_NOT_FOUND:
|
||||
(*_viewNotFound.viewLogicFunction)(_displayRef, _viewNotFound.pData);
|
||||
break;
|
||||
case VIEW_FUNC_UNDEFINED:
|
||||
(*_viewFuncUndefined.viewLogicFunction)(_displayRef, _viewFuncUndefined.pData);
|
||||
break;
|
||||
}
|
||||
|
||||
_displayRef.display();
|
||||
_forceRefresh = false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean ScreenManager::displayView(const uint8_t UID)
|
||||
{
|
||||
if(!_enabled) return true;
|
||||
_forceRefresh = true;
|
||||
ViewLink *viewLink = getLinkByUID(_viewLinkedList, UID);
|
||||
|
||||
if(viewLink == NULL)
|
||||
{
|
||||
//We display an error message on the screen
|
||||
((ErrorInfo *)_viewNotFound.pData)->errorMessage = FPSTR("View does not exist");
|
||||
((ErrorInfo *)_viewNotFound.pData)->viewUID = UID;
|
||||
(*_viewNotFound.viewLogicFunction)(_displayRef, _viewNotFound.pData);
|
||||
_displayRef.display();
|
||||
|
||||
_error = VIEW_NOT_FOUND;
|
||||
_currentView = &_viewNotFound;
|
||||
return false;
|
||||
}else if(viewLink->viewLogicFunction == NULL)
|
||||
}
|
||||
else if(viewLink->viewLogicFunction == NULL)
|
||||
{
|
||||
//We display an error message on the screen
|
||||
((ErrorInfo *)_viewFuncUndefined.pData)->errorMessage = FPSTR("View function is NULL");
|
||||
((ErrorInfo *)_viewFuncUndefined.pData)->viewUID = UID;
|
||||
(*_viewFuncUndefined.viewLogicFunction)(_displayRef, _viewFuncUndefined.pData);
|
||||
_displayRef.display();
|
||||
|
||||
_error = VIEW_FUNC_UNDEFINED;
|
||||
_currentView = viewLink;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!(*viewLink->viewLogicFunction)(_displayRef, viewLink->pData))
|
||||
{
|
||||
//We display an error message on the screen
|
||||
_displayRef.clearDisplay();
|
||||
((ErrorInfo *)_viewFunctionFailedToExecute.pData)->errorMessage = FPSTR("View function failed\nto execute");
|
||||
((ErrorInfo *)_viewFunctionFailedToExecute.pData)->viewUID = UID;
|
||||
(*_viewFunctionFailedToExecute.viewLogicFunction)(_displayRef, _viewFunctionFailedToExecute.pData);
|
||||
_displayRef.display();
|
||||
|
||||
_error = VIEW_FAILED_TO_EXECUTE;
|
||||
_currentView = viewLink;
|
||||
return false;
|
||||
}
|
||||
|
||||
_displayRef.display();
|
||||
_currentView = viewLink;
|
||||
_error = OK;
|
||||
return true;
|
||||
run();
|
||||
return _error == OK;
|
||||
}
|
||||
|
||||
boolean ScreenManager::displayNextView()
|
||||
void ScreenManager::displayNextView()
|
||||
{
|
||||
_forceRefresh = true;
|
||||
_error = OK;
|
||||
if(_currentView == NO_CURRENT_VIEW && !isListEmpty(_viewLinkedList))
|
||||
{
|
||||
_currentView = _viewLinkedList;
|
||||
return displayView();
|
||||
}
|
||||
|
||||
if(!isListEmpty(_currentView->next))
|
||||
else if(!isListEmpty(_currentView->next))
|
||||
{
|
||||
_currentView = _currentView->next;
|
||||
return displayView();
|
||||
}
|
||||
//End of the views, we cycle again :)
|
||||
else if(isListEmpty(_currentView->next) && !isListEmpty(_viewLinkedList))
|
||||
{
|
||||
_currentView = _viewLinkedList;
|
||||
}
|
||||
|
||||
_currentView = _viewLinkedList;
|
||||
return displayView();
|
||||
//We check if the view function is defined :
|
||||
if(_currentView != NO_CURRENT_VIEW)
|
||||
{
|
||||
if(_currentView->viewLogicFunction == NULL)
|
||||
{
|
||||
((ErrorInfo *)_viewFuncUndefined.pData)->viewUID = _currentView->UID;
|
||||
_error = VIEW_FUNC_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
}
|
||||
|
||||
void ScreenManager::displayPreviousView()
|
||||
{
|
||||
_forceRefresh = true;
|
||||
_error = OK;
|
||||
if(_currentView == NO_CURRENT_VIEW && !isListEmpty(_tail))
|
||||
{
|
||||
_currentView = _tail;
|
||||
}
|
||||
else if(!isListEmpty(_currentView->previous))
|
||||
{
|
||||
_currentView = _currentView->previous;
|
||||
}
|
||||
//End of the views, we cycle again :)
|
||||
else if(isListEmpty(_currentView->previous) && !isListEmpty(_tail))
|
||||
{
|
||||
_currentView = _tail;
|
||||
}
|
||||
|
||||
//We check if the view function is defined :
|
||||
if(_currentView != NO_CURRENT_VIEW)
|
||||
{
|
||||
if(_currentView->viewLogicFunction == NULL)
|
||||
{
|
||||
((ErrorInfo *)_viewFuncUndefined.pData)->viewUID = _currentView->UID;
|
||||
_error = VIEW_FUNC_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
}
|
||||
|
||||
void ScreenManager::invertDisplayColor(const boolean inverted)
|
||||
@ -354,6 +394,20 @@ void ScreenManager::clearDisplay(const boolean bufferOnly)
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenManager::clearViews()
|
||||
{
|
||||
ViewLinkedList cursor = _viewLinkedList;
|
||||
while(!isListEmpty(cursor))
|
||||
{
|
||||
ViewLink *toDelete = cursor;
|
||||
cursor = cursor->next;
|
||||
free(cursor);
|
||||
}
|
||||
//Do not forget to mark the list as empty
|
||||
_viewLinkedList = NULL;
|
||||
_tail = NULL;
|
||||
}
|
||||
|
||||
void ScreenManager::setEnabled(boolean value)
|
||||
{
|
||||
_enabled = value;
|
||||
|
@ -16,18 +16,21 @@ class ScreenManager
|
||||
|
||||
boolean addView(boolean (*viewLogicFunction)(Adafruit_SSD1306&, void*), void *pData, const unsigned char UID);
|
||||
boolean removeView(const unsigned char UID);
|
||||
boolean displayView(const int UID = -1);
|
||||
boolean displayNextView();
|
||||
boolean displayView(const uint8_t UID);
|
||||
void displayNextView();
|
||||
void displayPreviousView();
|
||||
boolean applyCfgFromSD();
|
||||
void invertDisplayColor(const boolean inverted);
|
||||
void orientDisplay(const Orientation orientation);
|
||||
void dimDisplay(const boolean dimmed);
|
||||
void clearDisplay(const boolean bufferOnly = false);
|
||||
void clearViews();
|
||||
void sleep();
|
||||
void wakeUp();
|
||||
void setEnabled(boolean value);
|
||||
boolean getEnabled();
|
||||
boolean init();
|
||||
void run();
|
||||
|
||||
Error getError() const;
|
||||
const char* getErrorMessage() const;
|
||||
@ -58,7 +61,11 @@ class ScreenManager
|
||||
boolean _displayColorInverted;
|
||||
boolean _displayDimmed;
|
||||
boolean _enabled;
|
||||
ViewLink* _currentView;
|
||||
uint8_t _refreshRateHz;
|
||||
uint16_t _refreshInterval;
|
||||
uint64_t _timeRef;
|
||||
boolean _forceRefresh;
|
||||
ViewLink *_currentView, *_tail;
|
||||
ViewLink _viewNotFound, _viewFuncUndefined, _currentViewUndefined, _viewFunctionFailedToExecute;
|
||||
SDCardManager *_sdCardManager;
|
||||
|
||||
|
@ -38,13 +38,13 @@ class TCPServer
|
||||
return _clientList.count();
|
||||
}
|
||||
|
||||
virtual void runServer()
|
||||
virtual void run()
|
||||
{
|
||||
handleNewClients();
|
||||
getClientData();
|
||||
}
|
||||
|
||||
virtual void startServer()
|
||||
virtual void start()
|
||||
{
|
||||
if(!_serverStarted)
|
||||
{
|
||||
@ -53,7 +53,7 @@ class TCPServer
|
||||
}
|
||||
}
|
||||
|
||||
virtual void stopServer()
|
||||
virtual void stop()
|
||||
{
|
||||
if(_serverStarted)
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ boolean TaskSchedulerManager::clearTask()
|
||||
_taskDataDictio.clear();
|
||||
}
|
||||
|
||||
void TaskSchedulerManager::runTaskScheduler()
|
||||
void TaskSchedulerManager::run()
|
||||
{
|
||||
if(_taskDataDictio.count() == 0)return;
|
||||
|
||||
|
@ -69,7 +69,7 @@ class TaskSchedulerManager
|
||||
boolean disableTask(const char *name);
|
||||
boolean disableTask(uint16_t id);
|
||||
boolean clearTask();
|
||||
void runTaskScheduler();
|
||||
void run();
|
||||
const unsigned int taskCount();
|
||||
uint16_t findFreeTaskId();
|
||||
protected:
|
||||
|
@ -9,15 +9,16 @@
|
||||
|
||||
SAB sab;
|
||||
|
||||
unsigned long currentMs = 0, buttonMs = 0;
|
||||
unsigned long currentMs = 0, buttonDownMs(0), buttonUpMs(0);
|
||||
volatile boolean ioStateChange(false);
|
||||
boolean buttonPushSampled(false);
|
||||
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()};
|
||||
ViewSTAPacket vstap = {sab.getConnectivityManager().macAddress(), sab.getConnectivityManager().localIP(), sab.getConnectivityManager().RSSI(), sab.getConnectivityManager().isSTAEnabled()};
|
||||
ViewIoInfoPacket vio = {{0},{0}};
|
||||
SdCardApiPacket sdCardApiPacket = {NULL, NULL};
|
||||
|
||||
DataLogger dataLogger = {HttpClient("192.168.0.17", "/esp8266/dataLogger.php", 1234), 0, false};
|
||||
//DataLogger dataLogger = {HttpClient("192.168.0.17", "/esp8266/dataLogger.php", 1234), 0, false};
|
||||
|
||||
void setup()
|
||||
{
|
||||
@ -70,6 +71,7 @@ void setup()
|
||||
sab.getWebServer().addApiRoutine("/esp/restart", &(espRestartApi), &sab, WEBServer<WEBClient>::GET);
|
||||
sab.getWebServer().addApiRoutine("/esp/reset", &(espResetApi), &sab, WEBServer<WEBClient>::GET);
|
||||
sab.getWebServer().addApiRoutine("/sab/wifi/stainfo", &(staWifiInfoApi), &sab, WEBServer<WEBClient>::GET);
|
||||
sab.getWebServer().addApiRoutine("/sab/wifi/scanner", &(apScannerApi), NULL, WEBServer<WEBClient>::GET);
|
||||
sab.getWebServer().addApiRoutine("/sab/systeminfo", &(systemInfoApi), &sab, WEBServer<WEBClient>::GET);
|
||||
sab.getWebServer().addApiRoutine("/sab/power/info", &(powerInfoApi), &sab, WEBServer<WEBClient>::GET);
|
||||
sab.getWebServer().addApiRoutine("/sab/power/set/freq", &(powerSettingsApi), &sab, WEBServer<WEBClient>::GET);
|
||||
@ -82,8 +84,8 @@ void setup()
|
||||
|
||||
sab.getTaskSchedulerManager().addTask((uint16_t)0, TaskSchedulerManagerHelper::Schedule::scheduleBuilder()->setMillis(5000), &(task_blink), &sab);
|
||||
sab.getTaskSchedulerManager().addTask(1, TaskSchedulerManagerHelper::Schedule::scheduleBuilder()->setSeconds(10), &(task_batt_sensing), &v1p);
|
||||
dataLogger.client.keepAlive(true);
|
||||
sab.getTaskSchedulerManager().addTask(2, TaskSchedulerManagerHelper::Schedule::scheduleBuilder()->setSeconds(1)->setTriggerRightAway(false), &(task_post_data_logger), &dataLogger);
|
||||
//dataLogger.client.keepAlive(true);
|
||||
//sab.getTaskSchedulerManager().addTask(2, TaskSchedulerManagerHelper::Schedule::scheduleBuilder()->setSeconds(1)->setTriggerRightAway(false), &(task_post_data_logger), &dataLogger);
|
||||
|
||||
Serial.println("End setup");
|
||||
}
|
||||
@ -106,13 +108,11 @@ void loop()
|
||||
sab.getIoManager().getPcf().digitalReadAll(vio.ioState);
|
||||
sab.getIoManager().getPcf().getPinModeAll(vio.ioMode);
|
||||
|
||||
sab.getScreenManager().displayView();
|
||||
|
||||
if(ioStateChange) Serial.println(F("ISR triggered"));
|
||||
ioStateChange = false;
|
||||
}
|
||||
|
||||
if(digitalRead(GPIO_0) == 0 && millis() - buttonMs > 500)
|
||||
/*if(digitalRead(GPIO_0) == 0 && millis() - buttonMs > 500)
|
||||
{
|
||||
buttonMs = millis();
|
||||
sab.getScreenManager().displayNextView();
|
||||
@ -120,12 +120,40 @@ void loop()
|
||||
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();
|
||||
}
|
||||
|
||||
//Run the webServer
|
||||
sab.getWebServer().runServer();
|
||||
sab.getFtpServer().runServer();
|
||||
sab.getTaskSchedulerManager().runTaskScheduler();
|
||||
if(digitalRead(GPIO_0) == 1 && buttonPushSampled)
|
||||
{
|
||||
buttonPushSampled = false;
|
||||
buttonUpMs = millis();
|
||||
|
||||
if(buttonUpMs - buttonDownMs < 700 && buttonUpMs - buttonDownMs > 200)//Short press
|
||||
{
|
||||
sab.getScreenManager().displayNextView();
|
||||
#ifdef DEBUG
|
||||
Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(digitalRead(GPIO_0) == 0 && buttonPushSampled && millis() - buttonDownMs > 700)
|
||||
{
|
||||
buttonPushSampled = false;
|
||||
|
||||
sab.getScreenManager().displayPreviousView();
|
||||
#ifdef DEBUG
|
||||
Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID());
|
||||
#endif
|
||||
}
|
||||
|
||||
//Run the differentes services
|
||||
sab.run();
|
||||
}
|
||||
|
||||
ICACHE_RAM_ATTR void ioISR()
|
||||
|
@ -48,7 +48,7 @@ typedef struct viewLink{
|
||||
boolean (*viewLogicFunction)(Adafruit_SSD1306&, void*);
|
||||
void *pData;
|
||||
const int UID;
|
||||
struct viewLink *next;
|
||||
struct viewLink *next, *previous;
|
||||
} ViewLink, *ViewLinkedList;
|
||||
|
||||
char *addChar(char *pointer, const char character);
|
||||
|
@ -30,5 +30,8 @@
|
||||
#define SOFT_VERSION "1.5.5" //WEBServer now parsing form parameters in the post data section
|
||||
#define SOFT_VERSION "1.5.6" //Added new SAB method to set te cpu frequency at run time
|
||||
#define SOFT_VERSION "1.6.0" //Added the new HttpClient class along with tests in a new task
|
||||
#define SOFT_VERSION "1.6.1" //Reworked the ScreenManager in order to display previous views and did some code optimization
|
||||
#define SOFT_VERSION "1.6.2" //Added a run method to the screen manager and reworked the error system
|
||||
#define SOFT_VERSION "1.6.3" //Added a new api call to get nearby wifi access points
|
||||
|
||||
#endif //VERSIONS_H
|
||||
|
@ -38,7 +38,10 @@ boolean nextViewApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc,
|
||||
{
|
||||
SAB *p = (SAB *)pData;
|
||||
char buffer[200];
|
||||
if(p->getScreenManager().displayNextView())
|
||||
|
||||
p->getScreenManager().displayNextView();
|
||||
|
||||
if(p->getScreenManager().getError() == OK)
|
||||
sprintf(buffer, "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"ViewUID\" : \"%d\" }", p->getScreenManager().getCurrentViewUID());
|
||||
else
|
||||
sprintf(buffer, "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"failed\", \"message\" : \"%s\" }", p->getScreenManager().getErrorMessage());
|
||||
@ -215,6 +218,20 @@ boolean staWifiInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *w
|
||||
return true;
|
||||
}*/
|
||||
|
||||
boolean apScannerApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
||||
{
|
||||
uint8_t number = WiFi.scanNetworks();
|
||||
wc->print("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n[");
|
||||
|
||||
for(uint8_t i(0); i < number; i++)
|
||||
{
|
||||
wc->printf("%s{\"SSID\":\"%s\",\"RSSI\":%d,\"Protected\":\"%s\"}", i == 0 ? "":",", WiFi.SSID(i).c_str(), WiFi.RSSI(i), WiFi.encryptionType(i) == ENC_TYPE_NONE ? "No":"Yes");
|
||||
}
|
||||
|
||||
wc->print("]");
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean systemInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
||||
{
|
||||
SAB *p = (SAB *)pData;
|
||||
|
@ -19,6 +19,7 @@ typedef struct sdCardApiPacket
|
||||
boolean sdCardUnmountApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
||||
boolean sdCardMountApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
||||
|
||||
boolean apScannerApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
||||
boolean staWifiInfoApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
||||
boolean apWifiInfoApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
||||
boolean espRestartApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
||||
|
Loading…
Reference in New Issue
Block a user