From 076a81a1011ee77de44534d83f68410b94a1df08 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Fri, 12 May 2023 12:19:00 +0200 Subject: [PATCH] Switch off of the lights fixed. brightness will be set to 0 now. PWM frequency set to 500Hz. --- firmware/config.h | 6 +++--- firmware/firmware.ino | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/firmware/config.h b/firmware/config.h index 40795f4..376be55 100644 --- a/firmware/config.h +++ b/firmware/config.h @@ -18,7 +18,7 @@ #define EEPROM_LAST_STATE_ADDRESS 4 // the first "last state" information for the first light #define EEPROM_TIMING_DATA_ADDRESS (EEPROM_LAST_STATE_ADDRESS + LIGHTS_COUNT) // Stored data date per light ELE_USED; HH; MM; CH1; CH2; CH3; CH4; -#define BRI_MOD_STEPS_PER_SEC 10 +#define BRI_MOD_STEPS_PER_SEC 25 #define TIME_CHECK_INTERVAL_MS (60000UL) // 60 second interval #define TIME_LIGHTENGINE_INTERVAL_MS (1000UL / BRI_MOD_STEPS_PER_SEC) // BRI_MOD_STEPS_PER_SEC steps per second to in-/decrease the brightness @@ -26,11 +26,11 @@ #define MY_NTP_SERVER "de.pool.ntp.org" // 10 bit PWM -#define PWM_FREQ (50000UL) +#define PWM_FREQ (500UL) #define PWM_OFF 0 // 0V #define PWM_MIN 0 // 0V - minimum light amount (~1%) #define PWM_MAX 255 // 24V - maximum light amount (100%) #define BRI_TO_PWM_FACTOR 1.0 // 24V-0V = 24V range #define PWM_TEST_INTERVA_MS 1000 -#define TEST_PWM_CHG_CNT 5 +#define TEST_PWM_CHG_CNT 1 diff --git a/firmware/firmware.ino b/firmware/firmware.ino index d157bb0..eee9c23 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -162,7 +162,7 @@ void lightEngine() if (current_bri[i] != 0) { in_transition = true; - current_bri[i] += step_level[i] / BRI_MOD_STEPS_PER_SEC; + current_bri[i] -= step_level[i] / BRI_MOD_STEPS_PER_SEC; if (current_bri[i] < 0) { current_bri[i] = 0; @@ -696,6 +696,7 @@ void init_webserver() } else if (server.arg("on" + (String)light) == "false" && light_state[light] == true) { light_state[light] = false; + bri[light] = 0; if (tmp == 0 && EEPROM.read(EEPROM_LAST_STATE_ADDRESS + light) == 1) { EEPROM.write(EEPROM_LAST_STATE_ADDRESS + light, LIGHT_STATE_OFF);