fix gpio module import
This commit is contained in:
parent
f0b77551b6
commit
2e84e3d916
|
@ -30,10 +30,6 @@ if "--fb" in sys.argv:
|
|||
if "--ignore-hangup" in sys.argv:
|
||||
ignore_sighup()
|
||||
|
||||
# Import GPIO library if requested
|
||||
if "--gpio" in sys.argv:
|
||||
import RPi.GPIO as GPIO
|
||||
|
||||
from electric_sieve.ElectricSieve import ElectricSieve
|
||||
|
||||
ElectricSieve().run()
|
||||
|
|
|
@ -16,6 +16,12 @@ from lib.pgfw.pgfw.GameChild import GameChild
|
|||
from lib.pgfw.pgfw.Sprite import Sprite
|
||||
from lib.pgfw.pgfw.extension import render_box
|
||||
|
||||
# Import GPIO library if available
|
||||
try:
|
||||
import RPi.GPIO as GPIO
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
class ElectricSieve(Game):
|
||||
|
||||
# The GPIO pins corresponding to the buttons and LED indicators
|
||||
|
@ -25,11 +31,21 @@ class ElectricSieve(Game):
|
|||
PIN_LED_DOWN = 23
|
||||
|
||||
def __init__(self):
|
||||
if self.gpio_enabled():
|
||||
self.initialize_gpio()
|
||||
"""
|
||||
Initialize super class, GPIO input, background, and activate the title screen.
|
||||
"""
|
||||
# Initialize super
|
||||
Game.__init__(self)
|
||||
|
||||
# Initialize GPIO input and callbacks if GPIO library is loaded
|
||||
if "RPi.GPIO" in sys.modules:
|
||||
self.initialize_gpio()
|
||||
|
||||
# Create a purple background
|
||||
self.background = Surface(self.display.screen.get_size())
|
||||
self.background.fill((255, 80, 190))
|
||||
|
||||
# Start the title screen
|
||||
self.title.activate()
|
||||
|
||||
def gpio_enabled(self):
|
||||
|
|
|
@ -133,3 +133,4 @@
|
|||
1670817307.1141152 53 ---
|
||||
1670819531.720299 203 FLA
|
||||
1670819619.775536 96 ---
|
||||
1670989457.377776 0 ---
|
||||
|
|
Loading…
Reference in New Issue