Пример #1
0
 def enter(self):
     self.next_state = S_CONTINUE
     self.station_code = database.get('trains.station_code', 'LBG')
     self.last_update = 0
     Buttons.enable_interrupt(Buttons.BTN_A,
                              lambda t: self.set_next_state(S_TO_SETTINGS),
                              on_press=True,
                              on_release=False)
     Buttons.enable_interrupt(Buttons.BTN_Menu,
                              lambda t: self.set_next_state(S_EXIT),
                              on_press=True,
                              on_release=False)
Пример #2
0
    GreenLEDNum = random.randint(0, 1)

    if RedLEDNum == 0:
        LED(LED.RED).on()
    else:
        LED(LED.RED).off()

    if GreenLEDNum == 0:
        LED(LED.GREEN).on()
    else:
        LED(LED.GREEN).off()

    colourNum1 = colourList[random.randint(0, 510)]
    colourNum2 = colourList[random.randint(0, 510)]
    n.display([colourNum1, colourNum2])


def badgeQuit():
    restart_to_default()  # call on exit of main.py'''


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

Buttons.enable_interrupt(Buttons.BTN_A,
                         lambda button_id: badgeQuit(),
                         on_press=True,
                         on_release=False)
Пример #3
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()
Пример #4
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)
Пример #5
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)
Пример #6
0
from tilda import Buttons

n = Neopix()

mapping = {0: 0x000001, 1: 0x000100, 2: 0x010000}

exit = False


def breakout(x):
    global exit
    exit = True


Buttons.enable_interrupt(Buttons.BTN_Menu,
                         breakout,
                         on_press=True,
                         on_release=False)

while True:
    store = [0, 0]
    incs = [random.randint(0, 2) for _ in range(2)]
    for i in range(0xff):
        store[0] += mapping[incs[0]]
        store[1] += mapping[incs[1]]
        n.display(store)
    if exit:
        break

restart_to_default()
Пример #7
0

def playback():
    global isRecording

    if isRecording:
        isRecording = False
        sim800.stoprecording()
        setRecordingStatus()
        displayStatus("")

    sim800.startplayback(1, 0, 100, False)


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

Buttons.enable_interrupt(Buttons.BTN_B,
                         lambda button_id: playback(),
                         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)

isRecording = False
displayControls()
setRecordingStatus()
Пример #8
0
        ugfx.text(5, i * 20 + 5, v + " ", ugfx.BLACK)


lastpushed = 0


def pushed(n):
    global Tape, TP, waiting
    if (waiting):
        output(n + " \n")
        Tape[TP] = ord(n)
        waiting = False


Buttons.enable_interrupt(Buttons.BTN_1,
                         lambda button_id: pushed("1"),
                         on_press=True,
                         on_release=False)
Buttons.enable_interrupt(Buttons.BTN_2,
                         lambda button_id: pushed("2"),
                         on_press=True,
                         on_release=False)
Buttons.enable_interrupt(Buttons.BTN_3,
                         lambda button_id: pushed("3"),
                         on_press=True,
                         on_release=False)
Buttons.enable_interrupt(Buttons.BTN_4,
                         lambda button_id: pushed("4"),
                         on_press=True,
                         on_release=False)
Buttons.enable_interrupt(Buttons.BTN_5,
                         lambda button_id: pushed("5"),
Пример #9
0
    vip = False
    show_boot()


def cbButton8(button_id):
    global strobe
    strobe = True


def cbButton9(button_id):
    global strobe
    strobe = False


Buttons.enable_interrupt(Buttons.BTN_Call,
                         cbButtonCall,
                         on_press=True,
                         on_release=False)

Buttons.enable_interrupt(Buttons.BTN_A,
                         cbButtonA,
                         on_press=True,
                         on_release=False)

Buttons.enable_interrupt(Buttons.BTN_B,
                         cbButtonB,
                         on_press=True,
                         on_release=False)

Buttons.enable_interrupt(Buttons.BTN_1,
                         cbButton1,
                         on_press=True,
Пример #10
0
            if YELLOW in CURRENT:
                last_update = 0
                CURRENT = (BLACK, BLACK)
            elif CURRENT == (RED, RED):
                CURRENT = (BLACK, BLACK)
            else:
                CURRENT = (RED, RED)
        last_update = utime.ticks_ms()
    if Buttons.is_pressed(Buttons.BTN_Menu):
        break
    if Buttons.is_pressed(Buttons.BTN_A) or Buttons.is_pressed(Buttons.BTN_B):
        playback_start = -400000


def force_start():
    global playback_start
    playback_start = 0


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

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

app.restart_to_default()