Can we post .py code files here, or should they be git hosted?

htmlgames

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
Hi just wondered if ok as created my first (small) program for thumby today?

Edit: seen codei in other threads so guess ok.


below is a fun torch project.
« Last Edit: January 30, 2024, 06:09:11 PM by htmlgames »


htmlgames

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
Code: [Select]
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()
« Last Edit: February 03, 2024, 08:13:36 AM by htmlgames »


 

SMF spam blocked by CleanTalk