mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
Fix rotary edge cases (#19164)
This commit is contained in:
parent
16b1c5577a
commit
7f24d2027f
@ -124,8 +124,7 @@ static void IRAM_ATTR RotaryIsrArgMiDesk(void *arg) {
|
|||||||
encoder->state = (state >> 2);
|
encoder->state = (state >> 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR RotaryIsrArg(void *arg);
|
static void IRAM_ATTR RotaryIsrArg(void *arg) {
|
||||||
void RotaryIsrArg(void *arg) {
|
|
||||||
tEncoder* encoder = static_cast<tEncoder*>(arg);
|
tEncoder* encoder = static_cast<tEncoder*>(arg);
|
||||||
|
|
||||||
// Theo Arends
|
// Theo Arends
|
||||||
@ -146,9 +145,9 @@ void RotaryInitMaxSteps(void) {
|
|||||||
}
|
}
|
||||||
uint8_t max_steps = Settings->param[P_ROTARY_MAX_STEP];
|
uint8_t max_steps = Settings->param[P_ROTARY_MAX_STEP];
|
||||||
if (!Rotary.model) { max_steps *= 3; }
|
if (!Rotary.model) { max_steps *= 3; }
|
||||||
Rotary.dimmer_increment = 100 / max_steps; // Dimmer 1..100 = 100
|
Rotary.dimmer_increment = 100 / min((uint8_t)100, max_steps); // Dimmer 1..100 = 100
|
||||||
Rotary.ct_increment = 350 / max_steps; // Ct 153..500 = 347
|
Rotary.ct_increment = 350 / min((uint8_t)350, max_steps); // Ct 153..500 = 347
|
||||||
Rotary.color_increment = 360 / max_steps; // Hue 0..359 = 360
|
Rotary.color_increment = 360 / min((uint8_t)360, max_steps); // Hue 0..359 = 360
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotaryInit(void) {
|
void RotaryInit(void) {
|
||||||
|
@ -1358,9 +1358,10 @@ void LightColorOffset(int32_t offset) {
|
|||||||
uint16_t hue;
|
uint16_t hue;
|
||||||
uint8_t sat;
|
uint8_t sat;
|
||||||
light_state.getHSB(&hue, &sat, nullptr); // Allow user control over Saturation
|
light_state.getHSB(&hue, &sat, nullptr); // Allow user control over Saturation
|
||||||
hue += offset;
|
int16_t hue_new = hue + offset;
|
||||||
if (hue < 0) { hue += 359; }
|
if (hue_new < 0) { hue_new += 359; }
|
||||||
if (hue > 359) { hue -= 359; }
|
if (hue_new > 359) { hue_new -= 359; }
|
||||||
|
hue = hue_new;
|
||||||
if (!Light.pwm_multi_channels) {
|
if (!Light.pwm_multi_channels) {
|
||||||
light_state.setHS(hue, sat);
|
light_state.setHS(hue, sat);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user