mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-06 03:50:13 +02:00
Loop function added, generic timer added, message buffer increased (you never know)
This commit is contained in:
parent
bf37f655df
commit
957a91e55e
6 changed files with 41 additions and 4 deletions
12
Software/src/devboard/utils/timer.cpp
Normal file
12
Software/src/devboard/utils/timer.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "timer.h"
|
||||
|
||||
MyTimer::MyTimer(unsigned long interval) : interval(interval), previousMillis(0) {}
|
||||
|
||||
bool MyTimer::elapsed() {
|
||||
unsigned long currentMillis = millis();
|
||||
if (currentMillis - previousMillis >= interval) {
|
||||
previousMillis = currentMillis;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
16
Software/src/devboard/utils/timer.h
Normal file
16
Software/src/devboard/utils/timer.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef __MYTIMER_H__
|
||||
#define __MYTIMER_H__
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
class MyTimer {
|
||||
public:
|
||||
MyTimer(unsigned long interval);
|
||||
bool elapsed();
|
||||
|
||||
private:
|
||||
unsigned long interval;
|
||||
unsigned long previousMillis;
|
||||
};
|
||||
|
||||
#endif // __MYTIMER_H__
|
Loading…
Add table
Add a link
Reference in a new issue