Compare commits
3 Commits
cd2b2ba624
...
e7cff6287f
Author | SHA1 | Date | |
---|---|---|---|
|
e7cff6287f | ||
|
7e58804af9 | ||
|
4f265e4c79 |
25
src/app/NonBlockingDelay.cpp
Normal file
25
src/app/NonBlockingDelay.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Author : Anatole SCHRAMM-HENRY
|
||||
* Created on : 03/04/2022
|
||||
* Licence : MIT
|
||||
*
|
||||
* Dead simple object implementing a non blocking delay using the Arduino framework.
|
||||
*/
|
||||
#include "NonBlockingDelay.h"
|
||||
|
||||
NonBlockingDelay::NonBlockingDelay(const unsigned long delay, unsigned long tickReference) : _delay(delay), _tickReference(tickReference){}
|
||||
|
||||
void NonBlockingDelay::reset()
|
||||
{
|
||||
_tickReference = millis();
|
||||
}
|
||||
|
||||
NonBlockingDelay::operator bool()
|
||||
{
|
||||
bool isTimeElapsed(millis() - _tickReference > _delay);
|
||||
|
||||
if(isTimeElapsed)
|
||||
reset();
|
||||
|
||||
return isTimeElapsed;
|
||||
}
|
27
src/app/NonBlockingDelay.h
Normal file
27
src/app/NonBlockingDelay.h
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Author : Anatole SCHRAMM-HENRY
|
||||
* Created on : 03/04/2022
|
||||
* Licence : MIT
|
||||
*
|
||||
* Dead simple object implementing a non blocking delay using the Arduino framework.
|
||||
*/
|
||||
#ifndef NONBLOCKINGDELAY_H
|
||||
#define NONBLOCKINGDELAY_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
class NonBlockingDelay
|
||||
{
|
||||
public:
|
||||
NonBlockingDelay(const unsigned long delay, unsigned long tickReference = millis());
|
||||
|
||||
// Manually reset the internal tick reference
|
||||
void reset();
|
||||
operator bool();
|
||||
protected:
|
||||
private:
|
||||
const unsigned long _delay;
|
||||
unsigned long _tickReference;
|
||||
};
|
||||
|
||||
#endif //NONBLOCKINGDELAY_H
|
@ -1,3 +1,10 @@
|
||||
/**
|
||||
* Author : Anatole SCHRAMM-HENRY
|
||||
* Created on : 24/02/2019
|
||||
* Licence : MIT
|
||||
*
|
||||
* Dead simple object implementing a non blocking delay using the Arduino framework.
|
||||
*/
|
||||
#include "definition.h"
|
||||
#include "SAB.h"
|
||||
#include "views.h"
|
||||
@ -6,13 +13,15 @@
|
||||
#include "CFGDictionary.h"
|
||||
#include "CFGParameterValue.h"
|
||||
#include "EventHandler.h"
|
||||
#include "NonBlockingDelay.h"
|
||||
#define DEBUG
|
||||
|
||||
SAB sab;
|
||||
EventHandler evHan;
|
||||
EventHandler::Event evt;
|
||||
|
||||
unsigned long currentMs = 0;
|
||||
NonBlockingDelay dataRefreshNBD(1000);
|
||||
|
||||
volatile boolean ioStateChange(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()};
|
||||
@ -96,9 +105,8 @@ void setup()
|
||||
void loop()
|
||||
{
|
||||
|
||||
if(millis() - currentMs >= 1000 || ioStateChange)
|
||||
if(dataRefreshNBD || ioStateChange)
|
||||
{
|
||||
currentMs = millis();
|
||||
v1p.dateTime = sab.getRtcManager().getDateTime();
|
||||
v1p.nbViews = sab.getScreenManager().getViewCount();
|
||||
vap.ipAddr = sab.getConnectivityManager().softAPIP();
|
||||
|
@ -38,6 +38,7 @@
|
||||
//#define SOFT_VERSION "1.6.6" //Removed useless INIT state that was like the LINE_BREAK state and added '-' as an allowed PARAM and VALUE character
|
||||
//#define SOFT_VERSION "1.6.7" //Changed the way we store and return the 3 letter month abbreviation
|
||||
//#define SOFT_VERSION "1.6.8" //Finally fixed the random crash issue concerning the servers :)
|
||||
#define SOFT_VERSION "1.6.9" //Updated the whole app the work with the esp8266 core 3.0.2 version, removed a bunch of warnings, corrected an array index overflow in apiTesterApi function
|
||||
//#define SOFT_VERSION "1.6.9" //Updated the whole app to work with the esp8266 core 3.0.2 version, removed a bunch of warnings, corrected an array index overflow in apiTesterApi function
|
||||
#define SOFT_VERSION "1.6.10" //Introduced new class : NonBlockingDelay which is used in the app.ino file.
|
||||
|
||||
#endif //VERSIONS_H
|
||||
|
Loading…
Reference in New Issue
Block a user