Remove redundant Timer
This commit is contained in:
parent
e1a279ee75
commit
173c388b67
2 changed files with 0 additions and 31 deletions
|
@ -1,23 +0,0 @@
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
class Timer{
|
|
||||||
private:
|
|
||||||
unsigned long _interval, _lastTick;
|
|
||||||
void (*_callback)(void);
|
|
||||||
|
|
||||||
public:
|
|
||||||
Timer(unsigned long interval, void (*callback)(void)){
|
|
||||||
_interval = interval;
|
|
||||||
_callback = callback;
|
|
||||||
_lastTick = millis();
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop(){
|
|
||||||
unsigned long tick = millis();
|
|
||||||
|
|
||||||
if (tick - _lastTick >= _interval){
|
|
||||||
_callback();
|
|
||||||
_lastTick = tick;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "LED.cpp"
|
#include "LED.cpp"
|
||||||
#include "Timer.cpp"
|
|
||||||
#include "BluetoothLEDCallback.cpp"
|
#include "BluetoothLEDCallback.cpp"
|
||||||
#include "BluetoothService.cpp"
|
#include "BluetoothService.cpp"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
@ -13,12 +12,6 @@ LED _led(&_ledOutput, FADE_IN_DURATION, FADE_OUT_DURATION);
|
||||||
BluetoothLEDCallback _btCallback(&_led);
|
BluetoothLEDCallback _btCallback(&_led);
|
||||||
BluetoothService _btService("Van Lights", &_btCallback);
|
BluetoothService _btService("Van Lights", &_btCallback);
|
||||||
|
|
||||||
void toggle(){
|
|
||||||
//_led.toggle();
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer _timer(3000, &toggle);
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
_ledOutput.attach(16);
|
_ledOutput.attach(16);
|
||||||
|
@ -33,5 +26,4 @@ void setup() {
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
_led.loop();
|
_led.loop();
|
||||||
_timer.loop();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue