Added brightness range check to brightness webserver set feature. Added a reset function to the timing control module. Fixed the pwm test feature by adding tc reset function call.
This commit is contained in:
parent
1efca24ff2
commit
9d02e054f5
3 changed files with 23 additions and 7 deletions
|
@ -18,7 +18,7 @@
|
||||||
#define EEPROM_LAST_STATE_ADDRESS 4 // the first "last state" information for the first light
|
#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 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 5
|
#define BRI_MOD_STEPS_PER_SEC 10
|
||||||
|
|
||||||
#define TIME_CHECK_INTERVAL_MS (60000UL) // 60 second interval
|
#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
|
#define TIME_LIGHTENGINE_INTERVAL_MS (1000UL / BRI_MOD_STEPS_PER_SEC) // BRI_MOD_STEPS_PER_SEC steps per second to in-/decrease the brightness
|
||||||
|
|
|
@ -78,10 +78,10 @@ uint8_t test_pwm_state = TEST_PWM_STATE_INIT;
|
||||||
bool light_state[LIGHTS_COUNT];
|
bool light_state[LIGHTS_COUNT];
|
||||||
bool in_transition;
|
bool in_transition;
|
||||||
|
|
||||||
int default_transitiontime = 4; // 4 seconds
|
int default_transitiontime = 4; // 4 = 4 seconds
|
||||||
|
|
||||||
int transitiontime[LIGHTS_COUNT];
|
uint16_t transitiontime[LIGHTS_COUNT];
|
||||||
int bri[LIGHTS_COUNT];
|
uint16_t bri[LIGHTS_COUNT];
|
||||||
uint16_t current_pwm[LIGHTS_COUNT];
|
uint16_t current_pwm[LIGHTS_COUNT];
|
||||||
|
|
||||||
float step_level[LIGHTS_COUNT];
|
float step_level[LIGHTS_COUNT];
|
||||||
|
@ -637,7 +637,15 @@ void init_webserver()
|
||||||
|
|
||||||
if (server.hasArg("bri" + (String)light))
|
if (server.hasArg("bri" + (String)light))
|
||||||
{
|
{
|
||||||
bri[light] = (int)server.arg("bri" + (String)light).toInt();
|
int tmp = (int)server.arg("bri" + (String)light).toInt();
|
||||||
|
|
||||||
|
if (tmp > 255)
|
||||||
|
{
|
||||||
|
tmp = 255;
|
||||||
|
} else if (tmp < 0) {
|
||||||
|
tmp = 0;
|
||||||
|
}
|
||||||
|
bri[light] = tmp;
|
||||||
Serial.print("Brightness ");
|
Serial.print("Brightness ");
|
||||||
Serial.print(light);
|
Serial.print(light);
|
||||||
Serial.print(" set to ");
|
Serial.print(" set to ");
|
||||||
|
@ -1124,6 +1132,7 @@ void test_pwm_main()
|
||||||
|
|
||||||
test_pwm = false;
|
test_pwm = false;
|
||||||
tc_enabled = tc_enabled_old;
|
tc_enabled = tc_enabled_old;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < LIGHTS_COUNT; i++)
|
for (uint8_t i = 0; i < LIGHTS_COUNT; i++)
|
||||||
{
|
{
|
||||||
light_state[i] = false;
|
light_state[i] = false;
|
||||||
|
@ -1134,6 +1143,7 @@ void test_pwm_main()
|
||||||
process_lightdata(i, transitiontime[i]);
|
process_lightdata(i, transitiontime[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tc_reset();
|
||||||
tc_update_main(); // load the tc if required
|
tc_update_main(); // load the tc if required
|
||||||
|
|
||||||
test_pwm_state = TEST_PWM_STATE_INIT;
|
test_pwm_state = TEST_PWM_STATE_INIT;
|
||||||
|
|
|
@ -25,6 +25,8 @@ bool tc_testOngoing = false;
|
||||||
|
|
||||||
uint32_t tc_last_check = 60000;
|
uint32_t tc_last_check = 60000;
|
||||||
|
|
||||||
|
uint8_t current_target_data_block = 255;
|
||||||
|
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
NTPClient timeClient(ntpUDP, MY_NTP_SERVER);
|
NTPClient timeClient(ntpUDP, MY_NTP_SERVER);
|
||||||
|
|
||||||
|
@ -126,6 +128,11 @@ void tc_init()
|
||||||
|
|
||||||
//********************************//
|
//********************************//
|
||||||
|
|
||||||
|
void tc_reset()
|
||||||
|
{
|
||||||
|
current_target_data_block = 255;
|
||||||
|
}
|
||||||
|
|
||||||
void tc_update_loop()
|
void tc_update_loop()
|
||||||
{
|
{
|
||||||
static uint8_t last_min_check = 255;
|
static uint8_t last_min_check = 255;
|
||||||
|
@ -146,7 +153,6 @@ void tc_update_loop()
|
||||||
|
|
||||||
void tc_update_main()
|
void tc_update_main()
|
||||||
{
|
{
|
||||||
static uint8_t current_target_data_block = 255;
|
|
||||||
uint8_t target_data_block = 255;
|
uint8_t target_data_block = 255;
|
||||||
|
|
||||||
if (tc_enabled == TIMING_CONTROL_DISABLED)
|
if (tc_enabled == TIMING_CONTROL_DISABLED)
|
||||||
|
|
Loading…
Reference in a new issue