Hardware Reference
In-Depth Information
Listing 11-3 continued
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])
def setupScreen() : # initialise the screen
screen.blit(background,[0,0]) # set background colour
drawControl(10,58,”Clear”)
drawControl(86,62,”Invert”)
drawControl(168,68,”Faster”)
drawControl(250,74,”Slower”)
drawControl(350,132,”Auto Step”)
for x in range(0,32) :
drawCol(x,seq[x])
pygame.display.update()
def drawControl(xPos,xLen,name) :
pygame.draw.rect(screen,cTextBack, ;
(xPos, 216, xLen,32), 0)
pygame.draw.rect(screen,cOutline, ;
(xPos, 216, xLen,32), 2)
text = font.render(name, True, cText, cTextBack )
textRect = text.get_rect()
textRect.topleft = xPos+4, 220
screen.blit(text, textRect)
def drawCol(x,value):
boxNum = 0
x = 10 + x*24
Search WWH ::




Custom Search