Skip to content

Commit

Permalink
fix initial switches in rpi
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdoa2 committed Apr 27, 2020
1 parent b41f093 commit ddbf3b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mpf/platforms/rpi/rpi.py
Expand Up @@ -209,7 +209,7 @@ async def get_hw_switch_states(self):
hw_states = dict()
curr_bit = 1
for index in range(32):
hw_states[str(index)] = (curr_bit & self._switches) == 0
hw_states[str(index)] = bool(curr_bit & self._switches)
curr_bit <<= 1
return hw_states

Expand Down
10 changes: 8 additions & 2 deletions mpf/tests/test_Rpi.py
Expand Up @@ -39,8 +39,8 @@ async def connect(self, address):
pass

async def read_bank_1(self):
## all switches read 1 which means they are open because of the pull-up
return 0xFF
## only switch 1 is active
return 0x02

async def set_pull_up_down(self, gpio, pud):
self.pull_ups[gpio] = pud
Expand Down Expand Up @@ -114,6 +114,12 @@ def testPlatform(self):
self.pi.pull_ups)

# test switches
self.assertSwitchState("s_test", True)
self.assertSwitchState("s_test2", False)

self.pi.callbacks[1](gpio=1, level=0, tick=123)
self.machine_run()

self.assertSwitchState("s_test", False)
self.assertSwitchState("s_test2", False)

Expand Down

0 comments on commit ddbf3b9

Please sign in to comment.