Hardware Reference
In-Depth Information
os.environ['SDL_VIDEO_WINDOW_POS'] = 'center'
pygame.display.set_caption(“LED sequence controller”)
screen = pygame.display.set_mode([788,250],0,32)
background = pygame.Surface((788,250))
# define the colours to use for the user interface
cBackground =(255,255,255)
cLEDon = (255,0,0)
cLEDoff = (128,128,128)
cOutline = (255,128,0)
cText = (0,0,0)
cTextBack = (220,220,220)
cStepBlock = (0,255,255)
background.fill(cBackground) # make background colour
font = pygame.font.Font(None, 28)
seq = [ 1 << (temp & 0x7) for temp in range (0,32)]
# initial sequence
timeInc = 0.3
stepInt = True # getting the step signal from inside the Pi
step = 0 # start point in sequence
nextTime = time.time()
lastSwitch = 0
def main():
setupScreen()
while True :
checkForEvent()
checkStep()
def checkStep() :
global step, nextTime, lastSwitch
if stepInt :
# if we are getting the step command from the internal timer
if time.time() > nextTime :
# is it time to do a next step
updateSeq(step)
step += 1
if step >31 :
step = 0
nextTime = time.time() + timeInc
else: # if not look at lowest switch
continued
Search WWH ::




Custom Search