wip gpio thread
This commit is contained in:
parent
d70c305626
commit
fa481631f2
19
NS.py
19
NS.py
|
@ -243,6 +243,10 @@ class NS(Game, Animation):
|
|||
# Initialize GPIO interface
|
||||
gpio.initialize_gpio()
|
||||
|
||||
# Launch a separate thread for reading the GPIO (and allowing its custom delays/sleeps)
|
||||
self.gpio_thread = Thread(target=self.read_gpio)
|
||||
self.gpio_thread.start()
|
||||
|
||||
# init Arduino
|
||||
elif self.serial_enabled():
|
||||
|
||||
|
@ -329,6 +333,12 @@ class NS(Game, Animation):
|
|||
def serial_enabled(self):
|
||||
return self.get_configuration("input", "serial")
|
||||
|
||||
def read_gpio(self):
|
||||
"""
|
||||
Test all connections of GPIO input pins.
|
||||
"""
|
||||
pass
|
||||
|
||||
def read_serial(self):
|
||||
while not self.serial_kill:
|
||||
name = self.get_configuration("input", "arduino-port")
|
||||
|
@ -382,15 +392,12 @@ class NS(Game, Animation):
|
|||
"""
|
||||
Check the connection status of the GPIO pins and turn on the appropriate light objects (the pads).
|
||||
"""
|
||||
# Get the active (a.k.a. pressed) state of each GPIO pin (a.k.a. pad)
|
||||
activity = gpio.activity()
|
||||
|
||||
for light_id in activity.keys():
|
||||
for light_id in self.gpio_data:
|
||||
# The pressed state is set to the activity state
|
||||
self.platform.lights[light_id].pressed = activity[light_id]
|
||||
self.platform.lights[light_id].pressed = self.gpio_data[light_id]
|
||||
|
||||
# Reset idle timer if a light is detected as pressed
|
||||
if activity[light_id]:
|
||||
if self.gpio_data[light_id]:
|
||||
self.idle_elapsed = 0
|
||||
|
||||
def reset(self, leave_wipe_running=False):
|
||||
|
|
Loading…
Reference in New Issue