diff --git a/micropython/examples/galactic_unicorn/cheer-lights.py b/micropython/examples/galactic_unicorn/cheer-lights.py deleted file mode 100644 index bc01ad8c..00000000 --- a/micropython/examples/galactic_unicorn/cheer-lights.py +++ /dev/null @@ -1,71 +0,0 @@ -# cheerlights -from time import sleep -from galactic import GalacticUnicorn -from picographics import PicoGraphics, DISPLAY_GALACTIC_UNICORN as DISPLAY -import network -import urequests - -try: - from secrets import WIFI_SSID, WIFI_PASS -except ImportError: - WIFI_SSID = None - WIFI_PASS = None - -# setup graphics -gu = GalacticUnicorn() -graphics = PicoGraphics(DISPLAY) -width = GalacticUnicorn.WIDTH -height = GalacticUnicorn.HEIGHT - - -# fill display -def draw(colour): - for x in range(width): - for y in range(height): - graphics.set_pen(colour) - graphics.pixel(x, y) - - gu.update(graphics) - - -# setup network connection -wlan = network.WLAN(network.STA_IF) -wlan.active(True) -wlan.connect(WIFI_SSID, WIFI_PASS) - -# Wait for connect or fail -max_wait = 10 -while max_wait > 0: - if wlan.status() < 0 or wlan.status() >= 3: - break - max_wait -= 1 - print('waiting for connection...') - sleep(1) - -# Handle connection error -if wlan.status() != 3: - raise RuntimeError('network connection failed') -else: - print('connected') - status = wlan.ifconfig() - print(f'ip = {status[0]}') - -# cheerlights - -# cheerlights colours -colours = {b'red': graphics.create_pen(0xff, 0x00, 0x00), b'green': graphics.create_pen(0x00, 0x80, 0x00), - b'blue': graphics.create_pen(0x00, 0x00, 0xff), - b'cyan': graphics.create_pen(0x00, 0xff, 0xff), b'white': graphics.create_pen(0xff, 0xff, 0xff), - b'oldlace': graphics.create_pen(0xfd, 0xf5, 0xe6), - b'purple': graphics.create_pen(0x80, 0x00, 0x80), b'magenta': graphics.create_pen(0xff, 0x00, 0xff), - b'yellow': graphics.create_pen(0xff, 0xff, 0x00), - b'orange': graphics.create_pen(0xff, 0xa5, 0x00), b'pink': graphics.create_pen(0xff, 0xc0, 0xcb)} - -# get request -while True: - r = urequests.get('http://api.thingspeak.com/channels/1417/field/1/last.txt') - print(f'Colour: {r.content}') - if r.content in colours: - draw(colours[r.content]) - r.close() - sleep(15) diff --git a/micropython/examples/galactic_unicorn/cheerlights.py b/micropython/examples/galactic_unicorn/cheerlights.py index 04520a0f..528a55cf 100644 --- a/micropython/examples/galactic_unicorn/cheerlights.py +++ b/micropython/examples/galactic_unicorn/cheerlights.py @@ -23,8 +23,8 @@ def draw(colour): graphics.pixel(x, y) gu.update(graphics) - - + + def status_handler(mode, status, ip): # reports wifi connection status print(mode, status, ip) @@ -62,4 +62,4 @@ while True: if r.content in colours: draw(colours[r.content]) r.close() - sleep(15) + sleep(15) \ No newline at end of file diff --git a/micropython/examples/galactic_unicorn/secrets.py b/micropython/examples/galactic_unicorn/secrets.py deleted file mode 100644 index cb0cbf2c..00000000 --- a/micropython/examples/galactic_unicorn/secrets.py +++ /dev/null @@ -1,2 +0,0 @@ -WIFI_SSID = "Name" -WIFI_PASS = "Password"