Esempio n. 1
0
def main():
    battery = OdroidGoBattery()

    voltage = battery.get_voltage()
    screen.print("voltage: %sV" % voltage)

    battery.deinit()
Esempio n. 2
0
def main():
    screen.print("All existing fonts:", align=screen.CENTER, color=screen.CYAN)

    fonts = screen.get_fonts()
    for font_name, font_id in fonts:
        text = "%i - %s" % (font_id, font_name)
        print(text)
        screen.set_font(font_id)
        screen.print(text, transparent=True)
Esempio n. 3
0
def main():
    led_pwm = PWM(blue_led, freq=1000, duty=0)

    for i in range(3, 0, -1):
        screen.print("%i" % i)

        for value in range(0, 100, 10):
            led_pwm.duty(value)
            time.sleep(0.01)

        for value in range(100, 0, -10):
            led_pwm.duty(value)
            time.sleep(0.01)

    led_pwm.deinit()
Esempio n. 4
0
def main():
    screen.print("PyOdroidGo by Jens Diemer (GPLv3)")
    screen.set_font(screen.FONT_DefaultSmall)
    screen.print(
        "%s %s on %s (Python v%s)" % (sys.implementation.name, ".".join(
            [str(i)
             for i in sys.implementation.version]), sys.platform, sys.version))
    screen.set_default_font()

    try:
        menu = Menu(screen=screen, reset_pin=odroidgo.BUTTON_MENU)
        crossbar = Crossbar(handler=menu)

        while not menu.exit:
            crossbar.poll()
            time.sleep(0.1)
    except Exception as err:
        buffer = io.StringIO()
        sys.print_exception(err, buffer)
        content = buffer.getvalue()
        print(content)
        screen.set_default_font()
        for line in content.splitlines():
            screen.print(line)
    finally:
        screen.deinit()

    print("--END--")
Esempio n. 5
0
def dir_listing(screen, path="/"):
    screen.print("Dir listing for: %r" % path)
    try:
        for item in sorted(os.ilistdir(path)):
            item_name, item_type = item[:2]
            abs_path = "%s/%s" % (path.rstrip("/"), item_name)
            stat = os.stat(abs_path)
            human_type = TYPE_MAP.get(item_type, "<unknown>")
            screen.print("%9s %-40s %s" % (human_type, abs_path, stat))
            if item_type == TYPE_DIR:
                dir_listing(screen, path=abs_path)
    except OSError as err:
        screen.print("ERROR reading %r: %s" % (path, err))
        buffer = io.StringIO()
        sys.print_exception(err, buffer)
        content = buffer.getvalue()
        for line in content.splitlines():
            screen.print(line)
Esempio n. 6
0
def main():
    print("sys.exit()")
    screen.print("sys.exit()")
    sys.exit()
Esempio n. 7
0
 def up(self):
     screen.print("up")
Esempio n. 8
0
def main():
    crossbar_handler = CrossbarPrintHandler()
    crossbar = Crossbar(crossbar_handler)
    screen.print("poll loop started...")
    while True:
        crossbar.poll()
Esempio n. 9
0
 def left(self):
     screen.print("left")
Esempio n. 10
0
 def right(self):
     screen.print("right")
Esempio n. 11
0
 def down(self):
     screen.print("down")
Esempio n. 12
0
def main():
    try:
        from wlan_settings import SSID, PASSWORD
    except ImportError as err:
        screen.print("ERROR: %s" % err)
        screen.print("Please create wlan_settings.py with SSID, PASSWORD ;)")
        raise RuntimeError

    # https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/network

    screen.print("Activate WLAN")
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)

    screen.print("scan...")
    for info in wlan.scan(True):
        ssid, bssid, primary_chan, rssi, auth_mode, auth_mode_string, hidden = info
        ssid = ssid.decode("UTF-8")
        if hidden:
            hidden = "hidden!"
        else:
            hidden = ""
        screen.print(" * %-20s channel %02i %s%s" %
                     (ssid, primary_chan, auth_mode_string, hidden))

    if not wlan.isconnected():
        screen.print("connecting to network...")
        wlan.connect(SSID, PASSWORD)
        no = 0
        while not wlan.isconnected():
            no += 1
            if no >= 20:
                screen.print("reset...")
                time.sleep(3)
                machine.reset()
            time.sleep(1)

    screen.print("connected, IP:")
    wlan_config = wlan.ifconfig()
    screen.print("network config: %s" % repr(wlan_config))

    # https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/rtc
    screen.print("NTP time...")
    rtc = machine.RTC()
    rtc.init((2018, 1, 1, 12, 12, 12))

    # found in second field, text before the coma, in
    # https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/blob/master/MicroPython_BUILD/components/micropython/docs/zones.csv
    my_timezone = "CET-1CEST,M3.5.0,M10.5.0/3"  # Europe/Berlin

    rtc.ntp_sync(server="pool.ntp.org", tz=my_timezone, update_period=3600)

    screen.print("time: %s" % repr(rtc.now()))

    # https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/ftpserver

    screen.print("Start FTP Server...")
    network.ftp.start(user="******",
                      password="******",
                      buffsize=1024,
                      timeout=300)
    # network.telnet.start(user="******", password="******", timeout=300)

    screen.print("done.")