Exemplo n.º 1
0
def draw(mode, goingToSleep=False):
    ugfx.orientation(0)
    if mode:
        # We flush the buffer and wait
        ugfx.flush(ugfx.LUT_FULL)
        badge.eink_busy_wait()
    else:
        # We prepare the screen refresh
        ugfx.clear(ugfx.WHITE)
        if goingToSleep:
            info1 = 'Sleeping...'
            info2 = 'Press any key to wake up'
        else:
            info1 = 'Press start to open the launcher'
            if otac.available(False):
                info2 = 'Press select to start OTA update'
            else:
                info2 = ''

        def disp_string_right(y, s):
            l = ugfx.get_string_width(s, "Roboto_Regular12")
            ugfx.string(296 - l, y, s, "Roboto_Regular12", ugfx.BLACK)

        disp_string_right(0, info1)
        disp_string_right(12, info2)

        if badge.safe_mode():
            disp_string_right(92, "Safe Mode - services disabled")
            disp_string_right(104,
                              "Sleep disabled - will drain battery quickly")
            disp_string_right(116, "Press Reset button to exit")

        nickname()

        on_usb = pm.usb_attached()
        vBatt = badge.battery_volt_sense()
        vBatt += vDrop
        charging = badge.battery_charge_status()

        battery(on_usb, vBatt, charging)

        if vBatt > 500:
            ugfx.string(52, 0,
                        str(round(vBatt / 1000, 1)) + 'v', 'Roboto_Regular12',
                        ugfx.BLACK)
Exemplo n.º 2
0
    ugfx.input_attach(ugfx.JOY_RIGHT, splash_input_other)


# Power management


def onSleep(idleTime):
    draw(False, True)
    services.force_draw(True)
    draw(True, True)


### PROGRAM

# Calibrate battery voltage drop
if badge.battery_charge_status() == False and pm.usb_attached(
) and badge.battery_volt_sense() > 2500:
    badge.nvs_set_u16('splash', 'bat.volt.drop',
                      5200 - badge.battery_volt_sense())  # mV
    print('Set vDrop to: ' + str(4200 - badge.battery_volt_sense()))
vDrop = badge.nvs_get_u16('splash', 'bat.volt.drop', 1000) - 1000  # mV

splash_input_init()

# post ota script
import post_ota

setupState = badge.nvs_get_u8('badge', 'setup.state', 0)
if setupState == 0:  #First boot
    print("[SPLASH] First boot (start setup)...")
    appglue.start_app("setup")
#elif setupState == 1: # Second boot: Show sponsors