Added initial Melody Playback Ability
Now, controlled via MQTT a Playback of a melody can Start, Stop, Pause etc. Settings like speed, total duration, pauses etc can be set.
This commit is contained in:
28
build/sketch/Timers.hpp
Normal file
28
build/sketch/Timers.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#line 1 "C:\\Users\\espi_\\Documents\\Arduino\\vesper\\Timers.hpp"
|
||||
#pragma once
|
||||
|
||||
extern volatile uint64_t startTime;
|
||||
extern melody_attributes melody;
|
||||
extern volatile bool playing;
|
||||
|
||||
void durationTimer(void *param);
|
||||
|
||||
|
||||
void durationTimer(void *param){
|
||||
|
||||
// SETUP TASK
|
||||
|
||||
for (;;){
|
||||
|
||||
if (playing){
|
||||
uint64_t now = millis();
|
||||
uint64_t timeToStop = startTime + melody.duration;
|
||||
if (now > timeToStop) {
|
||||
playing = false;
|
||||
Serial.println("Time Limit Reached. Stopping !");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user