diff --git a/firmware/firmware.ino b/firmware/firmware.ino index b87bf44..c9fe43a 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -495,7 +495,7 @@ void init_webserver() { test_pwm = true; tc_enabled_old = tc_enabled; - tc_enabled == TIMING_CONTROL_DISABLED; + tc_enabled = TIMING_CONTROL_DISABLED; server.send(200, "text/html", "OK"); }); @@ -966,9 +966,7 @@ void test_pwm_main() if (test_pwm == false) { return; - } - - if ((test_pwm_lastcheck_ms + PWM_TEST_INTERVA_MS) <= millis()) + } else if ((test_pwm_lastcheck_ms + PWM_TEST_INTERVA_MS) <= millis()) { test_pwm_lastcheck_ms = millis(); @@ -994,7 +992,7 @@ void test_pwm_main() // ----------------------- // case TEST_PWM_STATE_CH1_INC: - if (current_bri[0] < 255) + if (bri[0] < 255) { bri[0] += TEST_PWM_CHG_CNT; transitiontime[0] = 1; @@ -1008,7 +1006,7 @@ void test_pwm_main() case TEST_PWM_STATE_CH1_DEC: - if (current_bri[0] > 0) + if (bri[0] > 0) { bri[0] -= TEST_PWM_CHG_CNT; transitiontime[0] = 1; @@ -1017,7 +1015,12 @@ void test_pwm_main() } else { light_state[0] = false; + bri[0] = 0; + current_bri[0] = 0; + current_pwm[0] = 0; transitiontime[0] = 0; + process_lightdata(0, transitiontime[0]); + light_state[1] = true; test_pwm_state = TEST_PWM_STATE_CH2_INC; } @@ -1026,7 +1029,7 @@ void test_pwm_main() // ----------------------- // case TEST_PWM_STATE_CH2_INC: - if (current_bri[1] < 255) + if (bri[1] < 255) { bri[1] += TEST_PWM_CHG_CNT; transitiontime[1] = 1; @@ -1040,7 +1043,7 @@ void test_pwm_main() case TEST_PWM_STATE_CH2_DEC: - if (current_bri[1] > 0) + if (bri[1] > 0) { bri[1] -= TEST_PWM_CHG_CNT; transitiontime[1] = 1; @@ -1049,7 +1052,12 @@ void test_pwm_main() } else { light_state[1] = false; + bri[1] = 0; + current_bri[1] = 0; + current_pwm[1] = 0; transitiontime[1] = 0; + process_lightdata(1, transitiontime[1]); + light_state[2] = true; test_pwm_state = TEST_PWM_STATE_CH3_INC; } @@ -1058,7 +1066,7 @@ void test_pwm_main() // ----------------------- // case TEST_PWM_STATE_CH3_INC: - if (current_bri[2] < 255) + if (bri[2] < 255) { bri[2] += TEST_PWM_CHG_CNT; transitiontime[2] = 1; @@ -1072,7 +1080,7 @@ void test_pwm_main() case TEST_PWM_STATE_CH3_DEC: - if (current_bri[2] > 0) + if (bri[2] > 0) { bri[2] -= TEST_PWM_CHG_CNT; transitiontime[2] = 1; @@ -1080,8 +1088,13 @@ void test_pwm_main() } else { - light_state[2] = false; + light_state[2] = false; + bri[2] = 0; + current_bri[2] = 0; + current_pwm[2] = 0; transitiontime[2] = 0; + process_lightdata(2, transitiontime[2]); + light_state[3] = true; test_pwm_state = TEST_PWM_STATE_CH4_INC; } @@ -1090,7 +1103,7 @@ void test_pwm_main() // ----------------------- // case TEST_PWM_STATE_CH4_INC: - if (current_bri[3] < 255) + if (bri[3] < 255) { bri[3] += TEST_PWM_CHG_CNT; transitiontime[3] = 1; @@ -1104,7 +1117,7 @@ void test_pwm_main() case TEST_PWM_STATE_CH4_DEC: - if (current_bri[3] > 0) + if (bri[3] > 0) { bri[3] -= TEST_PWM_CHG_CNT; transitiontime[3] = 1; @@ -1123,8 +1136,8 @@ void test_pwm_main() transitiontime[i] = 0; process_lightdata(i, transitiontime[i]); } + test_pwm_state = TEST_PWM_STATE_INIT; } - test_pwm_state = TEST_PWM_STATE_INIT; break; // ----------------------- //