Toggle Navigation
Hatchery
Eggs
DotDotDot tag
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import rgb import buttons import defines import time rgb.clear() #global variables global rate rate = 15 global text text = 0 # colors colors = [ # white, red, purple, blue, teal, green, yellow (255, 255, 255), (255, 0, 0), (255, 0, 255), ( 0, 0, 255), ( 0, 255, 255), ( 0, 255, 0), (255, 255, 0), ] color = 0 # initial text print with default values displaytext = "[...] DotDotDot" rgb.framerate(rate) rgb.scrolltext(displaytext, colors[color]) # variables for buttons buttonup = 0 buttondown = 0 buttonright = 0 buttonleft = 0 buttona = 0 # button readout def rateup(button_is_down): if button_is_down: global buttonup buttonup = 1 pass buttons.register(defines.BTN_UP, rateup) def ratedown(button_is_down): if button_is_down: global buttondown buttondown = 1 pass buttons.register(defines.BTN_DOWN, ratedown) def colorright(button_is_down): if button_is_down: global buttonright buttonright = 1 pass buttons.register(defines.BTN_RIGHT, colorright) def colorleft(button_is_down): if button_is_down: global buttonleft buttonleft = 1 pass buttons.register(defines.BTN_LEFT, colorleft) def textb(button_is_down): if button_is_down: global buttona buttona = 1 pass buttons.register(defines.BTN_A, textb) while True: time.sleep(0.05) if buttonup: rate += 1 if rate > 30: rate = 30 rgb.framerate(rate) buttonup = 0 elif buttondown: rate -= 1 if rate < 1: rate = 1 rgb.framerate(rate) buttondown = 0 elif buttonright: color = (color + 1) % (len(colors)) time.sleep(0.5) buttonright = 0 rgb.clear() if text == 1: rgb.text(displaytext, colors[color], (1,0)) else: rgb.scrolltext(displaytext, colors[color]) elif buttonleft: color = (color - 1) % (len(colors)) buttonleft = 0 rgb.clear() if text == 1: rgb.text(displaytext, colors[color], (1,0)) else: rgb.scrolltext(displaytext, colors[color]) elif buttona: text += 1 if text == 1: displaytext = "[...]" rgb.clear() rgb.text(displaytext, colors[color], (1,0)) elif text == 2: displaytext = "DotDotDot" rgb.clear() rgb.scrolltext(displaytext, colors[color]) elif text == 3: text = 0 displaytext = "[...] DotDotDot" rgb.clear() rgb.scrolltext(displaytext, colors[color]) buttona = 0