Skip to content

Commit fc053ec

Browse files
authored
Merge pull request #16 from caternuson/slider
Update slider
2 parents 6233047 + 6f6dc7d commit fc053ec

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

adafruit_funhouse/peripherals.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,11 @@ def slider(self):
179179
Return the slider position value in the range of 0.0-1.0 or None if not touched
180180
"""
181181
val = 0
182-
cap_map = b"\x01\x03\x02\x06\x04\x0c\x08\x18\x10"
182+
cap_map = (0x01, 0x03, 0x02, 0x06, 0x04, 0x0C, 0x08, 0x18, 0x10)
183183
for cap in range(5):
184184
if self._ctp[cap + 3].value:
185185
val += 1 << (cap)
186-
for i, pos in enumerate(tuple(cap_map)):
187-
if val == pos:
188-
print(i, len(cap_map) - 1)
189-
return round(i / (len(cap_map) - 1), 1)
190-
return None
186+
return cap_map.index(val) / 8 if val in cap_map else None
191187

192188
@property
193189
def light(self):

0 commit comments

Comments
 (0)