From d4cacbff057a3b74a39836c789c9be97d2b87f63 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 13 Oct 2020 15:14:34 +0200 Subject: [PATCH] Fix rotary interrupt use of global vars - Fix rotary interrupt use of global vars (#9399) - Decrease direction change timout from 50 to 25 mSecs --- tasmota/support_rotary.ino | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tasmota/support_rotary.ino b/tasmota/support_rotary.ino index 76c748203..fda1f71e8 100644 --- a/tasmota/support_rotary.ino +++ b/tasmota/support_rotary.ino @@ -42,7 +42,7 @@ const uint8_t rotary_dimmer_increment = 100 / ROTARY_MAX_STEPS; // Dimmer 1..10 const uint8_t rotary_ct_increment = 350 / ROTARY_MAX_STEPS; // Ct 153..500 = 347 const uint8_t rotary_color_increment = 360 / ROTARY_MAX_STEPS; // Hue 0..359 = 360 -const uint8_t ROTARY_TIMEOUT = 10; // 10 * RotaryHandler() call which is usually 10 * 0.05 seconds +const uint8_t ROTARY_TIMEOUT = 5; // 5 * RotaryHandler() call which is usually 5 * 0.05 seconds const uint8_t ROTARY_DEBOUNCE = 10; // Debounce time in milliseconds struct ROTARY { @@ -50,15 +50,15 @@ struct ROTARY { } Rotary; struct tEncoder { - uint32_t debounce = 0; + volatile uint32_t debounce = 0; int8_t abs_position[2] = { 0 }; - int8_t direction = 0; // Control consistent direction - int8_t pin = -1; - uint8_t position = 128; + volatile int8_t direction = 0; // Control consistent direction + volatile int8_t pin = -1; + volatile uint8_t position = 128; uint8_t last_position = 128; uint8_t timeout = 0; // Disallow direction change within 0.5 second bool changed = false; - bool busy = false; + volatile bool busy = false; }; tEncoder Encoder[MAX_ROTARIES];