Toggle Navigation
Hatchery
Eggs
RealVibrator
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import badge, appglue, ugfx from random import randint def app_main(): hint1= "Press <START> to go to home screen!" hint2= "Press <A> to start vibration!" hint_font = "Roboto_Regular18" hint1_x = int((296-ugfx.get_string_width(hint1, hint_font))/2) hint1_y = 128-22-5 hint2_x = int((296-ugfx.get_string_width(hint2, hint_font))/2) hint2_y = 128 - 22 - 5 - 22 - 5 badge.init() ugfx.init() badge.eink_init() ugfx.input_init() badge.vibrator_init() ugfx.input_attach(ugfx.BTN_START, lambda pressed: go_home(pressed)) ugfx.input_attach(ugfx.BTN_A, lambda pressed: toggle_vibrator(pressed)) clear() center_text(5, "RealVibrator", "PermanentMarker36", ugfx.BLACK) ugfx.string(hint1_x, hint1_y, hint1, hint_font, ugfx.BLACK) ugfx.string(hint2_x, hint2_y, hint2, hint_font, ugfx.BLACK) ugfx.flush() def go_home(pressed): if pressed: appglue.home() def clear(): for i in range(2): ugfx.clear(ugfx.BLACK) ugfx.flush() ugfx.clear(ugfx.WHITE) ugfx.flush() def center_text(y, string, font, color): x=int((296-ugfx.get_string_width(string, font))/2) ugfx.string(x, y, string, font, color) def toggle_vibrator(pressed): if pressed: vibrator_integer = randint(0, 666) badge.vibrator_activate(vibrator_integer) app_main()