コード例 #1
0
def draw(mode, goingToSleep=False):
    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 = ''
        l = ugfx.get_string_width(info1,"Roboto_Regular12")
        ugfx.string(296-l, 0, info1, "Roboto_Regular12",ugfx.BLACK)
        l = ugfx.get_string_width(info2,"Roboto_Regular12")
        ugfx.string(296-l, 12, info2, "Roboto_Regular12",ugfx.BLACK)
        
        easydraw.nickname()
        
        vUsb = badge.usb_volt_sense()
        vBatt = badge.battery_volt_sense()
        vBatt += vDrop
        charging = badge.battery_charge_status()

        easydraw.battery(vUsb, vBatt, charging)
        
        if vBatt>500:
            ugfx.string(52, 0, str(round(vBatt/1000, 1)) + 'v','Roboto_Regular12',ugfx.BLACK)
コード例 #2
0
def splash_main():
    # Battery status
    cstate = badge.battery_charge_status()
    vbatt = badge.battery_volt_sense()
    percent = battery_percent(3800, 4300, vbatt)

    # Init graphics and show homescreen
    ugfx.init()

    # Depending on battery status...
    if (cstate) or (percent > 9):
        draw_home(percent, cstate, "Press START!")

        # Accept input
        ugfx.input_init()
        ugfx.input_attach(ugfx.BTN_START, start_launcher)

        # Start timer
        global splashTimer
        splashTimer.init(period=5000,
                         mode=Timer.PERIODIC,
                         callback=splashTimer_callback)

    else:
        draw_batterylow(percent)
        gotosleep()
コード例 #3
0
def splashTimer_callback(tmr):
    # Battery status
    cstate = badge.battery_charge_status()
    vbatt = badge.battery_volt_sense()
    percent = battery_percent(3800, 4300, vbatt)

    # Depending on battery status...
    if (cstate) or (percent > 95):  # Charging or full...
        draw_home(percent, cstate, "Press START!")
    else:  # If on battery power...
        if (percent < 10):  # ... and battery is empty
            draw_batterylow(percent)
            ugfx.flush()
        else:  # ... and battery is okay
            draw_home(percent, cstate, "Badge is sleeping...")

        gotosleep()
コード例 #4
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)
コード例 #5
0
ファイル: splash.py プロジェクト: moonbadge/ESP32-Firmware
    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")
コード例 #6
0
    ugfx.input_attach(ugfx.JOY_UP, splash_input_other)
    ugfx.input_attach(ugfx.JOY_DOWN, splash_input_other)
    ugfx.input_attach(ugfx.JOY_LEFT, splash_input_other)
    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 badge.usb_volt_sense() > 4500 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()
splash_about_countdown_reset()

# 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
コード例 #7
0
ファイル: splash.py プロジェクト: javaBin/micropython-esp32
    ugfx.input_attach(ugfx.JOY_UP, splash_input_other)
    ugfx.input_attach(ugfx.JOY_DOWN, splash_input_other)
    ugfx.input_attach(ugfx.JOY_LEFT, splash_input_other)
    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()
splash_about_countdown_reset()

# 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