Hardware Reference
In-Depth Information
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
switchState = pfio.read_input() & 1
if switchState !=
lastSwitch and lastSwitch == 0:
updateSeq(step)
step += 1
if step >31 :
step = 0
lastSwitch = switchState
def updateSeq(n) :
pygame.draw.rect(screen,cBackground,
(10, 202,768 ,10), 0) # blank out track
pygame.draw.rect(screen,cStepBlock,
(14 + n * 24, 202,10 ,10), 0) # draw new position
pygame.display.update()
pfio.write_output(seq[n])
continued
Search WWH ::




Custom Search