Exemplo n.º 1
0
            menu.scroll_down()

def GPIO_setup():
    GPIO.setmode(GPIO.BCM)
    for button in [A, UP, DOWN, LEFT, RIGHT, B, START, SELECT]:
        GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.add_event_detect(button, GPIO.FALLING, callback=button_handler, bouncetime=150)
        
def GPIO_cleanup():
    for button in [A, UP, DOWN, LEFT, RIGHT, B, START, SELECT]:
        GPIO.remove_event_detect(button)
    GPIO.cleanup()
    
    
# set up led matrix
led_matrix.init_matrices([(0,0),(8,0),(8,8),(0,8)], math_coords=False)
GPIO_setup()    
    
# set up menu
menu_items = [
    ["ASPIRIN", "aspirin.py"],
    ["CLOCK", "clock.py"],
    ["DICE", "dice.py"],
    ["PROTECTOR", "protector.py"],
    ["BREAKOUT", "breakout.py"],
    ["TETRIS", "tetris.py"],
    ["STACK-EM", "stackem.py"],
    ["SPACE INVADERS", "space_invaders.py"],
    ["FLAPPYBIRD", "flappybird.py"],
    ["GAME OF LIFE", "game_of_life.py"],
    ["SNAKE", "snake.py"]
Exemplo n.º 2
0
#

#Imports
from rstem import led_matrix
from rstem import accel
import RPi.GPIO as GPIO
import sys
import time

# notify of progress
print("P50")
sys.stdout.flush()

#Initialize hardware
#led_matrix.init_grid(2,2)
led_matrix.init_matrices([(0,8),(8,8),(8,0),(0,0)])

print("P60")
sys.stdout.flush()

accel.init(1)

print("P70")
sys.stdout.flush()

#Initialize game data
bricks = []
ball = None
score = 0
start_time = time.time()
ball_tick = 0
Exemplo n.º 3
0
    for button in [A, UP, DOWN, LEFT, RIGHT, B, START, SELECT]:
        GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.add_event_detect(button,
                              GPIO.FALLING,
                              callback=button_handler,
                              bouncetime=150)


def GPIO_cleanup():
    for button in [A, UP, DOWN, LEFT, RIGHT, B, START, SELECT]:
        GPIO.remove_event_detect(button)
    GPIO.cleanup()


# set up led matrix
led_matrix.init_matrices([(0, 0), (8, 0), (8, 8), (0, 8)], math_coords=False)
GPIO_setup()

# set up menu
menu_items = [["ASPIRIN", "aspirin.py"], ["CLOCK", "clock.py"],
              ["DICE", "dice.py"], ["PROTECTOR", "protector.py"],
              ["BREAKOUT", "breakout.py"], ["TETRIS", "tetris.py"],
              ["STACK-EM", "stackem.py"],
              ["SPACE INVADERS", "space_invaders.py"],
              ["FLAPPYBIRD", "flappybird.py"],
              ["GAME OF LIFE", "game_of_life.py"], ["SNAKE", "snake.py"]]
menu_items.sort()  # put in alphabetical order by titles
menu = Menu(menu_items, show_loading=True)

while True:
    if curr_state == IN_MENU: