Merge remote-tracking branch 'second/develop'
This commit is contained in:
commit
2e340d0cc8
3 changed files with 33 additions and 7 deletions
BIN
firmware/20230512_firmware_dev.ino.bin
Normal file
BIN
firmware/20230512_firmware_dev.ino.bin
Normal file
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
@ -405,6 +405,13 @@ void init_webserver()
|
|||
{
|
||||
const char* key = state.key().c_str();
|
||||
int light = atoi(key) - 1;
|
||||
if (light < 0)
|
||||
{
|
||||
light = 0;
|
||||
} else if (light > (LIGHTS_COUNT-1))
|
||||
{
|
||||
light = (LIGHTS_COUNT-1);
|
||||
}
|
||||
JsonObject values = state.value();
|
||||
|
||||
uint8_t tmp = EEPROM.read(EEPROM_LAST_STATE_STARTUP_ADDRESS);
|
||||
|
@ -441,6 +448,10 @@ void init_webserver()
|
|||
if (values.containsKey("transitiontime"))
|
||||
{
|
||||
default_transitiontime = values["transitiontime"];
|
||||
if (default_transitiontime < 0)
|
||||
{
|
||||
default_transitiontime = 0;
|
||||
}
|
||||
if (tc_enabled == TIMING_CONTROL_DISABLED)
|
||||
{
|
||||
for (uint8_t i = 0 ; i < LIGHTS_COUNT; i++)
|
||||
|
@ -461,6 +472,13 @@ void init_webserver()
|
|||
server.on("/state", HTTP_GET, []()
|
||||
{ // HTTP GET request used to fetch current light state
|
||||
uint8_t light = server.arg("light").toInt() - 1;
|
||||
if (light < 0)
|
||||
{
|
||||
light = 0;
|
||||
} else if (light > (LIGHTS_COUNT-1))
|
||||
{
|
||||
light = (LIGHTS_COUNT-1);
|
||||
}
|
||||
DynamicJsonDocument root(512);
|
||||
root["on"] = light_state[light];
|
||||
root["bri"] = bri[light];
|
||||
|
@ -536,6 +554,10 @@ void init_webserver()
|
|||
if (server.hasArg("transition"))
|
||||
{
|
||||
default_transitiontime = server.arg("transition").toFloat();
|
||||
if (default_transitiontime < 0)
|
||||
{
|
||||
default_transitiontime = 0;
|
||||
}
|
||||
if (tc_enabled == TIMING_CONTROL_DISABLED)
|
||||
{
|
||||
for (uint8_t i = 0 ; i < LIGHTS_COUNT; i++)
|
||||
|
@ -610,9 +632,11 @@ void init_webserver()
|
|||
}
|
||||
|
||||
// scene switch handling
|
||||
if (server.hasArg("scene")) {
|
||||
if (server.hasArg("scene"))
|
||||
{
|
||||
scene = server.arg("scene").toInt();
|
||||
if (EEPROM.read(EEPROM_SCENE_ADDRESS) != scene) {
|
||||
if (EEPROM.read(EEPROM_SCENE_ADDRESS) != scene)
|
||||
{
|
||||
EEPROM.write(EEPROM_SCENE_ADDRESS, scene);
|
||||
EEPROM.commit();
|
||||
Serial.print("Scene set to ");
|
||||
|
@ -623,7 +647,8 @@ void init_webserver()
|
|||
if (server.hasArg("dip")) {
|
||||
uint8_t tmp = EEPROM.read(EEPROM_DYNAMIC_IP_ADDRESS);
|
||||
uint8_t tmp2 = (server.arg("dip") == "true" ? 1 : 0);
|
||||
if (tmp != tmp2) {
|
||||
if (tmp != tmp2)
|
||||
{
|
||||
EEPROM.write(EEPROM_DYNAMIC_IP_ADDRESS, tmp2);
|
||||
EEPROM.commit();
|
||||
Serial.print("Set dynamic IP to ");
|
||||
|
@ -671,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);
|
||||
|
|
Loading…
Reference in a new issue