added general pinout info at the top, changed the start pin to have an inhibitor latch
This commit is contained in:
parent
9eda20c47d
commit
22208f9cf7
@ -1,6 +1,49 @@
|
||||
#!/usr/bin/env python
|
||||
#coding=utf-8
|
||||
|
||||
############################################
|
||||
########### GENERAL INFORMATION ############
|
||||
############################################
|
||||
|
||||
|
||||
# Pinout for assembly:
|
||||
#
|
||||
# 3V3 (1) (2) 5V
|
||||
# pin_shutdown (3) (4) 5V
|
||||
# - (5) (6) GND
|
||||
# - (7) (8) -
|
||||
# GND (9) (10) -
|
||||
# - (11) (12) -
|
||||
# - (13) (14) GND
|
||||
# - (15) (16) pin_blue
|
||||
# 3V3 (17) (18) pin_green
|
||||
# - (19) (20) GND
|
||||
# - (21) (22) pin_red
|
||||
# - (23) (24) -
|
||||
# GND (25) (26) -
|
||||
# - (27) (28) -
|
||||
# - (29) (30) GND
|
||||
# pin_error (31) (32) pin_start
|
||||
# - (33) (34) GND
|
||||
# - (35) (36) -
|
||||
# - (37) (38) -
|
||||
# GND (39) (40) -
|
||||
|
||||
# default state of pins:
|
||||
#
|
||||
# 32: pull up
|
||||
# 31: pull down
|
||||
# 3: pull down
|
||||
#
|
||||
# make sure leds are on pull-up default pins
|
||||
# so when their state is undefined, the led
|
||||
# strips are switched off!
|
||||
#
|
||||
# 22: pull up
|
||||
# 18: pull up
|
||||
# 16: pull up
|
||||
|
||||
|
||||
############################################
|
||||
############# START OF IMPORTS #############
|
||||
############################################
|
||||
@ -350,6 +393,8 @@ led_init()
|
||||
game_running = False
|
||||
game_just_started = True
|
||||
|
||||
pin_start_inhibit = False
|
||||
|
||||
############################################
|
||||
########## END OF INITIALISATION ###########
|
||||
############################################
|
||||
@ -406,8 +451,13 @@ while True:
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
if GPIO.input(pin_start) == True and game_running == False: #wait for the user to press start button
|
||||
if GPIO.input(pin_start) == True and pin_start_inhibit == False and game_running == False: #wait for the user to press start button
|
||||
game_running = True
|
||||
|
||||
# set an inhibitor bit to stop the contact from possibly vibrating and
|
||||
# causing a stop of the game immediately after start
|
||||
pin_start_inhibit = True
|
||||
pin_start_inhibit_timer_start = pygame.time.get_ticks()
|
||||
errors = 0
|
||||
error_added = False
|
||||
|
||||
@ -420,6 +470,13 @@ while True:
|
||||
if game_running == True: # game running
|
||||
print("Game running normally")
|
||||
|
||||
# if the start pin is inhibited and at least 3 seconds have passed,
|
||||
# stop blocking the pin
|
||||
if pin_start_inhibit == True:
|
||||
if (pygame.time.get_ticks()-start_ticks)/1000 > 3:
|
||||
pin_start_inhibit = False
|
||||
|
||||
|
||||
if GPIO.input(pin_error) == True:
|
||||
if error_added == False:
|
||||
errors += 1
|
||||
@ -446,7 +503,8 @@ while True:
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
if GPIO.input(pin_start) != True:
|
||||
# if the start input is gone and the start pin isnt inhibited
|
||||
if GPIO.input(pin_start) != True and pin_start_inhibit == False:
|
||||
|
||||
change_led_colour(100,10,10)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user