Toggle Navigation
Hatchery
Eggs
Pimp name
__init__.py
Login
Register
__init__.py
Content
import easydraw, system, badge, ugfx, sys import random def action_exit(pushed): if (pushed): # to turn off all the leds at ones badge.led(6,0,0,0) # go back to the home screen system.home() def show_names(x=10, y=10, font='PermanentMarker36', color=ugfx.BLACK): badge.init() nick = badge.nvs_get_str('owner', 'name', 'BAYA') width = ugfx.get_string_width(nick, font) ugfx.string(int((128 - width)/2), y, nick, font, color) ugfx.flush() # do the magick endlesly while True: # loop over the leds for led_id in [0,1,2,3,4,5]: # default, turn off all the leds r, g, b = [0,0,0] # select a random color rgb = random.randint(1, 3) # turn ON the selected color if rgb == 1: r = 1 elif rgb == 2: g = 1 elif rgb == 3: b = 1 # turn the led to the selected state badge.led(led_id,r,g,b) def main(): ugfx.input_init() ugfx.input_attach(ugfx.BTN_B, action_exit) ugfx.input_attach(ugfx.BTN_START, action_exit) show_names() sys.stdin.read(1) #Wait for any key action_exit(True) main()