Skip to content

Commit e5b6dde

Browse files
authored
Merge pull request #76 from Tiramisioux/codex/investigate-adafruit-quad-encoder-behavior-wn0rmg
Default `detents_per_pulse` to 1 for GPIO and quad I2C encoders
2 parents 7bd14b8 + 9fbcc37 commit e5b6dde

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/module/gpio_input.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ def extract_action_method(self, action_config):
114114
else:
115115
return None
116116

117+
@staticmethod
118+
def _normalize_detents_per_pulse(value):
119+
try:
120+
return max(1, int(value or 1))
121+
except (TypeError, ValueError):
122+
return 1
123+
117124
def _describe_actions(self, config):
118125
"""
119126
Generate a string description of the actions assigned to a component.

src/module/i2c/quad_rotary_controller.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ def _update_setting(self, name: str, change: int, detents_per_pulse: int):
202202
except Exception as exc:
203203
logging.error("Failed to update %s: %s", name, exc)
204204

205+
# ------------------------------------------------------------------
206+
@staticmethod
207+
def _normalize_detents_per_pulse(value):
208+
try:
209+
return max(1, int(value or 1))
210+
except (TypeError, ValueError):
211+
return 1
212+
205213
# ------------------------------------------------------------------
206214
def run(self):
207215
while True:

0 commit comments

Comments
 (0)