From 12d7ab9b0f64a72467f2d93166be0b9b1a167d8e Mon Sep 17 00:00:00 2001 From: Drath Date: Sun, 28 Dec 2025 13:55:58 +0100 Subject: [PATCH] slow down race condition, kinda ugly --- main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 2204b67..452f5cf 100644 --- a/main.cpp +++ b/main.cpp @@ -172,10 +172,12 @@ int main() { { std::unique_ptr pSensors = std::make_unique(); std::vector threads; - std::function funcs[] = {displayThread, hassThread, sensorsThread}; + std::function funcs[] = {displayThread, sensorsThread, hassThread}; - for (auto& f : funcs) + for (auto& f : funcs) { threads.emplace_back(f, pSensors.get()); // params: function, stop_token (implied), pointer to sensor struct + std::this_thread::sleep_for(std::chrono::milliseconds(10)); // start threads with delay so displayThread can quit the app if theres no lcd + } sem::main.acquire(); }