chore: code cleanup

This commit is contained in:
2026-06-08 22:39:17 +02:00
parent 9b272b93e8
commit 00b937edf4
2 changed files with 1 additions and 36 deletions

View File

@@ -1,35 +0,0 @@
#pragma once
#include <Arduino.h>
class ParallelTask {
private:
unsigned long previousMillis;
unsigned long interval;
void (*callback)(); // Pointer to the function you want to run
public:
// Constructor: Takes the interval in milliseconds and the function to run
ParallelTask(unsigned long interval_ms, void (*func)()) {
interval = interval_ms;
callback = func;
previousMillis = 0;
}
// Call this in your main loop()
void update() {
unsigned long currentMillis = millis();
// Handle millis() rollover (happens ~every 50 days) and check interval
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (callback) {
callback();
}
}
}
// Optional: Update the interval dynamically while running
void setInterval(unsigned long new_interval) {
interval = new_interval;
}
};

View File

@@ -42,7 +42,7 @@ void displayValue() {
}
void measureLight() {
int value = analogRead(PIN_LDR);asdfasdf
int value = analogRead(PIN_LDR);
displayedValue = 100 - (int)(value / 10);
}