Merge branch 'development' into release-7.1

This commit is contained in:
Theo Arends 2019-12-02 14:55:56 +01:00
commit 876a1e699c
2 changed files with 13 additions and 11 deletions

View File

@ -118,8 +118,10 @@ void WifiSetMode(WiFiMode_t wifi_mode)
delay(100); delay(100);
} }
if (!WiFi.mode(wifi_mode)) { uint32_t retry = 2;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Cannot set Mode")); while (!WiFi.mode(wifi_mode) && retry--) {
AddLog_P(LOG_LEVEL_INFO, S_LOG_WIFI, PSTR("Retry set Mode..."));
delay(100);
} }
if (wifi_mode == WIFI_OFF) { if (wifi_mode == WIFI_OFF) {

View File

@ -241,8 +241,8 @@ struct LIGHT {
uint8_t last_color[LST_MAX]; uint8_t last_color[LST_MAX];
uint8_t color_remap[LST_MAX]; uint8_t color_remap[LST_MAX];
uint16_t wheel = 0; uint8_t wheel = 0;
uint16_t random = 0; uint8_t random = 0;
uint8_t subtype = 0; // LST_ subtype uint8_t subtype = 0; // LST_ subtype
uint8_t device = 0; uint8_t device = 0;
uint8_t old_power = 1; uint8_t old_power = 1;
@ -1518,18 +1518,18 @@ void LightCycleColor(int8_t direction)
if (0 == direction) { if (0 == direction) {
if (Light.random == Light.wheel) { if (Light.random == Light.wheel) {
Light.random = random(358) +1; // Random Hue Light.random = random(255);
} }
Light.wheel += (Light.random < Light.wheel) ? -1 : 1; direction = (Light.random < Light.wheel) ? -1 : 1;
} else {
Light.wheel += direction;
} }
if (Light.wheel > 359) { Light.wheel = 1; } // Loop Hue colors Light.wheel += direction;
if (Light.wheel < 1) { Light.wheel = 359; } // Loop Hue colors uint16_t hue = changeUIntScale(Light.wheel, 0, 255, 0, 359); // Scale to hue to keep amount of steps low (max 255 instead of 359)
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: random %d, wheel %d, hue %d"), Light.random, Light.wheel, hue);
uint8_t sat; uint8_t sat;
light_state.getHSB(nullptr, &sat, nullptr); // Allow user control over Saturation light_state.getHSB(nullptr, &sat, nullptr); // Allow user control over Saturation
light_state.setHS(Light.wheel, sat); light_state.setHS(hue, sat);
light_controller.calcLevels(Light.new_color); light_controller.calcLevels(Light.new_color);
} }