Skip to content

Commit 4bd0f5f

Browse files
committed
Fix buttons on M5Stack
1 parent de38007 commit 4bd0f5f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

m5stack/ugame.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99

1010
K_X = 0x20
11-
K_DOWN = 0x01
12-
K_LEFT = 0x08
13-
K_RIGHT = 0x04
14-
K_UP = 0x02
11+
K_DOWN = 0x02
12+
K_LEFT = 0x04
13+
K_RIGHT = 0x08
14+
K_UP = 0x01
1515
K_O = 0x10
16+
K_SELECT = 0x40
17+
K_START = 0x80
1618

1719

1820
class Audio:
@@ -30,12 +32,12 @@ def mute(self, value=True):
3032

3133

3234
class Buttons:
33-
def __init__(self, i2c, address=0x10):
35+
def __init__(self, i2c, address=0x08):
3436
self._i2c = i2c
3537
self._address = address
3638

3739
def get_pressed(self):
38-
return self._i2c.readfrom(self._address, 1)[0]
40+
return self._i2c.readfrom(self._address, 1)[0] ^ 0xff
3941

4042

4143
spi = SPI(2, baudrate=40000000, sck=Pin(18), mosi=Pin(23))

0 commit comments

Comments
 (0)