option to suppress GPIO init
This commit is contained in:
parent
6cd9e8cfd7
commit
232e4836e9
|
@ -34,7 +34,7 @@ class ElectricSieve(Game):
|
|||
PIN_LED_UP = 22
|
||||
PIN_LED_DOWN = 23
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, suppress_gpio_init=False):
|
||||
"""
|
||||
Initialize super class, GPIO input, background, and activate the title screen.
|
||||
"""
|
||||
|
@ -76,7 +76,7 @@ class ElectricSieve(Game):
|
|||
self.rotated = True
|
||||
|
||||
# Initialize GPIO input and callbacks if GPIO library is loaded
|
||||
if "RPi.GPIO" in sys.modules:
|
||||
if "RPi.GPIO" in sys.modules and not suppress_gpio_init:
|
||||
self.initialize_gpio()
|
||||
|
||||
self.velocity = Vector(0, 0)
|
||||
|
@ -103,12 +103,6 @@ class ElectricSieve(Game):
|
|||
# Start the title screen
|
||||
self.title.activate()
|
||||
|
||||
def gpio_enabled(self):
|
||||
"""
|
||||
@return True if GPIO mode was requested at launch, False otherwise
|
||||
"""
|
||||
return "--gpio" in sys.argv
|
||||
|
||||
def initialize_gpio(self):
|
||||
"""
|
||||
Set pin numbering mode to GPIO, initialize all buttons to input pullup.
|
||||
|
@ -130,6 +124,7 @@ class ElectricSieve(Game):
|
|||
|
||||
@param pin Raspberry Pi pin number as read by the RPi.GPIO library
|
||||
"""
|
||||
# Print the input state of each pin if debug is requested on the command line
|
||||
if "--debug" in sys.argv:
|
||||
pin_name = "left" if pin == ElectricSieve.PIN_BUTTON_LEFT else "right"
|
||||
left_pin_state = GPIO.input(ElectricSieve.PIN_BUTTON_LEFT)
|
||||
|
|
Loading…
Reference in New Issue