From d8927c95754b1241e1eaab6e88509fa9c302d8aa Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Tue, 8 Oct 2024 16:14:50 +0100 Subject: [PATCH 1/8] Initial setup of build with added W example --- .github/workflows/micropython.yml | 8 ++- examples/tiny_fx_w/README.md | 16 +++++ .../tiny_fx_w/examples/wifi/random_colour.py | 63 +++++++++++++++++++ examples/tiny_fx_w/secrets.py | 3 + 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 examples/tiny_fx_w/README.md create mode 100644 examples/tiny_fx_w/examples/wifi/random_colour.py create mode 100644 examples/tiny_fx_w/secrets.py diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 4a272c7..48ed1a5 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -75,6 +75,7 @@ jobs: ROOT_DIR: "$GITHUB_WORKSPACE/picofx" BOARD_DIR: "$GITHUB_WORKSPACE/picofx/boards/${{matrix.board}}" EXAMPLES_DIR: "$GITHUB_WORKSPACE/picofx/examples/tiny_fx" + EXAMPLES_W_DIR: "$GITHUB_WORKSPACE/picofx/examples/tiny_fx_w" FILESYSTEM_DIR: "$GITHUB_WORKSPACE/picofx/temp" FILESYSTEM_SUFFIX: "with-libs-and-examples" BOARD: "PIMORONI_TINYFX" @@ -186,13 +187,18 @@ jobs: cp -v -r ${{env.BOARD_DIR}}/visible_libs/. ${{env.FILESYSTEM_DIR}}/lib cp -v -r ${{env.EXAMPLES_DIR}}/. ${{env.FILESYSTEM_DIR}} + - name: "HACK: Mangle W examples into user filesystem" + if: matrix.shortname == 'tiny_fx_w' + shell: bash + run: | + cp -v -r ${{env.EXAMPLES_W_DIR}}/. ${{env.FILESYSTEM_DIR}} + - name: Append Filesystem shell: bash run: | python3 -m pip install littlefs-python==0.12.0 ./dir2uf2/dir2uf2 --fs-compact --append-to micropython/ports/rp2/build/${{env.RELEASE_FILE}}.uf2 --manifest ${{env.BOARD_DIR}}/uf2-manifest.txt --filename ${{env.FILESYSTEM_SUFFIX}}.uf2 ${{env.FILESYSTEM_DIR}}/ - - name: Store .uf2 as artifact uses: actions/upload-artifact@v4 with: diff --git a/examples/tiny_fx_w/README.md b/examples/tiny_fx_w/README.md new file mode 100644 index 0000000..50ac6f6 --- /dev/null +++ b/examples/tiny_fx_w/README.md @@ -0,0 +1,16 @@ +# TinyFX W Micropython Examples + +These are micropython examples for the wireless functionality of the Pimoroni [TinyFX W](https://shop.pimoroni.com/products/tiny_fx_w), a stamp-sized light and sound effects controller board for model making, construction kits, and dioramas. + +For examples that show off the rest of the board's functions, refer to the regular [TinyFX Micropython Examples](../tiny_fx/README.md) + +- [WiFi Examples](#wifi-examples) + - [Random Colour](#random-colour) + + +## WiFi Examples + +### Random Colour +[wifi/random_colour.py](examples/wifi/random_colour.py) + +Show the state of TinyFX's Boot button on its RGB output. diff --git a/examples/tiny_fx_w/examples/wifi/random_colour.py b/examples/tiny_fx_w/examples/wifi/random_colour.py new file mode 100644 index 0000000..a63790a --- /dev/null +++ b/examples/tiny_fx_w/examples/wifi/random_colour.py @@ -0,0 +1,63 @@ +import time +import network +import requests +from tiny_fx import TinyFX + +""" +Press "Boot" to exit the program. +""" +# secrets.py should contain: +# WIFI_SSID = "" +# WIFI_PASSWORD = "" + +try: + from secrets import WIFI_SSID, WIFI_PASSWORD +except ImportError: + print("Create secrets.py with your WiFi credentials") + + +# Constants +MONO_NAMES = ("One", "Two", "Three", "Four", "Five", "Six") +COLOUR_NAMES = ("R", "G", "B") + +# Variables +tiny = TinyFX() # Create a new TinyFX object to interact with the board + + +# Connect to WLAN +wlan = network.WLAN(network.STA_IF) +wlan.active(True) +wlan.connect(WIFI_SSID, WIFI_PASSWORD) + +while wlan.isconnected() == False: + print('Waiting for connection...') + time.sleep(1) + +ip = wlan.ifconfig()[0] +print(f'Connected on {ip}') + + +# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) +try: + while True: + req = requests.get("https://random-flat-colors.vercel.app/api/random?count=2").json() + + mono = tuple(int(req['colors'][0][i:i+1], 16) / 15 for i in range(1, 7)) + colour = tuple(int(req['colors'][1][i:i+2], 16) for i in (1, 3, 5)) + + for i in range(len(tiny.outputs)): + tiny.outputs[i].brightness(mono[i]) + print(f"{MONO_NAMES[i]} = {round(mono[i], 2)}", end=", ") + + tiny.rgb.set_rgb(*colour) + for i in range(len(colour)): + print(f"{COLOUR_NAMES[i]} = {colour[i]}", end=", ") + + print() + + time.sleep(5) + +# Turn off all the outputs +finally: + tiny.shutdown() + wlan.disconnect() \ No newline at end of file diff --git a/examples/tiny_fx_w/secrets.py b/examples/tiny_fx_w/secrets.py new file mode 100644 index 0000000..ad19206 --- /dev/null +++ b/examples/tiny_fx_w/secrets.py @@ -0,0 +1,3 @@ +# secrets.py should contain: +WIFI_SSID = "" +WIFI_PASSWORD = "" \ No newline at end of file From b684216292f2438b01349eba081dc5d6f901853d Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Tue, 8 Oct 2024 16:25:02 +0100 Subject: [PATCH 2/8] Update manifest for W --- boards/PIMORONI_TINYFX/uf2-manifest.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boards/PIMORONI_TINYFX/uf2-manifest.txt b/boards/PIMORONI_TINYFX/uf2-manifest.txt index c7951d6..f9e4561 100644 --- a/boards/PIMORONI_TINYFX/uf2-manifest.txt +++ b/boards/PIMORONI_TINYFX/uf2-manifest.txt @@ -1,4 +1,5 @@ main.py +secrets.py examples/*.py examples/effects/*.py examples/effects/mono/*.py @@ -7,6 +8,7 @@ examples/function/*.py examples/showcase/*.py examples/audio/race_start.py examples/audio/fair_use_encounters.py +examples/wifi/*.py lib/*.py lib/picofx/*.py lib/picofx/colour/*.py From 0fa9eb0099d9f8df29920f1e40f7af8b7ec6ac05 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Tue, 8 Oct 2024 16:52:19 +0100 Subject: [PATCH 3/8] Set up zip file creation for W --- .github/workflows/filesystem.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/filesystem.yml b/.github/workflows/filesystem.yml index 2c674a4..7fc5f18 100644 --- a/.github/workflows/filesystem.yml +++ b/.github/workflows/filesystem.yml @@ -16,12 +16,14 @@ jobs: - name: TinyFX shortname: tiny_fx board: PIMORONI_TINYFX + - name: TinyFX W + shortname: tiny_fx_w + board: PIMORONI_TINYFX env: RELEASE_FILE: ${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}} ROOT_DIR: "picofx" BOARD_DIR: "picofx/boards/${{matrix.board}}" - EXAMPLES_DIR: "picofx/examples/${{matrix.shortname}}" LIBS_DIR: "picofx/lib_temp" EX_DIR: "picofx/ex_temp" @@ -42,26 +44,34 @@ jobs: - name: "Assemble example content" shell: bash run: | - mkdir -p ${{env.EXAMPLES_DIR}} - cp -v -r ${{env.EXAMPLES_DIR}}/. ${{env.EX_DIR}} + mkdir -p ${{env.EX_DIR}} + cp -v -r picofx/examples/tiny_fx/. ${{env.EX_DIR}} rm -v ${{env.EX_DIR}}/README.md rm -v -r ${{env.EX_DIR}}/examples/audio/photon_sword rm -v ${{env.EX_DIR}}/examples/audio/photon_sword.py + - name: "Append W example content" + if: matrix.shortname == 'tiny_fx_w' + shell: bash + run: | + cp -v -r picofx/examples/tiny_fx_w/. ${{env.EX_DIR}} + rm -v ${{env.EX_DIR}}/README.md + - name: Libs .zip artifact + if: matrix.shortname == 'tiny_fx' uses: actions/upload-artifact@v4 with: name: ${{env.RELEASE_FILE}}-libraries-only path: picofx/lib_temp - - name: Examples .zip artifact + - name: Examples .zip artifact uses: actions/upload-artifact@v4 with: name: ${{env.RELEASE_FILE}}-examples-only path: "picofx/ex_temp" - name: Libs .zip release asset - if: github.event_name == 'release' + if: github.event_name == 'release' && matrix.shortname == 'tiny_fx' uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 545d6ab907693db12d01dd2ce5936aea7528f41c Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Tue, 8 Oct 2024 17:16:41 +0100 Subject: [PATCH 4/8] Separate manifests for the two boards --- .github/workflows/micropython.yml | 4 +++- boards/PIMORONI_TINYFX/uf2-manifest-w.txt | 15 +++++++++++++++ boards/PIMORONI_TINYFX/uf2-manifest.txt | 2 -- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 boards/PIMORONI_TINYFX/uf2-manifest-w.txt diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 48ed1a5..82900e8 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -64,10 +64,12 @@ jobs: - name: TinyFX shortname: tiny_fx board: PIMORONI_TINYFX + manifest: uf2-manifest - name: TinyFX W shortname: tiny_fx_w board: PIMORONI_TINYFX variant: w + manifest: uf2-manifest-w env: RELEASE_FILE: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython @@ -197,7 +199,7 @@ jobs: shell: bash run: | python3 -m pip install littlefs-python==0.12.0 - ./dir2uf2/dir2uf2 --fs-compact --append-to micropython/ports/rp2/build/${{env.RELEASE_FILE}}.uf2 --manifest ${{env.BOARD_DIR}}/uf2-manifest.txt --filename ${{env.FILESYSTEM_SUFFIX}}.uf2 ${{env.FILESYSTEM_DIR}}/ + ./dir2uf2/dir2uf2 --fs-compact --append-to micropython/ports/rp2/build/${{env.RELEASE_FILE}}.uf2 --manifest ${{env.BOARD_DIR}}/${{matrix.manifest}}.txt --filename ${{env.FILESYSTEM_SUFFIX}}.uf2 ${{env.FILESYSTEM_DIR}}/ - name: Store .uf2 as artifact uses: actions/upload-artifact@v4 diff --git a/boards/PIMORONI_TINYFX/uf2-manifest-w.txt b/boards/PIMORONI_TINYFX/uf2-manifest-w.txt new file mode 100644 index 0000000..f9e4561 --- /dev/null +++ b/boards/PIMORONI_TINYFX/uf2-manifest-w.txt @@ -0,0 +1,15 @@ +main.py +secrets.py +examples/*.py +examples/effects/*.py +examples/effects/mono/*.py +examples/effects/colour/*.py +examples/function/*.py +examples/showcase/*.py +examples/audio/race_start.py +examples/audio/fair_use_encounters.py +examples/wifi/*.py +lib/*.py +lib/picofx/*.py +lib/picofx/colour/*.py +lib/picofx/mono/*.py \ No newline at end of file diff --git a/boards/PIMORONI_TINYFX/uf2-manifest.txt b/boards/PIMORONI_TINYFX/uf2-manifest.txt index f9e4561..c7951d6 100644 --- a/boards/PIMORONI_TINYFX/uf2-manifest.txt +++ b/boards/PIMORONI_TINYFX/uf2-manifest.txt @@ -1,5 +1,4 @@ main.py -secrets.py examples/*.py examples/effects/*.py examples/effects/mono/*.py @@ -8,7 +7,6 @@ examples/function/*.py examples/showcase/*.py examples/audio/race_start.py examples/audio/fair_use_encounters.py -examples/wifi/*.py lib/*.py lib/picofx/*.py lib/picofx/colour/*.py From 7326553fc924b631e7c924e20701f6e008bbb3d7 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Thu, 10 Oct 2024 12:29:09 +0100 Subject: [PATCH 5/8] Tidied up random wireless example --- examples/tiny_fx_w/README.md | 16 ++-- .../tiny_fx_w/examples/wifi/random_colour.py | 63 ---------------- .../tiny_fx_w/examples/wireless/random.py | 74 +++++++++++++++++++ examples/tiny_fx_w/secrets.py | 3 +- 4 files changed, 86 insertions(+), 70 deletions(-) delete mode 100644 examples/tiny_fx_w/examples/wifi/random_colour.py create mode 100644 examples/tiny_fx_w/examples/wireless/random.py diff --git a/examples/tiny_fx_w/README.md b/examples/tiny_fx_w/README.md index 50ac6f6..28e8606 100644 --- a/examples/tiny_fx_w/README.md +++ b/examples/tiny_fx_w/README.md @@ -4,13 +4,19 @@ These are micropython examples for the wireless functionality of the Pimoroni [T For examples that show off the rest of the board's functions, refer to the regular [TinyFX Micropython Examples](../tiny_fx/README.md) -- [WiFi Examples](#wifi-examples) - - [Random Colour](#random-colour) +- [Wireless Examples](#wireless-examples) + - [Random](#random) -## WiFi Examples +## Wireless Examples -### Random Colour -[wifi/random_colour.py](examples/wifi/random_colour.py) +These examples requires a `secrets.py` file to be on your board's file system with the credentials of your WiFi network. + +### Random +[wireless/random.py](examples/wireless/random.py) Show the state of TinyFX's Boot button on its RGB output. +Show random colours and patterns obtained from the internet on TinyFX's outputs. + + + diff --git a/examples/tiny_fx_w/examples/wifi/random_colour.py b/examples/tiny_fx_w/examples/wifi/random_colour.py deleted file mode 100644 index a63790a..0000000 --- a/examples/tiny_fx_w/examples/wifi/random_colour.py +++ /dev/null @@ -1,63 +0,0 @@ -import time -import network -import requests -from tiny_fx import TinyFX - -""" -Press "Boot" to exit the program. -""" -# secrets.py should contain: -# WIFI_SSID = "" -# WIFI_PASSWORD = "" - -try: - from secrets import WIFI_SSID, WIFI_PASSWORD -except ImportError: - print("Create secrets.py with your WiFi credentials") - - -# Constants -MONO_NAMES = ("One", "Two", "Three", "Four", "Five", "Six") -COLOUR_NAMES = ("R", "G", "B") - -# Variables -tiny = TinyFX() # Create a new TinyFX object to interact with the board - - -# Connect to WLAN -wlan = network.WLAN(network.STA_IF) -wlan.active(True) -wlan.connect(WIFI_SSID, WIFI_PASSWORD) - -while wlan.isconnected() == False: - print('Waiting for connection...') - time.sleep(1) - -ip = wlan.ifconfig()[0] -print(f'Connected on {ip}') - - -# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) -try: - while True: - req = requests.get("https://random-flat-colors.vercel.app/api/random?count=2").json() - - mono = tuple(int(req['colors'][0][i:i+1], 16) / 15 for i in range(1, 7)) - colour = tuple(int(req['colors'][1][i:i+2], 16) for i in (1, 3, 5)) - - for i in range(len(tiny.outputs)): - tiny.outputs[i].brightness(mono[i]) - print(f"{MONO_NAMES[i]} = {round(mono[i], 2)}", end=", ") - - tiny.rgb.set_rgb(*colour) - for i in range(len(colour)): - print(f"{COLOUR_NAMES[i]} = {colour[i]}", end=", ") - - print() - - time.sleep(5) - -# Turn off all the outputs -finally: - tiny.shutdown() - wlan.disconnect() \ No newline at end of file diff --git a/examples/tiny_fx_w/examples/wireless/random.py b/examples/tiny_fx_w/examples/wireless/random.py new file mode 100644 index 0000000..62bb471 --- /dev/null +++ b/examples/tiny_fx_w/examples/wireless/random.py @@ -0,0 +1,74 @@ +import time +import network +import requests +from tiny_fx import TinyFX + +""" +Show random colours and patterns obtained from the internet on TinyFX's outputs. + +This example requires a secrets.py file to be on your board's file system with the credentials of your WiFi network. + +Press "Boot" to exit the program. +""" + +try: + from secrets import WIFI_SSID, WIFI_PASSWORD +except ImportError: + print("Create secrets.py with your WiFi credentials") + raise + + +# Constants +MONO_NAMES = ("One", "Two", "Three", "Four", "Five", "Six") +COLOUR_NAMES = ("R", "G", "B") +CONNECTION_INTERVAL = 1.0 # The time to sleep between each connection check +REQUEST_INTERVAL = 5.0 # The time to sleep between each internet request + +# Variables +tiny = TinyFX() # Create a new TinyFX object to interact with the board +wlan = network.WLAN(network.STA_IF) # Create a new network object for interacting with WiFI + + +# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) +try: + # Connect to WLAN + wlan.active(True) + wlan.connect(WIFI_SSID, WIFI_PASSWORD) + + # Wait until the connection is established + while not wlan.isconnected(): + print('Waiting for connection...') + time.sleep(CONNECTION_INTERVAL) + + # Print out our IP address + print(f'Connected on {wlan.ifconfig()[0]}') + + # Loop forever + while True: + # Get two colours from the internet + req = requests.get("https://random-flat-colors.vercel.app/api/random?count=2").json() + + # Use the first to get brightness values for the six mono outputs + mono = tuple(int(req['colors'][0][i:i + 1], 16) / 15 for i in range(1, 7)) + + # Use the second to get the colour components for the RGB output + colour = tuple(int(req['colors'][1][i:i + 2], 16) for i in (1, 3, 5)) + + # Set the mono outputs, and print the values + for i in range(len(tiny.outputs)): + tiny.outputs[i].brightness(mono[i]) + print(f"{MONO_NAMES[i]} = {round(mono[i], 2)}", end=", ") + + # Set the colour output, and print the values + tiny.rgb.set_rgb(*colour) + for i in range(len(colour)): + print(f"{COLOUR_NAMES[i]} = {colour[i]}", end=", ") + + print() + + time.sleep(REQUEST_INTERVAL) + +# Turn off all the outputs +finally: + tiny.shutdown() + wlan.disconnect() diff --git a/examples/tiny_fx_w/secrets.py b/examples/tiny_fx_w/secrets.py index ad19206..f290ec1 100644 --- a/examples/tiny_fx_w/secrets.py +++ b/examples/tiny_fx_w/secrets.py @@ -1,3 +1,2 @@ -# secrets.py should contain: WIFI_SSID = "" -WIFI_PASSWORD = "" \ No newline at end of file +WIFI_PASSWORD = "" From 657baf1e0ba2d7103e0411a86fc5c887b21b11d5 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Thu, 10 Oct 2024 13:05:05 +0100 Subject: [PATCH 6/8] Added cheerlights example and closed request --- examples/tiny_fx_w/README.md | 5 ++ .../examples/wireless/cheerlights.py | 68 +++++++++++++++++++ .../tiny_fx_w/examples/wireless/random.py | 8 ++- 3 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 examples/tiny_fx_w/examples/wireless/cheerlights.py diff --git a/examples/tiny_fx_w/README.md b/examples/tiny_fx_w/README.md index 28e8606..d4b07da 100644 --- a/examples/tiny_fx_w/README.md +++ b/examples/tiny_fx_w/README.md @@ -6,6 +6,7 @@ For examples that show off the rest of the board's functions, refer to the regul - [Wireless Examples](#wireless-examples) - [Random](#random) + - [CheerLights](#cheerlights) ## Wireless Examples @@ -19,4 +20,8 @@ Show the state of TinyFX's Boot button on its RGB output. Show random colours and patterns obtained from the internet on TinyFX's outputs. +### CheerLights +[wireless/cheerlights.py](examples/wireless/cheerlights.py) +Obtain the current CheerLights colour from the internet and show it on TinyFX's RGB output. +For more information about CheerLights, visit: [https://cheerlights.com/](https://cheerlights.com/) diff --git a/examples/tiny_fx_w/examples/wireless/cheerlights.py b/examples/tiny_fx_w/examples/wireless/cheerlights.py new file mode 100644 index 0000000..023f969 --- /dev/null +++ b/examples/tiny_fx_w/examples/wireless/cheerlights.py @@ -0,0 +1,68 @@ +import time +import network +import requests +from tiny_fx import TinyFX + +""" +Obtain the current CheerLights colour from the internet and show it on TinyFX's RGB output. +For more information about CheerLights, visit: https://cheerlights.com/ + +This example requires a secrets.py file to be on your board's file system with the credentials of your WiFi network. + +Press "Boot" to exit the program. +""" + +try: + from secrets import WIFI_SSID, WIFI_PASSWORD +except ImportError: + print("Create secrets.py with your WiFi credentials") + raise + + +# Constants +COLOUR_NAMES = ("R", "G", "B") +CONNECTION_INTERVAL = 1.0 # The time to sleep between each connection check +REQUEST_INTERVAL = 5.0 # The time to sleep between each internet request + +# Variables +tiny = TinyFX() # Create a new TinyFX object to interact with the board +wlan = network.WLAN(network.STA_IF) # Create a new network object for interacting with WiFI + + +# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) +try: + # Connect to WLAN + wlan.active(True) + wlan.connect(WIFI_SSID, WIFI_PASSWORD) + + # Wait until the connection is established + while not wlan.isconnected(): + print('Waiting for connection...') + time.sleep(CONNECTION_INTERVAL) + + # Print out our IP address + print(f'Connected on {wlan.ifconfig()[0]}') + + # Loop forever + while True: + # Get the current CheerLights colour from the internet + req = requests.get("http://api.thingspeak.com/channels/1417/field/2/last.json") + json = req.json() + req.close() + + # Use the second to get the colour components for the RGB output + colour = tuple(int(json['field2'][i:i + 2], 16) for i in (1, 3, 5)) + + # Set the colour output, and print the values + tiny.rgb.set_rgb(*colour) + for i in range(len(colour)): + print(f"{COLOUR_NAMES[i]} = {colour[i]}", end=", ") + + print() + + time.sleep(REQUEST_INTERVAL) + +# Turn off all the outputs +finally: + tiny.shutdown() + wlan.disconnect() diff --git a/examples/tiny_fx_w/examples/wireless/random.py b/examples/tiny_fx_w/examples/wireless/random.py index 62bb471..09d4809 100644 --- a/examples/tiny_fx_w/examples/wireless/random.py +++ b/examples/tiny_fx_w/examples/wireless/random.py @@ -46,13 +46,15 @@ # Loop forever while True: # Get two colours from the internet - req = requests.get("https://random-flat-colors.vercel.app/api/random?count=2").json() + req = requests.get("https://random-flat-colors.vercel.app/api/random?count=2") + json = req.json() + req.close() # Use the first to get brightness values for the six mono outputs - mono = tuple(int(req['colors'][0][i:i + 1], 16) / 15 for i in range(1, 7)) + mono = tuple(int(json['colors'][0][i:i + 1], 16) / 15 for i in range(1, 7)) # Use the second to get the colour components for the RGB output - colour = tuple(int(req['colors'][1][i:i + 2], 16) for i in (1, 3, 5)) + colour = tuple(int(json['colors'][1][i:i + 2], 16) for i in (1, 3, 5)) # Set the mono outputs, and print the values for i in range(len(tiny.outputs)): From 9126be445c68adce79a0a0d92ce59031a6145240 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Thu, 10 Oct 2024 13:50:47 +0100 Subject: [PATCH 7/8] Update manifest for new folder name --- boards/PIMORONI_TINYFX/uf2-manifest-w.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/PIMORONI_TINYFX/uf2-manifest-w.txt b/boards/PIMORONI_TINYFX/uf2-manifest-w.txt index f9e4561..08583cb 100644 --- a/boards/PIMORONI_TINYFX/uf2-manifest-w.txt +++ b/boards/PIMORONI_TINYFX/uf2-manifest-w.txt @@ -8,7 +8,7 @@ examples/function/*.py examples/showcase/*.py examples/audio/race_start.py examples/audio/fair_use_encounters.py -examples/wifi/*.py +examples/wireless/*.py lib/*.py lib/picofx/*.py lib/picofx/colour/*.py From 59790637f9ff9c6c99ec2ae8f4dffa1016ddbcfc Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Thu, 10 Oct 2024 14:08:33 +0100 Subject: [PATCH 8/8] Improve error reporting on w examples --- examples/tiny_fx_w/examples/wireless/cheerlights.py | 6 ++++-- examples/tiny_fx_w/examples/wireless/random.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/tiny_fx_w/examples/wireless/cheerlights.py b/examples/tiny_fx_w/examples/wireless/cheerlights.py index 023f969..46e2c22 100644 --- a/examples/tiny_fx_w/examples/wireless/cheerlights.py +++ b/examples/tiny_fx_w/examples/wireless/cheerlights.py @@ -14,9 +14,10 @@ try: from secrets import WIFI_SSID, WIFI_PASSWORD + if len(WIFI_SSID) == 0: + raise ValueError("no WiFi network set. Open the 'secrets.py' file on your device to add your WiFi credentials") except ImportError: - print("Create secrets.py with your WiFi credentials") - raise + raise ImportError("no module named 'secrets'. Create a 'secrets.py' file on your device with your WiFi credentials") # Constants @@ -33,6 +34,7 @@ try: # Connect to WLAN wlan.active(True) + print(f"Connecting to network '{WIFI_SSID}'") wlan.connect(WIFI_SSID, WIFI_PASSWORD) # Wait until the connection is established diff --git a/examples/tiny_fx_w/examples/wireless/random.py b/examples/tiny_fx_w/examples/wireless/random.py index 09d4809..2d60ff9 100644 --- a/examples/tiny_fx_w/examples/wireless/random.py +++ b/examples/tiny_fx_w/examples/wireless/random.py @@ -13,9 +13,10 @@ try: from secrets import WIFI_SSID, WIFI_PASSWORD + if len(WIFI_SSID) == 0: + raise ValueError("no WiFi network set. Open the 'secrets.py' file on your device to add your WiFi credentials") except ImportError: - print("Create secrets.py with your WiFi credentials") - raise + raise ImportError("no module named 'secrets'. Create a 'secrets.py' file on your device with your WiFi credentials") # Constants @@ -33,6 +34,7 @@ try: # Connect to WLAN wlan.active(True) + print(f"Connecting to network '{WIFI_SSID}'") wlan.connect(WIFI_SSID, WIFI_PASSWORD) # Wait until the connection is established