import thumby
thumby.display.setFPS(2) # frames per second
brightness = 127
colour = 0 # black
torch = 1 # white 'ON'
blink = 0
while(not(thumby.buttonA.pressed() and thumby.buttonB.pressed())):
if thumby.buttonA.justPressed():
torch = 1
if thumby.buttonB.justPressed():
torch = 0
if thumby.buttonL.pressed():
blink = 0
torch = 1
if thumby.buttonR.pressed():
blink = 1
torch = torch
if blink == 1:
torch = not(torch)
thumby.display.fill(torch) # fill screen with pixels
if torch > 0:
if thumby.buttonU.pressed():
#colour = 1
if brightness <= 120:
brightness += 7
thumby.display.drawText("increasing", 6, 4, colour)
thumby.display.drawText("%d" % brightness, 6, 20, colour)
thumby.audio.playBlocking(brightness * 7,42)
if thumby.buttonD.pressed():
#colour = 0
if brightness > 8:
brightness -= 7
thumby.display.drawText("decreasing", 6, 4, colour)
thumby.display.drawText("%d" % brightness, 6, 20, colour)
thumby.audio.playBlocking(brightness * 7,42)
thumby.display.brightness(brightness)
thumby.display.update()