Skip to content

Instantly share code, notes, and snippets.

@Darenn
Created June 22, 2023 08:28
Show Gist options
  • Select an option

  • Save Darenn/8e4a480af435c8ad7a3329cd26db1d88 to your computer and use it in GitHub Desktop.

Select an option

Save Darenn/8e4a480af435c8ad7a3329cd26db1d88 to your computer and use it in GitHub Desktop.
Happy birthday program for the tiny circuit thumby displaying a birthday cake and playing music
import thumby
import time
# BITMAP: width: 42, height: 42
bitmap0 = bytearray([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,234,228,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
128,64,32,32,16,16,16,8,8,104,104,8,8,4,4,4,4,4,0,255,0,0,255,0,4,4,4,4,4,8,8,8,8,136,136,16,16,16,32,32,64,128,
255,124,248,248,240,240,240,224,224,224,224,224,224,192,204,204,192,192,192,193,193,193,193,192,192,192,204,204,192,224,224,224,224,225,225,240,240,240,248,248,124,255,
255,239,222,222,189,189,123,123,123,123,123,123,123,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,123,123,123,123,123,123,189,189,189,222,222,239,255,
1,3,3,7,7,7,15,15,15,15,15,15,31,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,31,15,15,15,15,15,15,7,7,7,3,3,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
SOL6=1568
LA=880
DO=1046
SI=987
RE=1174
SOL=784
MI=1318
FA=1397
spr_cake = thumby.Sprite(42, 42, bitmap0, 15, 0)
thumby.display.setFPS(30)
thumby.display.fill(0) # Fill canvas to black
thumby.display.drawSprite(spr_cake)
while(1):
thumby.display.update()
thumby.audio.playBlocking(SOL, 250)
thumby.audio.playBlocking(SOL, 250)
thumby.audio.playBlocking(LA, 500)
thumby.audio.playBlocking(SOL, 500)
thumby.audio.playBlocking(DO, 500)
thumby.audio.playBlocking(SI, 1000)
thumby.audio.playBlocking(SOL, 250)
thumby.audio.playBlocking(SOL, 250)
thumby.audio.playBlocking(LA, 500)
thumby.audio.playBlocking(SOL, 500)
thumby.audio.playBlocking(RE, 500)
thumby.audio.playBlocking(DO, 1000)
thumby.audio.playBlocking(SOL, 250)
thumby.audio.playBlocking(SOL, 250)
thumby.audio.playBlocking(SOL6, 500)
thumby.audio.playBlocking(MI, 500)
thumby.audio.playBlocking(DO, 500)
thumby.audio.playBlocking(SI, 500)
thumby.audio.playBlocking(LA, 500)
thumby.audio.playBlocking(FA, 250)
thumby.audio.playBlocking(FA, 250)
thumby.audio.playBlocking(MI, 500)
thumby.audio.playBlocking(DO, 500)
thumby.audio.playBlocking(RE, 500)
thumby.audio.playBlocking(DO, 500)
thumby.audio.playBlocking(20, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment