import appglue, ugfx, badge

ugfx.init()

ugfx.clear(ugfx.WHITE)

badge.nvs_set_str('boot','splash','adamant_badge')

badge.eink_png(10,10,'/lib/adamant_badge/logo.png') 

ugfx.flush()

def render(text, pushed):
  badge.eink_png(10,10,'/lib/adamant_badge/logo.png')
    
def buzz(speed, pushed):
  if(pushed):
    badge.vibrator_activate(speed)

ugfx.input_init()
ugfx.input_attach(ugfx.JOY_UP, lambda pressed: buzz(0x22, pressed))
ugfx.input_attach(ugfx.JOY_DOWN, lambda pressed: buzz(0x55, pressed))
ugfx.input_attach(ugfx.JOY_LEFT, lambda pressed: buzz(0x99, pressed))
ugfx.input_attach(ugfx.JOY_RIGHT, lambda pressed: buzz(0xFF, pressed))
ugfx.input_attach(ugfx.BTN_A, lambda pressed: render('A', pressed))
ugfx.input_attach(ugfx.BTN_B, lambda pressed: render('B', pressed))
ugfx.input_attach(ugfx.BTN_START, lambda x: appglue.home())
ugfx.input_attach(ugfx.BTN_SELECT, lambda x: appglue.home())