Compare commits

...

3 Commits

Author SHA1 Message Date
anschrammh
e7cff6287f Updated versions history 2022-04-04 21:42:28 +02:00
anschrammh
7e58804af9 Now using a non blocking delay object :) 2022-04-04 21:41:35 +02:00
anschrammh
4f265e4c79 Added a new very simple class to cleanly perform non blocking delays 2022-04-04 21:39:33 +02:00
4 changed files with 65 additions and 4 deletions

View 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;
}

View 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

View File

@ -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();

View File

@ -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