Exemplo n.º 1
0
def main_menu():
    while True:
        clear()

        print()

        menu_items = [{
            "title": "Install Apps",
            "function": show_categories
        }, {
            "title": "Update",
            "function": show_update
        }, {
            "title": "Manage Apps",
            "function": show_remove
        }]

        option = prompt_option(menu_items,
                               none_text="Exit",
                               text="What do you want to do?",
                               title=title)

        if option:
            option["function"]()
        else:
            app.restart_to_default()
Exemplo n.º 2
0
def main():

    init()

    start()

    write_some_text()

    while True:
        if buttons.is_triggered(Buttons.BTN_A):
            a_was_pushed():

    app.restart_to_default()
Exemplo n.º 3
0
        "Temperature (tmp) : {:.2f} C".format(Sensors.get_tmp_temperature()))
    ugfx.Label(
        5, 20, 240, 15,
        "Temperature (hdc) : {:.2f} C".format(Sensors.get_hdc_temperature()))
    ugfx.Label(
        5, 35, 240, 15,
        "Humidity    (hdc) : {:.2f} %".format(Sensors.get_hdc_humidity()))
    ugfx.Label(5, 50, 240, 15,
               "Light       (opt) : {:.2f} Lux".format(Sensors.get_lux()))
    ugfx.Label(5, 65, 240, 15,
               "Mag Field:  (drv) : {:.2f}    ".format(mag.convert()))
    ugfx.Label(5, 80, 240, 15,
               "Sensor samplerate : {} ms".format(Sensors.sample_rate()))

    charging = Sensors.get_charge_status()
    if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:
        ugfx.Label(5, 110, 240, 15, "Battery is        : charging")
    elif charging == Sensors.BAT_DONE_CHARGING:
        ugfx.Label(5, 110, 240, 15, "Battery is        : full")
    elif charging == Sensors.BAT_NOT_CHARGING:
        ugfx.Label(5, 110, 240, 15, "Battery is        : discharging")

    ugfx.Label(5, 125, 240, 15,
               "Battery is        : {:.2f} %".format(sim800.batterycharge()))

    sleep(2)

ugfx.clear()

app.restart_to_default()
Exemplo n.º 4
0
given_name = homescreen.name("Set your name in the settings app")
if len(given_name) <= max_name:
    ugfx.set_default_font(ugfx.FONT_NAME)
else:
    ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
# Draw name
ugfx.Label(0, ugfx.height() - name_height, ugfx.width(), name_height, given_name, justification=ugfx.Label.CENTER)


# Draw for the user to see
ugfx.orientation(270)
ugfx.set_default_font(ugfx.FONT_SMALL)

# WiFi/Battery update loop
while True:
    ugfx.area(0, ugfx.height() - info_height, ugfx.width(), info_height, ugfx.WHITE)

    wifi_strength_value = homescreen.wifi_strength()
    if wifi_strength_value:
        wifi_message = 'WiFi: %s%%' % int(wifi_strength_value)
        wifi_text = ugfx.text(center[0], ugfx.height() - info_height, wifi_message, ugfx.BLACK)

    battery_value = homescreen.battery()
    if battery_value:
        battery_message = 'Battery: %s%%' % int(battery_value)
        battery_text = ugfx.text(0, ugfx.height() - info_height, battery_message, ugfx.BLACK)

    homescreen.sleep_or_exit(1.5)

restart_to_default()
Exemplo n.º 5
0
def badgeQuit():
    restart_to_default()
Exemplo n.º 6
0
def badgeQuit():
    restart_to_default()  # call on exit of main.py'''
Exemplo n.º 7
0
"""Weather

Displays the weather where you are.
"""

___name___ = "Weather"
___license___ = "MIT"
___dependencies___ = ["ugfx_helper"]
___categories___ = ["Homescreens"]
___bootstrapped___ = True  # Whether or not apps get downloaded on first install. Defaults to "False", mostly likely you won't have to use this at all.

import ugfx_helper, ugfx, app
from tilda import Buttons
# import weather

ugfx_helper.init()
ugfx.clear(ugfx.BLACK)

ugfx.text(5, 5, "Hi Alan!", ugfx.WHITE)

Buttons.enable_interrupt(Buttons.BTN_B,
                         lambda button_id: app.restart_to_default(),
                         on_press=True,
                         on_release=False)

while True:
    sleep.wfi()

ugfx.clear()
app.restart_to_default()
Exemplo n.º 8
0
def quit_game():
    app.restart_to_default()
Exemplo n.º 9
0

def get_black():
    x = random.randint(1, 320)
    ugfx.clear(ugfx.html_color(0x000000))
    text = str(d["blackCards"][x]["text"])
    ugfx.Label(0, 0, 240, 400, text, style=b)


def get_white():
    y = random.randint(1, 1271)
    ugfx.clear(ugfx.html_color(0xffffff))
    text = str(d["whiteCards"][y])
    ugfx.Label(0, 0, 240, 400, text, style=w)


Buttons.enable_interrupt(Buttons.BTN_A,
                         lambda button_id: get_black(),
                         on_press=True,
                         on_release=False)

Buttons.enable_interrupt(Buttons.BTN_B,
                         lambda button_id: get_white(),
                         on_press=True,
                         on_release=False)

Buttons.enable_interrupt(Buttons.BTN_Menu,
                         lambda button_id: restart_to_default(),
                         on_press=True,
                         on_release=False)
Exemplo n.º 10
0
        ugfx.orientation(90)
        orientation = 90
        draw_screen()

ugfx.init()
ugfx.clear(ugfx.BLACK)
ugfx.set_default_font(ugfx.FONT_FIXED)

s=ugfx.Style()
s.set_enabled([ugfx.WHITE, ugfx.BLACK, ugfx.BLACK, ugfx.GREY])
s.set_background(ugfx.BLACK)
ugfx.set_default_style(s)

Buttons.enable_interrupt(Buttons.BTN_A, lambda button_id:get_beer(), on_press=True, on_release=False)
Buttons.enable_interrupt(Buttons.BTN_B, lambda button_id:toggle_orientation(), on_press=True, on_release=False)
Buttons.enable_interrupt(Buttons.BTN_Menu, lambda button_id:app.restart_to_default(), on_press=True, on_release=False)

ugfx.text(5, 10, "Instructions:", ugfx.WHITE)
ugfx.text(5, 30, "Press the A button to refresh", ugfx.WHITE)
ugfx.text(5, 45, "Press the B button to rotate", ugfx.WHITE)
ugfx.text(5, 60, "Press the Menu button to exit", ugfx.WHITE)
ugfx.text(5, 90, "!", ugfx.RED)
ugfx.text(15, 90, "means the stock is low", ugfx.WHITE)
ugfx.text(5, 120, "Loading data from the bar...", ugfx.WHITE)


get_beer()

while True:
    sleep.wfi()
Exemplo n.º 11
0
def exit():
    print('trains/main: Exit')
    ugfx.clear()
    app.restart_to_default()