Skip to content

Commit 1bd33dd

Browse files
committed
esp32/Ringo: Fixed incorrect input mapping
1 parent 81523a4 commit 1bd33dd

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

ports/esp32/libraries/Ringo/Buttons.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@ def __init__(self, expander: PCA95XX, ads: ADS1015):
4040
def expander_scan(self):
4141
state = self.expander.state_read()
4242

43-
for i in range(len(self.expander_btns)):
44-
pin = Buttons.Pins[self.expander_btns[i]]
43+
for exp_btn in self.expander_btns:
44+
pin = Buttons.Pins[exp_btn]
4545

46-
if ((state >> pin) & 1) == 1:
47-
self.released(pin)
46+
released: bool = ((state >> pin) & 1) == 1
47+
if pin == 14:
48+
released = not released
49+
50+
if released:
51+
self.released(exp_btn)
4852
else:
49-
self.pressed(pin)
53+
self.pressed(exp_btn)
5054

5155
def ads_scan(self):
5256
for btn in self.ads_btns:
53-
# print("Buttons reading ADS channel", Buttons.Pins[btn])
5457
self.ads.read(Buttons.Pins[btn])
5558
if self.ads.read(Buttons.Pins[btn]) < 5:
5659
self.pressed(btn)

ports/esp32/libraries/Ringo/Pins.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ class Buttons:
4040
Num_0: int = const(9)
4141
Num_Ast: int = const(10)
4242
Num_Hash: int = const(11)
43+
4344
Home: int = const(12)
44-
Power: int = const(13)
45+
Power: int = const(13) # Note: only input that behaves 0 - released, 1 - pressed, rest are pulled-up
4546
Alt_L: int = const(14)
4647
Alt_R: int = const(15)
4748

@@ -63,8 +64,9 @@ class Buttons:
6364
const(10),
6465
const(9),
6566
const(11),
66-
const(14),
67+
6768
const(13),
69+
const(14),
6870
const(15),
6971
const(12),
7072

0 commit comments

Comments
 (0)