From 88742e03995145e572e0feed57c3c22a7ce196fc Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 13 Dec 2024 22:16:11 +0100 Subject: [PATCH] [rotary_encoder] Fix volatile increment/decrement deprecation warnings (#7958) --- esphome/components/rotary_encoder/rotary_encoder.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/esphome/components/rotary_encoder/rotary_encoder.cpp b/esphome/components/rotary_encoder/rotary_encoder.cpp index e9a0eac3f5..f8e5357a6e 100644 --- a/esphome/components/rotary_encoder/rotary_encoder.cpp +++ b/esphome/components/rotary_encoder/rotary_encoder.cpp @@ -93,13 +93,17 @@ void IRAM_ATTR HOT RotaryEncoderSensorStore::gpio_intr(RotaryEncoderSensorStore int8_t rotation_dir = 0; uint16_t new_state = STATE_LOOKUP_TABLE[input_state]; if ((new_state & arg->resolution & STATE_HAS_INCREMENTED) != 0) { - if (arg->counter < arg->max_value) - arg->counter++; + if (arg->counter < arg->max_value) { + auto x = arg->counter + 1; + arg->counter = x; + } rotation_dir = 1; } if ((new_state & arg->resolution & STATE_HAS_DECREMENTED) != 0) { - if (arg->counter > arg->min_value) - arg->counter--; + if (arg->counter > arg->min_value) { + auto x = arg->counter - 1; + arg->counter = x; + } rotation_dir = -1; }