From 75e5541e5e46a8b3ae9f5832110a04221c4ffcca Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sat, 29 Apr 2023 20:30:42 +0200 Subject: [PATCH] Fixed pwm start in case that the timing control mechanism is activated in a part of the data blocks. Updated tc link buttons to prevent reload of the web interface. --- firmware/firmware.ino | 90 ++++++++++++++++++++++++++++++++----- firmware/timing_control.ino | 8 ++-- 2 files changed, 83 insertions(+), 15 deletions(-) diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 8c71b2f..16b1f16 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -9,8 +9,11 @@ #include "config.h" //********* Config block *********// +// blue, warmwhite, purple, white&red&green +// blau, schwarz, rot, weiß // ch1, ch2, ch3, ch4 -uint8_t pins[LIGHTS_COUNT] = { 14, 12, 15, 13 }; +// D1, D2, D7, D5 +uint8_t pins[LIGHTS_COUNT] = { 5, 4, 13, 14 }; IPAddress strip_ip(192, 168, 0, 26); // choose an unique IP Adress IPAddress gateway_ip(192, 168, 0, 1); // Router IP @@ -660,15 +663,13 @@ void init_webserver() http_content += "

Light " + (String)(light_num + 1) + "

"; http_content += "
"; http_content += ""; - http_content += "ON"; - http_content += "OFF"; + http_content += "ON"; + http_content += "OFF"; http_content += "
"; // slider for brightness http_content += "
"; - http_content += ""; + http_content += ""; http_content += ""; http_content += " " + (String)(int)(bri[light_num] * 100.0 / 255.0) + "%"; http_content += "
"; @@ -686,6 +687,73 @@ void init_webserver() http_content += "
"; } + http_content += ""; // startup state and scene for all of the lights http_content += ""; @@ -729,12 +797,12 @@ void init_webserver() http_content += "
"; http_content += ""; int tc_val = EEPROM.read(EEPROM_TIMING_CONTROL_ENABLED_ADDRESS); - http_content += "ON"; - http_content += "ON"; + http_content += "OFF"; + http_content += "\" href=\"#\">OFF"; http_content += "
"; http_content += "
"; @@ -966,7 +1034,7 @@ void init_webserver() "fetch(url)" ".then(response => response.json())" ".then(data => {" - "const pwmValue = ((Math.round((data.curpwm - ((data.curpwm >= " + (String)PWM_MIN+ ") ? " + (String)PWM_MIN + " : 0)) / " + (String)PWM_MAX + " * 100.0) * 100.0) / 100.0).toFixed(2);" // pwm as % PWM_MIN to PWM_MAX + "const pwmValue = ((Math.round((data.curpwm - ((data.curpwm >= " + (String)PWM_MIN+ ") ? " + (String)PWM_MIN + " : 0)) / " + (String)PWM_MAX + " * 10000) / 100).toFixed(2));"// pwm as % PWM_MIN to PWM_MAX "console.log('curpwm[' + i + '] = ' + data.curpwm + ' = ' + pwmValue);" "pwmElement.innerText = pwmValue.toString();" "pwmElement.value = pwmValue;" diff --git a/firmware/timing_control.ino b/firmware/timing_control.ino index eaaadd6..cadb2af 100644 --- a/firmware/timing_control.ino +++ b/firmware/timing_control.ino @@ -214,19 +214,19 @@ void tc_update_main() bri[3] = tc_data[target_data_block].ch4; if (tc_data[target_data_block-1].ch1 != current_bri[0]) { - current_bri[0] = tc_data[target_data_block-1].ch1; + current_bri[0] = tc_data[target_data_block-1].ch1 + ((tc_data[target_data_block].ch1 == 0) ? 1 : -1); } if (tc_data[target_data_block-1].ch2 != current_bri[1]) { - current_bri[1] = tc_data[target_data_block-1].ch2; + current_bri[1] = tc_data[target_data_block-1].ch2 + ((tc_data[target_data_block].ch2 == 0) ? 1 : -1); } if (tc_data[target_data_block-1].ch3 != current_bri[2]) { - current_bri[2] = tc_data[target_data_block-1].ch3; + current_bri[2] = tc_data[target_data_block-1].ch3 + ((tc_data[target_data_block].ch3 == 0) ? 1 : -1); } if (tc_data[target_data_block-1].ch4 != current_bri[3]) { - current_bri[3] = tc_data[target_data_block-1].ch4; + current_bri[3] = tc_data[target_data_block-1].ch4 + ((tc_data[target_data_block].ch4 == 0) ? 1 : -1); } for (uint8_t i = 0; i < LIGHTS_COUNT; i++)