Set up scheduled program cycles #24

Merged
W1CDN merged 41 commits from program-cycle into main 2023-09-15 16:51:45 -05:00
2 changed files with 9 additions and 5 deletions
Showing only changes of commit a69128397a - Show all commits

View File

@ -10,7 +10,7 @@
[env:esp32doit-devkit-v1] [env:esp32doit-devkit-v1]
platform = espressif32 platform = espressif32
build_flags = ;build_flags =
; -std=c++11 ; -std=c++11
; -std=gnu++11 ; -std=gnu++11
board = esp32doit-devkit-v1 board = esp32doit-devkit-v1

View File

@ -162,10 +162,11 @@ const int blinker = LED_BUILTIN;
// Timers // Timers
//auto timer = timer_create_default(); //auto timer = timer_create_default();
Timer<1> timer; Timer<1> timer;
auto time_until_start = timer_create_default();
// Example from https://github.com/contrem/arduino-timer#examples // Example from https://github.com/contrem/arduino-timer#examples
bool toggle_led(void *) { bool toggle_led(void *) {
Serial.print("Timer time: ");
Serial.println(rtc.now().timestamp());
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); // toggle the LED digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); // toggle the LED
return true; // keep timer active? true return true; // keep timer active? true
} }
@ -602,11 +603,17 @@ void setup() {
yourInputStartTimeUnix = atol(inputMessage.c_str()); yourInputStartTimeUnix = atol(inputMessage.c_str());
//} //}
Serial.println(yourInputStartTimeUnix); Serial.println(yourInputStartTimeUnix);
timer.at(millis() + 10000, toggle_led);
Serial.println(millis());
auto active_tasks = timer.size();
Serial.println(active_tasks);
} }
// else { // else {
// inputMessage = "No message sent"; // inputMessage = "No message sent";
// } // }
//request->send(200, "text/plain", inputMessage); //request->send(200, "text/plain", inputMessage);
// https://techtutorialsx.com/2018/01/14/esp32-arduino-http-server-external-and-internal-redirects/
request->redirect("/"); request->redirect("/");
}); });
server.onNotFound(notFound); server.onNotFound(notFound);
@ -621,13 +628,10 @@ void setup() {
// sender.setMessage(String("73 de kb3jcy ")); // sender.setMessage(String("73 de kb3jcy "));
// sender.startSending(); // sender.startSending();
} }
void loop() { void loop() {
// Timers // Timers
time_until_start.tick();
timer.tick(); timer.tick();
// DateTime now = rtc.now(); // DateTime now = rtc.now();