diff --git a/tasmota/tasmota_support/support_rotary.ino b/tasmota/tasmota_support/support_rotary.ino index 4e8e22d1192a..90fcf57dd46d 100644 --- a/tasmota/tasmota_support/support_rotary.ino +++ b/tasmota/tasmota_support/support_rotary.ino @@ -124,8 +124,7 @@ static void IRAM_ATTR RotaryIsrArgMiDesk(void *arg) { encoder->state = (state >> 2); } -void IRAM_ATTR RotaryIsrArg(void *arg); -void RotaryIsrArg(void *arg) { +static void IRAM_ATTR RotaryIsrArg(void *arg) { tEncoder* encoder = static_cast(arg); // Theo Arends @@ -146,9 +145,9 @@ void RotaryInitMaxSteps(void) { } uint8_t max_steps = Settings->param[P_ROTARY_MAX_STEP]; if (!Rotary.model) { max_steps *= 3; } - Rotary.dimmer_increment = 100 / max_steps; // Dimmer 1..100 = 100 - Rotary.ct_increment = 350 / max_steps; // Ct 153..500 = 347 - Rotary.color_increment = 360 / max_steps; // Hue 0..359 = 360 + Rotary.dimmer_increment = 100 / min((uint8_t)100, max_steps); // Dimmer 1..100 = 100 + Rotary.ct_increment = 350 / min((uint8_t)350, max_steps); // Ct 153..500 = 347 + Rotary.color_increment = 360 / min((uint8_t)360, max_steps); // Hue 0..359 = 360 } void RotaryInit(void) { diff --git a/tasmota/tasmota_xdrv_driver/xdrv_04_light.ino b/tasmota/tasmota_xdrv_driver/xdrv_04_light.ino index 6599fde21d2e..127e036c331f 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_04_light.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_04_light.ino @@ -1358,9 +1358,10 @@ void LightColorOffset(int32_t offset) { uint16_t hue; uint8_t sat; light_state.getHSB(&hue, &sat, nullptr); // Allow user control over Saturation - hue += offset; - if (hue < 0) { hue += 359; } - if (hue > 359) { hue -= 359; } + int16_t hue_new = hue + offset; + if (hue_new < 0) { hue_new += 359; } + if (hue_new > 359) { hue_new -= 359; } + hue = hue_new; if (!Light.pwm_multi_channels) { light_state.setHS(hue, sat); } else {