예제 #1
0
def main():

    zoom = 15
    tft = m5stack.Display()

    tft.text(10, 10, "> Reading settings.\n")
    with open("/flash/settings.json") as fp:
        settings = json.loads(fp.read())

    tft.text(10, tft.LASTY, "> Connecting to wifi.\n")
    wifi = Wifi(settings["username"], settings["password"])

    tft.text(10, tft.LASTY, "> Scanning networks.\n")
    networks = wifi.scan()

    tft.text(10, tft.LASTY, "> Locating current position.\n")
    geolocation = Geolocation(settings["api_key"], networks)
    coordinates = geolocation.coordinates()

    tft.text(10, tft.LASTY, "> Downloading the map.\n")
    map = Map(coordinates)
    map.save("/flash/map.jpg")

    tft.image(0, 0, "/flash/map.jpg")

    button_a = DigitalInput(Pin(m5stack.BUTTON_A_PIN, Pin.IN),
                            callback=lambda pin: zoom_in_handler(map, tft))

    button_c = DigitalInput(Pin(m5stack.BUTTON_C_PIN, Pin.IN),
                            callback=lambda pin: zoom_out_handler(map, tft))
예제 #2
0
def main():
    tft = m5stack.Display()

    init()
    seed = boot()
    try:
        verifies = sign_and_verify(seed)
    except Exception as e:
        verifies = "error"
        import sys
        sys.print_exception(e)
    message = "verifies? %s" % verifies
    tft.text(tft.CENTER, 45, message)
예제 #3
0
import utime
import machine
import m5stack

tft = m5stack.Display()
uart = machine.UART(2, tx=17, rx=16)


def main():
    while True:
        height = 0
        b = uart.read(1)
        tft.text(tft.CENTER, height, 'msg: ' + str(b))
        height += 10
        utime.sleep(1)


if __name__ == '__main__':
    main()