Refactor LedHandler to a class

This commit is contained in:
Djuri 2025-01-05 21:19:28 +01:00
parent ac13098824
commit d023643090
Signed by: djuri
GPG key ID: 61B9B2DDE5AA3AC1
11 changed files with 931 additions and 935 deletions

View file

@ -18,6 +18,7 @@
#define WEBSERVER_H
#include "ESPAsyncWebServer.h"
#include "lib/config.hpp"
#include "lib/led_handler.hpp"
uint wifiLostConnection;
uint priceNotifyLostConnection = 0;
@ -58,13 +59,14 @@ void handleFrontlight() {
if (hasLightLevel() && preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE) != 0) {
uint lightLevel = getLightLevel();
uint luxThreshold = preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE);
auto& ledHandler = getLedHandler();
if (lightLevel <= 1 && preferences.getBool("flOffWhenDark", DEFAULT_FL_OFF_WHEN_DARK)) {
if (frontlightIsOn()) frontlightFadeOutAll();
} else if (lightLevel < luxThreshold && !frontlightIsOn()) {
frontlightFadeInAll();
} else if (frontlightIsOn() && lightLevel > luxThreshold) {
frontlightFadeOutAll();
if (ledHandler.frontlightIsOn()) ledHandler.frontlightFadeOutAll();
} else if (lightLevel < luxThreshold && !ledHandler.frontlightIsOn()) {
ledHandler.frontlightFadeInAll();
} else if (ledHandler.frontlightIsOn() && lightLevel > luxThreshold) {
ledHandler.frontlightFadeOutAll();
}
}
#endif
@ -100,9 +102,7 @@ void checkMissedBlocks() {
}
}
void monitorDataConnections() {
// Price notification monitoring
if (getPriceNotifyInit() && !preferences.getBool("fetchEurPrice", DEFAULT_FETCH_EUR_PRICE) && !isPriceNotifyConnected()) {
handlePriceNotifyDisconnection();
@ -137,7 +137,6 @@ extern "C" void app_main() {
bool thirdPartySource = getDataSource() == THIRD_PARTY_SOURCE;
while (true) {
if (eventSourceTaskHandle != NULL) {
xTaskNotifyGive(eventSourceTaskHandle);