From 177a52a6b0f18673003807db24998ea14b291b7a Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Mon, 9 Dec 2024 14:31:25 +0000 Subject: [PATCH 01/13] Add hardcoded wireless for Slot 5 --- firmware/PIMORONI_YUKON_W/board.c | 38 ++++++++ firmware/PIMORONI_YUKON_W/board.json | 15 ++++ firmware/PIMORONI_YUKON_W/manifest.py | 10 +++ firmware/PIMORONI_YUKON_W/micropython.cmake | 54 ++++++++++++ firmware/PIMORONI_YUKON_W/mpconfigboard.cmake | 26 ++++++ firmware/PIMORONI_YUKON_W/mpconfigboard.h | 38 ++++++++ firmware/PIMORONI_YUKON_W/pimoroni_yukon_w.h | 87 +++++++++++++++++++ firmware/PIMORONI_YUKON_W/pins.csv | 70 +++++++++++++++ firmware/PIMORONI_YUKON_W/uf2-manifest.txt | 5 ++ 9 files changed, 343 insertions(+) create mode 100644 firmware/PIMORONI_YUKON_W/board.c create mode 100644 firmware/PIMORONI_YUKON_W/board.json create mode 100644 firmware/PIMORONI_YUKON_W/manifest.py create mode 100644 firmware/PIMORONI_YUKON_W/micropython.cmake create mode 100644 firmware/PIMORONI_YUKON_W/mpconfigboard.cmake create mode 100644 firmware/PIMORONI_YUKON_W/mpconfigboard.h create mode 100644 firmware/PIMORONI_YUKON_W/pimoroni_yukon_w.h create mode 100644 firmware/PIMORONI_YUKON_W/pins.csv create mode 100644 firmware/PIMORONI_YUKON_W/uf2-manifest.txt diff --git a/firmware/PIMORONI_YUKON_W/board.c b/firmware/PIMORONI_YUKON_W/board.c new file mode 100644 index 0000000..7a29612 --- /dev/null +++ b/firmware/PIMORONI_YUKON_W/board.c @@ -0,0 +1,38 @@ +#include "mpconfigboard.h" +#include "hardware/gpio.h" +#include "hardware/i2c.h" +#include "tca9555.h" + +void board_init() { + // Set the first IO expander's initial state + tca_set_output_port(0, 0x8800); // Disable the two ADC Muxes + tca_set_polarity_port(0, 0x0000); + tca_set_config_port(0, 0x07BF); + + // Set the second IO expander's initial state + tca_set_output_port(1, 0x0000); + tca_set_polarity_port(1, 0x0000); + tca_set_config_port(1, 0xFCE6); +} + +void board_reset(void) { + for (int i = 0; i < 16; ++i) { + gpio_init(i); + hw_clear_bits(&padsbank0_hw->io[i], PADS_BANK0_GPIO0_IE_BITS | + PADS_BANK0_GPIO0_PUE_BITS | + PADS_BANK0_GPIO0_PDE_BITS); + hw_set_bits(&padsbank0_hw->io[i], PADS_BANK0_GPIO0_OD_BITS); + } + + // Skip over SLOT 5 + + for (int i = 20; i < 24; ++i) { + gpio_init(i); + hw_clear_bits(&padsbank0_hw->io[i], PADS_BANK0_GPIO0_IE_BITS | + PADS_BANK0_GPIO0_PUE_BITS | + PADS_BANK0_GPIO0_PDE_BITS); + hw_set_bits(&padsbank0_hw->io[i], PADS_BANK0_GPIO0_OD_BITS); + } + + board_init(); +} diff --git a/firmware/PIMORONI_YUKON_W/board.json b/firmware/PIMORONI_YUKON_W/board.json new file mode 100644 index 0000000..cbd5892 --- /dev/null +++ b/firmware/PIMORONI_YUKON_W/board.json @@ -0,0 +1,15 @@ +{ + "deploy": [ + "../deploy.md" + ], + "docs": "", + "features": [ + ], + "images": [ + ], + "mcu": "rp2040", + "product": "Pimoroni Yukon W", + "thumbnail": "", + "url": "https://shop.pimoroni.com/products/yukon", + "vendor": "Pimoroni" +} diff --git a/firmware/PIMORONI_YUKON_W/manifest.py b/firmware/PIMORONI_YUKON_W/manifest.py new file mode 100644 index 0000000..8b3cf67 --- /dev/null +++ b/firmware/PIMORONI_YUKON_W/manifest.py @@ -0,0 +1,10 @@ +include("$(PORT_DIR)/boards/manifest.py") + +freeze("$(BOARD_DIR)/../frozen/") + +require("sdcard") + +require("bundle-networking") + +# Bluetooth +require("aioble") diff --git a/firmware/PIMORONI_YUKON_W/micropython.cmake b/firmware/PIMORONI_YUKON_W/micropython.cmake new file mode 100644 index 0000000..cc30979 --- /dev/null +++ b/firmware/PIMORONI_YUKON_W/micropython.cmake @@ -0,0 +1,54 @@ +set(PIMORONI_PICO_PATH ../../../../pimoroni-pico) +include(${CMAKE_CURRENT_LIST_DIR}/../pimoroni_pico_import.cmake) + +include_directories(${PIMORONI_PICO_PATH}/micropython) +include_directories(${CMAKE_CURRENT_LIST_DIR}/../modules) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../") +list(APPEND CMAKE_MODULE_PATH "${PIMORONI_PICO_PATH}/micropython") +list(APPEND CMAKE_MODULE_PATH "${PIMORONI_PICO_PATH}/micropython/modules") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../modules") + +# Enable support for string_view (for PicoGraphics) +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) + +# Essential +include(pimoroni_i2c/micropython) +include(pimoroni_bus/micropython) + +# Pico Graphics Essential +include(hershey_fonts/micropython) +include(bitmap_fonts/micropython) +include(picographics/micropython) + +# Pico Graphics Extra +include(jpegdec/micropython) +include(qrcode/micropython/micropython) + +# Sensors & Breakouts +include(micropython-common-breakouts) + +# LEDs & Matrices +include(plasma/micropython) + +# Servos & Motors +include(pwm/micropython) +include(servo/micropython) +include(encoder/micropython) +include(motor/micropython) + +# Utility +include(adcfft/micropython) + +# Note: cppmem is *required* for C++ code to function on MicroPython +# it redirects `malloc` and `free` calls to MicroPython's heap +include(cppmem/micropython) + +# version.py, pimoroni.py and boot.py +include(modules_py/modules_py) + +# Must call `enable_ulab()` to enable +include(micropython-common-ulab) + +include(tca9555/micropython) diff --git a/firmware/PIMORONI_YUKON_W/mpconfigboard.cmake b/firmware/PIMORONI_YUKON_W/mpconfigboard.cmake new file mode 100644 index 0000000..fcd24bc --- /dev/null +++ b/firmware/PIMORONI_YUKON_W/mpconfigboard.cmake @@ -0,0 +1,26 @@ +# cmake file for Pimoroni Yukon +set(MICROPY_BOARD "PIMORONI_YUKON_W") + +# Allow Pico SDK to locate "pimoroni_yukon.h" in this directory. +list(APPEND PICO_BOARD_HEADER_DIRS "${CMAKE_CURRENT_LIST_DIR}") + +set(MICROPY_SOURCE_BOARD + ${CMAKE_CURRENT_LIST_DIR}/board.c +) + +set(MICROPY_TCA9555_DIR + ${CMAKE_CURRENT_LIST_DIR}/../drivers/tca9555/ +) + +set(MICROPY_PY_LWIP ON) +set(MICROPY_PY_NETWORK_CYW43 ON) + +# Bluetooth +set(MICROPY_PY_BLUETOOTH ON) +set(MICROPY_BLUETOOTH_BTSTACK ON) +set(MICROPY_PY_BLUETOOTH_CYW43 ON) + +# Board specific version of the frozen manifest +set(MICROPY_FROZEN_MANIFEST ${CMAKE_CURRENT_LIST_DIR}/manifest.py) + +set(MICROPY_C_HEAP_SIZE 4096) diff --git a/firmware/PIMORONI_YUKON_W/mpconfigboard.h b/firmware/PIMORONI_YUKON_W/mpconfigboard.h new file mode 100644 index 0000000..ddbee02 --- /dev/null +++ b/firmware/PIMORONI_YUKON_W/mpconfigboard.h @@ -0,0 +1,38 @@ +// This is a hack! Need to replace with upstream board definition. +#define MICROPY_HW_BOARD_NAME "Pimoroni Yukon W" +#define MICROPY_HW_FLASH_STORAGE_BYTES (14160 * 1024) + +#define MICROPY_HW_USB_VID (0x2E8A) +#define MICROPY_HW_USB_PID (0x105B) + +#define MICROPY_HW_SPI0_SCK (0) +#define MICROPY_HW_SPI0_MOSI (0) +#define MICROPY_HW_SPI0_MISO (0) + +#define MICROPY_HW_I2C0_SDA (24) +#define MICROPY_HW_I2C0_SCL (25) +#define MICROPY_HW_I2C0_FREQ (400000) + +#define TCA9555_CHIP_COUNT (2) +#define TCA9555_CHIP_ADDRESSES { 0x20, 0x26 } +#define TCA9555_LOCAL_MEMORY (1) +#define TCA9555_READ_INTERNALS (1) + +// Enable networking. +#define MICROPY_PY_NETWORK 1 +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "YukonW" + +// CYW43 driver configuration. +#define CYW43_USE_SPI (1) +#define CYW43_LWIP (1) +#define CYW43_GPIO (0) +#define CYW43_SPI_PIO (1) +#define ENABLE_SPI_DUMPING (1) + +#define MICROPY_BOARD_EARLY_INIT board_init +void board_init(void); + +#define MICROPY_BOARD_START_SOFT_RESET board_reset +void board_reset(void); + +#define MICROPY_HW_PIN_RESERVED(i) ((i) == CYW43_PIN_WL_HOST_WAKE || (i) == CYW43_PIN_WL_REG_ON) diff --git a/firmware/PIMORONI_YUKON_W/pimoroni_yukon_w.h b/firmware/PIMORONI_YUKON_W/pimoroni_yukon_w.h new file mode 100644 index 0000000..8c08c9d --- /dev/null +++ b/firmware/PIMORONI_YUKON_W/pimoroni_yukon_w.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +// ----------------------------------------------------- +// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO +// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES +// ----------------------------------------------------- + +#ifndef _BOARDS_PIMORONI_YUKON_H +#define _BOARDS_PIMORONI_YUKON_H + +// For board detection +#define PIMORONI_YUKON + +// --- UART --- +//#ifndef PICO_DEFAULT_UART +//#define PICO_DEFAULT_UART 0 +//#endif +//#ifndef PICO_DEFAULT_UART_TX_PIN +//#define PICO_DEFAULT_UART_TX_PIN 0 +//#endif +//#ifndef PICO_DEFAULT_UART_RX_PIN +//#define PICO_DEFAULT_UART_RX_PIN 1 +//#endif + +// --- LED --- +//#ifndef PICO_DEFAULT_LED_PIN +//#define PICO_DEFAULT_LED_PIN 25 +//#endif +// no PICO_DEFAULT_WS2812_PIN + +// --- I2C --- +#ifndef PICO_DEFAULT_I2C +#define PICO_DEFAULT_I2C 0 +#endif +#ifndef PICO_DEFAULT_I2C_SDA_PIN +#define PICO_DEFAULT_I2C_SDA_PIN 24 +#endif +#ifndef PICO_DEFAULT_I2C_SCL_PIN +#define PICO_DEFAULT_I2C_SCL_PIN 25 +#endif + +// --- SPI --- +//#ifndef PICO_DEFAULT_SPI +//#define PICO_DEFAULT_SPI 0 +//#endif +//#ifndef PICO_DEFAULT_SPI_SCK_PIN +//#define PICO_DEFAULT_SPI_SCK_PIN 18 +//#endif +//#ifndef PICO_DEFAULT_SPI_TX_PIN +//#define PICO_DEFAULT_SPI_TX_PIN 19 +//#endif +//#ifndef PICO_DEFAULT_SPI_RX_PIN +//#define PICO_DEFAULT_SPI_RX_PIN 16 +//#endif +//#ifndef PICO_DEFAULT_SPI_CSN_PIN +//#define PICO_DEFAULT_SPI_CSN_PIN 17 +//#endif + +#ifndef CYW43_PIN_WL_HOST_WAKE +#define CYW43_PIN_WL_HOST_WAKE 19 /*24*/ +#endif + +#ifndef CYW43_PIN_WL_REG_ON +#define CYW43_PIN_WL_REG_ON 16 /*23*/ +#endif + +// --- FLASH --- +#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 + +#ifndef PICO_FLASH_SPI_CLKDIV +#define PICO_FLASH_SPI_CLKDIV 2 +#endif + +#ifndef PICO_FLASH_SIZE_BYTES +#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) +#endif + +// All boards have B1 RP2040 +#ifndef PICO_RP2040_B0_SUPPORTED +#define PICO_RP2040_B0_SUPPORTED 0 +#endif + +#endif \ No newline at end of file diff --git a/firmware/PIMORONI_YUKON_W/pins.csv b/firmware/PIMORONI_YUKON_W/pins.csv new file mode 100644 index 0000000..7c01821 --- /dev/null +++ b/firmware/PIMORONI_YUKON_W/pins.csv @@ -0,0 +1,70 @@ +SLOT1_FAST1,GPIO0 +SLOT1_FAST2,GPIO1 +SLOT1_FAST3,GPIO2 +SLOT1_FAST4,GPIO3 +SLOT1_SLOW1,EXT_GPIO3 +SLOT1_SLOW2,EXT_GPIO4 +SLOT1_SLOW3,EXT_GPIO5 +SLOT2_FAST1,GPIO4 +SLOT2_FAST2,GPIO5 +SLOT2_FAST3,GPIO6 +SLOT2_FAST4,GPIO7 +SLOT2_SLOW1,EXT_GPIO0 +SLOT2_SLOW2,EXT_GPIO1 +SLOT2_SLOW3,EXT_GPIO2 +SLOT3_FAST1,GPIO8 +SLOT3_FAST2,GPIO9 +SLOT3_FAST3,GPIO10 +SLOT3_FAST4,GPIO11 +SLOT3_SLOW1,EXT_GPIO8 +SLOT3_SLOW2,EXT_GPIO9 +SLOT3_SLOW3,EXT_GPIO10 +SLOT4_FAST1,GPIO12 +SLOT4_FAST2,GPIO13 +SLOT4_FAST3,GPIO14 +SLOT4_FAST4,GPIO15 +SLOT4_SLOW1,EXT_GPIO23 +SLOT4_SLOW2,EXT_GPIO21 +SLOT4_SLOW3,EXT_GPIO22 +SLOT5_FAST1,GPIO16 +SLOT5_FAST2,GPIO17 +SLOT5_FAST3,GPIO18 +SLOT5_FAST4,GPIO19 +SLOT5_SLOW1,EXT_GPIO31 +SLOT5_SLOW2,EXT_GPIO30 +SLOT5_SLOW3,EXT_GPIO29 +SLOT6_FAST1,GPIO20 +SLOT6_FAST2,GPIO21 +SLOT6_FAST3,GPIO22 +SLOT6_FAST4,GPIO23 +SLOT6_SLOW1,EXT_GPIO26 +SLOT6_SLOW2,EXT_GPIO28 +SLOT6_SLOW3,EXT_GPIO27 +SDA,GPIO24 +SCL,GPIO25 +EX_I2C_SDA,GPIO26 +EX_SPI_SCK,GPIO26 +GP26_A0,GPIO26 +GP26,GPIO26 +A0,GPIO26 +EX_I2C_SCL,GPIO27 +EX_SPI_MOSI,GPIO27 +GP27_A1,GPIO27 +GP27,GPIO27 +A1,GPIO27 +INT,GPIO28 +SHARED_ADC,GPIO29 +MAIN_EN,EXT_GPIO6 +USER_SW,EXT_GPIO7 +ADC_ADDR_1,EXT_GPIO12 +ADC_ADDR_2,EXT_GPIO13 +ADC_ADDR_3,EXT_GPIO14 +ADC_MUX_EN_1,EXT_GPIO15 +ADC_MUX_EN_2,EXT_GPIO11 +SW_A,EXT_GPIO17 +SW_B,EXT_GPIO18 +LED_A,EXT_GPIO19 +LED_B,EXT_GPIO20 +LCD_BL,EXT_GPIO16 +LCD_DC,EXT_GPIO24 +LCD_CS,EXT_GPIO25 \ No newline at end of file diff --git a/firmware/PIMORONI_YUKON_W/uf2-manifest.txt b/firmware/PIMORONI_YUKON_W/uf2-manifest.txt new file mode 100644 index 0000000..97a3c54 --- /dev/null +++ b/firmware/PIMORONI_YUKON_W/uf2-manifest.txt @@ -0,0 +1,5 @@ +../*.py +../lib/*.py +../lib/pimoroni_yukon/*.py +../lib/pimoroni_yukon/devices/*.py +../lib/pimoroni_yukon/modules/*.py \ No newline at end of file From 287825fec624ab98fa4bafca3a0a77e7ab8b136c Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Mon, 9 Dec 2024 14:36:18 +0000 Subject: [PATCH 02/13] Include W build in CI --- .github/workflows/micropython.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 44069a3..aaaa7a1 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -64,6 +64,9 @@ jobs: - name: Yukon shortname: yukon board: PIMORONI_YUKON + - name: Yukon W + shortname: yukon_w + board: PIMORONI_YUKON_W env: RELEASE_FILE: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython @@ -71,7 +74,7 @@ jobs: BOARD_DIR: "$GITHUB_WORKSPACE/yukon/firmware/${{matrix.board}}" FILESYSTEM_DIR: "$GITHUB_WORKSPACE/yukon/lib" FILESYSTEM_SUFFIX: "with-filesystem" - BOARD: "PIMORONI_YUKON" + BOARD: ${{matrix.board}} steps: - name: Compiler Cache From d8d9075763058db0e0e52eba14aa57184a46eec5 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Mon, 9 Dec 2024 15:46:25 +0000 Subject: [PATCH 03/13] Actually change the wireless pins --- .github/workflows/micropython.yml | 6 ++++++ firmware/yukon_wireless.patch | 36 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 firmware/yukon_wireless.patch diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index aaaa7a1..6d2af4f 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -138,6 +138,12 @@ jobs: working-directory: micropython run: git apply "${{env.FIRMWARE_DIR}}/yukon_expander.patch" + - name: "HACK: Yukon Wireless Patch" + if: matrix.shortname == 'yukon_w' + shell: bash + working-directory: micropython/lib/pico-sdk + run: git apply "${{env.FIRMWARE_DIR}}/yukon_wireless.patch" + - name: Install Arm GNU Toolchain (arm-none-eabi-gcc) uses: carlosperate/arm-none-eabi-gcc-action@v1 with: diff --git a/firmware/yukon_wireless.patch b/firmware/yukon_wireless.patch new file mode 100644 index 0000000..d3f849e --- /dev/null +++ b/firmware/yukon_wireless.patch @@ -0,0 +1,36 @@ +diff --git a/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c b/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c +index 5afe85e..c22084c 100644 +--- a/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c ++++ b/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c +@@ -20,22 +20,23 @@ + #include "cyw43_debug_pins.h" + + #if CYW43_SPI_PIO +-#define WL_REG_ON 23 +-#define DATA_OUT_PIN 24u +-#define DATA_IN_PIN 24u +-#define IRQ_PIN 24u ++#define WL_REG_ON 16u /*23*/ ++#define DATA_OUT_PIN 19u /*24u*/ ++#define DATA_IN_PIN 19u /*24u*/ ++#define IRQ_PIN 19u /*24u*/ + // #define MONITOR_PIN 3u +-#define CLOCK_PIN 29u +-#define CS_PIN 25u ++#define CLOCK_PIN 18u /*29u*/ ++#define CS_PIN 17u /*25u*/ + #define IRQ_SAMPLE_DELAY_NS 100 + +-#define SPI_PROGRAM_NAME spi_gap01_sample0 ++//#define SPI_PROGRAM_NAME spi_gap01_sample0 ++#define SPI_PROGRAM_NAME spi_gap0_sample1 // for lower cpu speed + #define SPI_PROGRAM_FUNC __CONCAT(SPI_PROGRAM_NAME, _program) + #define SPI_PROGRAM_GET_DEFAULT_CONFIG_FUNC __CONCAT(SPI_PROGRAM_NAME, _program_get_default_config) + #define SPI_OFFSET_END __CONCAT(SPI_PROGRAM_NAME, _offset_end) + #define SPI_OFFSET_LP1_END __CONCAT(SPI_PROGRAM_NAME, _offset_lp1_end) + +-#define CLOCK_DIV 2 ++#define CLOCK_DIV 8 + #define CLOCK_DIV_MINOR 0 + #define PADS_DRIVE_STRENGTH PADS_BANK0_GPIO0_DRIVE_VALUE_12MA + From 07a23a15ae75bfcfa81aef86d40b9ee4ae552dfa Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Mon, 9 Dec 2024 16:14:18 +0000 Subject: [PATCH 04/13] Reduced Yukon usable flash to allow for "seamless" switching to W build --- firmware/PIMORONI_YUKON/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/PIMORONI_YUKON/mpconfigboard.h b/firmware/PIMORONI_YUKON/mpconfigboard.h index 5f46555..68455d7 100644 --- a/firmware/PIMORONI_YUKON/mpconfigboard.h +++ b/firmware/PIMORONI_YUKON/mpconfigboard.h @@ -1,6 +1,6 @@ // This is a hack! Need to replace with upstream board definition. #define MICROPY_HW_BOARD_NAME "Pimoroni Yukon" -#define MICROPY_HW_FLASH_STORAGE_BYTES (15 * 1024 * 1024) +#define MICROPY_HW_FLASH_STORAGE_BYTES (14160 * 1024) #define MICROPY_HW_USB_VID (0x2E8A) #define MICROPY_HW_USB_PID (0x105B) From 8fb6c6444099ac81235e7bc7a4b288e0d72b4af2 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Thu, 12 Dec 2024 15:04:24 +0000 Subject: [PATCH 05/13] Add WirelessModule class --- lib/pimoroni_yukon/modules/__init__.py | 6 +++-- lib/pimoroni_yukon/modules/rm2_wireless.py | 31 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 lib/pimoroni_yukon/modules/rm2_wireless.py diff --git a/lib/pimoroni_yukon/modules/__init__.py b/lib/pimoroni_yukon/modules/__init__.py index 6c429e9..fd2b8d8 100644 --- a/lib/pimoroni_yukon/modules/__init__.py +++ b/lib/pimoroni_yukon/modules/__init__.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2023 Christopher Parrott for Pimoroni Ltd +# SPDX-FileCopyrightText: 2025 Christopher Parrott for Pimoroni Ltd # # SPDX-License-Identifier: MIT @@ -12,6 +12,7 @@ from .quad_servo_direct import QuadServoDirectModule from .quad_servo_reg import QuadServoRegModule from .serial_servo import SerialServoModule +from .rm2_wireless import WirelessModule KNOWN_MODULES = ( @@ -24,4 +25,5 @@ ProtoPotModule, QuadServoDirectModule, QuadServoRegModule, - SerialServoModule) + SerialServoModule, + WirelessModule) diff --git a/lib/pimoroni_yukon/modules/rm2_wireless.py b/lib/pimoroni_yukon/modules/rm2_wireless.py new file mode 100644 index 0000000..f504047 --- /dev/null +++ b/lib/pimoroni_yukon/modules/rm2_wireless.py @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: 2025 Christopher Parrott for Pimoroni Ltd +# +# SPDX-License-Identifier: MIT + +from .common import YukonModule, ADC_LOW, ADC_FLOAT, IO_LOW, IO_HIGH + + +class WirelessModule(YukonModule): + NAME = "RM2 Wireless" + + # | ADC1 | ADC2 | SLOW1 | SLOW2 | SLOW3 | Module | Condition (if any) | + # |-------|-------|-------|-------|-------|----------------------|-----------------------------| + # | LOW | FLOAT | 1 | 0 | 1 | RM2 Wireless | | + @staticmethod + def is_module(adc1_level, adc2_level, slow1, slow2, slow3): + return adc1_level == ADC_LOW and adc2_level == ADC_FLOAT and slow1 is IO_HIGH and slow2 is IO_LOW and slow3 is IO_HIGH + + def __init__(self): + super().__init__() + + try: + import network + except ImportError: + raise RuntimeError("This build does not contain wireless networking support. Please flash your Yukon with a build that supports wireless in order to use this module.") + + def initialise(self, slot, adc1_func, adc2_func): + if slot.ID != 5: + raise RuntimeError("Currently the wireless module is only supported in Slot 5. Please relocate your module.") + + # Pass the slot and adc functions up to the parent now that module specific initialisation has finished + super().initialise(slot, adc1_func, adc2_func) From dc26b9a1029114a8c5f8ddf183612520b84eb426 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Mon, 16 Dec 2024 14:42:50 +0000 Subject: [PATCH 06/13] Updated documentation for RM2 Wireless --- README.md | 1 + docs/module_detection.md | 6 ++- docs/modules/rm2_wireless.md | 76 ++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 docs/modules/rm2_wireless.md diff --git a/README.md b/README.md index 354243e..53b0637 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ To take Yukon further, the full API for the library is described in the followin * [Docs: LED Strip Module](/docs/modules/led_strip.md) * [Docs: Quad Servo Direct Module](/docs/modules/quad_servo_direct.md) * [Docs: Quad Servo Regulated Module](/docs/modules/quad_servo_reg.md) +* [Docs: RM2 Wireless Module](/docs/modules/rm2_wireless.md) * [Docs: Serial Bus Servo Module](/docs/modules/serial_servo.md) * [Docs: Yukon Module](/docs/modules/yukon_module.md) * [Docs: Custom Module](/docs/modules/custom_module.md) diff --git a/docs/module_detection.md b/docs/module_detection.md index 34f4a86..0490d63 100644 --- a/docs/module_detection.md +++ b/docs/module_detection.md @@ -253,9 +253,11 @@ Here is the current address list for Yukon modules produced by Pimoroni. LOWLOW101Reserved - - LOWFLOAT101Reserved + + + LOWFLOAT101RM2 Wireless + LOWHIGH101Reserved diff --git a/docs/modules/rm2_wireless.md b/docs/modules/rm2_wireless.md new file mode 100644 index 0000000..0a8e931 --- /dev/null +++ b/docs/modules/rm2_wireless.md @@ -0,0 +1,76 @@ +# RM2 Wireless Module - Library Reference + +This is the library reference for the [RM2 Wireless Module for Yukon](https://pimoroni.com/yukon). + +- [Getting Started](#getting-started) +- [Initialising the Module](#initialising-the-module) +- [Reference](#reference) + - [Constants](#constants) + - [Functions](#functions) + + +**:information-source: Wireless is a baked-in feature of MicroPython, so the normal import and initialisation steps for Yukon modules are not strictly required to get your project online. There are still some advantages to doing these though, so the steps are explained below.** + +## Getting Started + +To start using a Wireless Module, you first need to import the class from `pimoroni_yukon.modules`. + +```python +from pimoroni_yukon.modules import WirelessModule +``` + +Then create an instance of `WirelessModule`. This will also confirm that you have a wireless capable build flashed to your Yukon. + +```python +module = WirelessModule() +``` + + +## Initialising the Module + +As with all Yukon modules, `WirelessModule` must be initialised before it can be used. This is achieved by first registering the module with the `Yukon` class, with the slot it is attached to. + +```python +from pimoroni_yukon import SLOT5 as SLOT # Only SLOT5 supports the RM2 Wireless Module at present + +# Import and set up Yukon and WirelessModule instances + +yukon.register_with_slot(module, SLOT) +``` + +Then `Yukon` can verify and initialise its modules. + +```python +yukon.verify_and_initialise() +``` + +This checks each slot on the board to see if the modules expected by your program are physically attached to the board. Only if they match will the `WirelessModule` be initialised. + +The RM2 Wireless Module is now ready to use. It can be interacted with using Micropython's `network` libraries, see Raspberry Pi's [Pico W tutorial](https://projects.raspberrypi.org/en/projects/get-started-pico-w/2). + +From here you can optionally provide power to all your other modules by calling. +```python +yukon.enable_main_output() +``` + + +## Reference + +### Constants + +```python +NAME = "RM2 Wireless" +``` + + +### Functions + +```python +# Address Checking +@staticmethod +is_module(adc1_level: int, adc2_level: int, slow1: bool, slow2: bool, slow3: bool) -> bool + +# Initialisation +WirelessModule() +initialise(slot: SLOT, adc1_func: Callable, adc2_func: Callable) -> None +``` From 94a486c4c77990d3b6c96335a81b1aa6b7e6b348 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Mon, 16 Dec 2024 14:48:21 +0000 Subject: [PATCH 07/13] Added extra ignore condition for linting --- .github/workflows/python-linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml index 0f97d32..0e85169 100644 --- a/.github/workflows/python-linting.yml +++ b/.github/workflows/python-linting.yml @@ -22,4 +22,4 @@ jobs: - name: Lint Yukon Python Libraries shell: bash run: | - python3 -m flake8 --show-source --ignore E501,E201,E241,E222,E116,E266 lib/ \ No newline at end of file + python3 -m flake8 --show-source --ignore E501,E201,E241,E222,E116,E266,F401 lib/ \ No newline at end of file From 5d976a72e3c927a7cc9e5897a90677b9d2d9ce7b Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Mon, 16 Dec 2024 15:59:28 +0000 Subject: [PATCH 08/13] Added cheerlights wireless example --- examples/wireless/README.md | 14 ++++ examples/wireless/cheerlights.py | 106 +++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 examples/wireless/README.md create mode 100644 examples/wireless/cheerlights.py diff --git a/examples/wireless/README.md b/examples/wireless/README.md new file mode 100644 index 0000000..251684e --- /dev/null +++ b/examples/wireless/README.md @@ -0,0 +1,14 @@ +# Yukon Micropython Wireless Examples + +This folder contains a collection of *Wireless* examples, that combine the RM2 Wireless Module with others to create functional projects. + +- [Cheerlights](#cheerlights) + + +## Cheerlights + +[cheerlights.py](cheerlights.py) + +Obtain the current CheerLights colour from the internet and show it on an LED Strip connected to Yukon. 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. \ No newline at end of file diff --git a/examples/wireless/cheerlights.py b/examples/wireless/cheerlights.py new file mode 100644 index 0000000..374e4a2 --- /dev/null +++ b/examples/wireless/cheerlights.py @@ -0,0 +1,106 @@ +import time +import network +import requests +from pimoroni_yukon import Yukon +from pimoroni_yukon import SLOT2 as STRIP_SLOT +from pimoroni_yukon import SLOT5 as RM2_SLOT +from pimoroni_yukon.modules import LEDStripModule, WirelessModule + + +""" +Obtain the current CheerLights colour from the internet and show it on an LED Strip connected to Yukon. +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. + +Hold "Boot" to exit the program (can take up to 5 seconds). +""" + +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: + raise ImportError("no module named 'secrets'. Create a 'secrets.py' file on your device with your WiFi credentials") + + +# 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 +STRIP_TYPE = LEDStripModule.NEOPIXEL # Change to LEDStripModule.DOTSTAR for APA102 style strips + # Two Neopixel strips can be driven too, by using LEDStripModule.DUAL_NEOPIXEL +STRIP_PIO = 0 # The PIO system to use (0 or 1) to drive the strip(s) +STRIP_SM = 0 # The State Machines (SM) to use to drive the strip(s) +LEDS_PER_STRIP = 60 # How many LEDs are on the strip. If using DUAL_NEOPIXEL this can be a single value or a list or tuple +BRIGHTNESS = 1.0 # The max brightness of the LEDs (only supported by APA102s) + +# Variables +yukon = Yukon() # Create a new Yukon object +leds = LEDStripModule(STRIP_TYPE, # Create a LEDStripModule object, with the details of the attached strip(s) + STRIP_PIO, + STRIP_SM, + LEDS_PER_STRIP, + BRIGHTNESS) +wireless = WirelessModule() # Create a WirelessModule object + + +# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) +try: + yukon.register_with_slot(leds, STRIP_SLOT) # Register the LEDStripModule object with the slot + yukon.register_with_slot(wireless, RM2_SLOT) # Register the WirelessModule object with the slot + yukon.verify_and_initialise() # Verify that the modules are attached to Yukon, and initialise them + + wlan = network.WLAN(network.STA_IF) # Create a new network object for interacting with WiFi + wlan.active(True) # Turn on WLAN communications + + # Connect to WLAN + print(f"Connecting to network '{WIFI_SSID}'") + 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]}') + + # Turn on power to the module slots and the LED strip + yukon.enable_main_output() + leds.enable() + + # Loop until the BOOT/USER button is pressed + while not yukon.is_boot_pressed(): + + # 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)) + + # Print out the Cheerlights colour + for i in range(len(colour)): + print(f"{COLOUR_NAMES[i]} = {colour[i]}", end=", ") + print() + + # Apply the colour to all the LEDs and send them to the strip + for led in range(leds.strip.num_leds()): + leds.strip.set_rgb(led, *colour) + leds.strip.update() + + # Monitor sensors for a number of seconds, recording the min, max, and average for each + yukon.monitored_sleep(REQUEST_INTERVAL) + + +finally: + # Put the board back into a safe state, regardless of how the program may have ended + yukon.reset() + + # Attempt to disconnect from WiFi + try: + wlan.disconnect() + except Exception: + pass From 816228ebfe4496289f8ca5a3723595f6177ba76c Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Mon, 16 Dec 2024 16:35:49 +0000 Subject: [PATCH 09/13] Added basic wireless module examples --- examples/modules/rm2_wireless/README.md | 33 +++++++++++++ .../rm2_wireless}/cheerlights.py | 3 +- .../modules/rm2_wireless/detect_module.py | 25 ++++++++++ examples/modules/rm2_wireless/wifi_scan.py | 49 +++++++++++++++++++ examples/wireless/README.md | 14 ------ 5 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 examples/modules/rm2_wireless/README.md rename examples/{wireless => modules/rm2_wireless}/cheerlights.py (98%) create mode 100644 examples/modules/rm2_wireless/detect_module.py create mode 100644 examples/modules/rm2_wireless/wifi_scan.py delete mode 100644 examples/wireless/README.md diff --git a/examples/modules/rm2_wireless/README.md b/examples/modules/rm2_wireless/README.md new file mode 100644 index 0000000..2b61310 --- /dev/null +++ b/examples/modules/rm2_wireless/README.md @@ -0,0 +1,33 @@ +# RM2 Wireless Module - Micropython Examples + + + +These are micropython examples for the [RM2 Wireless Module for Yukon](https://shop.pimoroni.com/products/rm2-wireless-module-for-yukon). + +- [Examples](#examples) + - [Detect Module](#detect-module) + - [WiFi Scan](#wifi-scan) + - [Cheerlights](#cheerlights) + + +## Examples + +### Detect Module +[detect_module.py](detect_module.py) + +A boilerplate example showing how to detect if the RM2 Wireless Module is attached to Yukon prior to performing any wireless operations. + + +### WiFi Scan +[wifi_scan.py](wifi_scan.py) + +Periodically scan for available WiFi networks using a RM2 Wireless Module connected to Slot 5, and print out their details. + + +### Cheerlights + +[cheerlights.py](cheerlights.py) + +Obtain the current CheerLights colour from the internet and show it on an LED Strip connected to Yukon. 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. \ No newline at end of file diff --git a/examples/wireless/cheerlights.py b/examples/modules/rm2_wireless/cheerlights.py similarity index 98% rename from examples/wireless/cheerlights.py rename to examples/modules/rm2_wireless/cheerlights.py index 374e4a2..41d9483 100644 --- a/examples/wireless/cheerlights.py +++ b/examples/modules/rm2_wireless/cheerlights.py @@ -1,4 +1,3 @@ -import time import network import requests from pimoroni_yukon import Yukon @@ -61,7 +60,7 @@ # Wait until the connection is established while not wlan.isconnected(): print('Waiting for connection...') - time.sleep(CONNECTION_INTERVAL) + yukon.monitored_sleep(CONNECTION_INTERVAL) # Print out our IP address print(f'Connected on {wlan.ifconfig()[0]}') diff --git a/examples/modules/rm2_wireless/detect_module.py b/examples/modules/rm2_wireless/detect_module.py new file mode 100644 index 0000000..0ef71b3 --- /dev/null +++ b/examples/modules/rm2_wireless/detect_module.py @@ -0,0 +1,25 @@ +from pimoroni_yukon import Yukon +from pimoroni_yukon import SLOT5 as SLOT +from pimoroni_yukon.modules import WirelessModule + +""" +A boilerplate example showing how to detect if the RM2 Wireless Module +is attached to Yukon prior to performing any wireless operations. +""" + +# Variables +yukon = Yukon() # Create a new Yukon object, with a lower voltage limit set +module = WirelessModule() # Create a WirelessModule object + +# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) +try: + yukon.register_with_slot(module, SLOT) # Register the WirelessModule object with the slot + yukon.verify_and_initialise() # Verify that a WirelessModule is attached to Yukon, and initialise it + + # Do wireless things here + +finally: + # Put the board back into a safe state, regardless of how the program may have ended + yukon.reset() + + # Disconnect from wireless here diff --git a/examples/modules/rm2_wireless/wifi_scan.py b/examples/modules/rm2_wireless/wifi_scan.py new file mode 100644 index 0000000..f820fa8 --- /dev/null +++ b/examples/modules/rm2_wireless/wifi_scan.py @@ -0,0 +1,49 @@ +import network +import binascii +from pimoroni_yukon import Yukon +from pimoroni_yukon import SLOT5 as SLOT +from pimoroni_yukon.modules import WirelessModule + +""" +Periodically scan for available WiFi networks using a RM2 Wireless Module connected to Slot 5, +and print out their details. + +Hold "Boot" to exit the program (can take up to 5 seconds). +""" + +# Constants +SCAN_INTERVAL = 5.0 # The time to sleep between each network scan + +# Variables +yukon = Yukon() # Create a new Yukon object, with a lower voltage limit set +module = WirelessModule() # Create a WirelessModule object + + +# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) +try: + yukon.register_with_slot(module, SLOT) # Register the WirelessModule object with the slot + yukon.verify_and_initialise() # Verify that a WirelessModule is attached to Yukon, and initialise it + + wlan = network.WLAN(network.STA_IF) # Create a new network object for interacting with WiFi + wlan.active(True) # Turn on WLAN communications + + while not yukon.is_boot_pressed(): + # Scan for nearby networks and print them out + networks = wlan.scan() # Returns a list of tuples with 6 fields: ssid, bssid, channel, RSSI, security, hidden + for i, w in enumerate(networks): + print(i, w[0].decode(), binascii.hexlify(w[1]).decode(), + w[2], w[3], w[4], w[5]) + print() + + # Monitor sensors for a number of seconds, recording the min, max, and average for each + yukon.monitored_sleep(SCAN_INTERVAL) + +finally: + # Put the board back into a safe state, regardless of how the program may have ended + yukon.reset() + + # Attempt to disconnect from WiFi + try: + wlan.disconnect() + except Exception: + pass diff --git a/examples/wireless/README.md b/examples/wireless/README.md deleted file mode 100644 index 251684e..0000000 --- a/examples/wireless/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Yukon Micropython Wireless Examples - -This folder contains a collection of *Wireless* examples, that combine the RM2 Wireless Module with others to create functional projects. - -- [Cheerlights](#cheerlights) - - -## Cheerlights - -[cheerlights.py](cheerlights.py) - -Obtain the current CheerLights colour from the internet and show it on an LED Strip connected to Yukon. 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. \ No newline at end of file From 18e3d9a0ee6326c46bcbb81ce81c05ec466f37b8 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Mon, 16 Dec 2024 16:47:14 +0000 Subject: [PATCH 10/13] Attempt to increase wireless speed --- firmware/yukon_wireless.patch | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/firmware/yukon_wireless.patch b/firmware/yukon_wireless.patch index d3f849e..a8b8812 100644 --- a/firmware/yukon_wireless.patch +++ b/firmware/yukon_wireless.patch @@ -1,8 +1,8 @@ diff --git a/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c b/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c -index 5afe85e..c22084c 100644 +index 5afe85e..75547ee 100644 --- a/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c +++ b/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c -@@ -20,22 +20,23 @@ +@@ -20,13 +20,13 @@ #include "cyw43_debug_pins.h" #if CYW43_SPI_PIO @@ -21,16 +21,4 @@ index 5afe85e..c22084c 100644 +#define CS_PIN 17u /*25u*/ #define IRQ_SAMPLE_DELAY_NS 100 --#define SPI_PROGRAM_NAME spi_gap01_sample0 -+//#define SPI_PROGRAM_NAME spi_gap01_sample0 -+#define SPI_PROGRAM_NAME spi_gap0_sample1 // for lower cpu speed - #define SPI_PROGRAM_FUNC __CONCAT(SPI_PROGRAM_NAME, _program) - #define SPI_PROGRAM_GET_DEFAULT_CONFIG_FUNC __CONCAT(SPI_PROGRAM_NAME, _program_get_default_config) - #define SPI_OFFSET_END __CONCAT(SPI_PROGRAM_NAME, _offset_end) - #define SPI_OFFSET_LP1_END __CONCAT(SPI_PROGRAM_NAME, _offset_lp1_end) - --#define CLOCK_DIV 2 -+#define CLOCK_DIV 8 - #define CLOCK_DIV_MINOR 0 - #define PADS_DRIVE_STRENGTH PADS_BANK0_GPIO0_DRIVE_VALUE_12MA - + #define SPI_PROGRAM_NAME spi_gap01_sample0 From 64e1dc657e4e9368751de6ebbeb1dc443f528c15 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Mon, 16 Dec 2024 17:11:38 +0000 Subject: [PATCH 11/13] Bump version and name updates --- firmware/PIMORONI_YUKON/board.json | 2 +- firmware/PIMORONI_YUKON/mpconfigboard.h | 2 +- firmware/PIMORONI_YUKON_W/board.json | 2 +- firmware/PIMORONI_YUKON_W/mpconfigboard.h | 4 ++-- lib/pimoroni_yukon/__init__.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/firmware/PIMORONI_YUKON/board.json b/firmware/PIMORONI_YUKON/board.json index e0b0c0c..fdbdeb9 100644 --- a/firmware/PIMORONI_YUKON/board.json +++ b/firmware/PIMORONI_YUKON/board.json @@ -8,7 +8,7 @@ "images": [ ], "mcu": "rp2040", - "product": "Pimoroni Yukon", + "product": "Pimoroni Yukon (no Wireless)", "thumbnail": "", "url": "https://shop.pimoroni.com/products/yukon", "vendor": "Pimoroni" diff --git a/firmware/PIMORONI_YUKON/mpconfigboard.h b/firmware/PIMORONI_YUKON/mpconfigboard.h index 68455d7..be2b070 100644 --- a/firmware/PIMORONI_YUKON/mpconfigboard.h +++ b/firmware/PIMORONI_YUKON/mpconfigboard.h @@ -1,5 +1,5 @@ // This is a hack! Need to replace with upstream board definition. -#define MICROPY_HW_BOARD_NAME "Pimoroni Yukon" +#define MICROPY_HW_BOARD_NAME "Pimoroni Yukon (no Wireless)" #define MICROPY_HW_FLASH_STORAGE_BYTES (14160 * 1024) #define MICROPY_HW_USB_VID (0x2E8A) diff --git a/firmware/PIMORONI_YUKON_W/board.json b/firmware/PIMORONI_YUKON_W/board.json index cbd5892..02feff1 100644 --- a/firmware/PIMORONI_YUKON_W/board.json +++ b/firmware/PIMORONI_YUKON_W/board.json @@ -8,7 +8,7 @@ "images": [ ], "mcu": "rp2040", - "product": "Pimoroni Yukon W", + "product": "Pimoroni Yukon (+ Wireless)", "thumbnail": "", "url": "https://shop.pimoroni.com/products/yukon", "vendor": "Pimoroni" diff --git a/firmware/PIMORONI_YUKON_W/mpconfigboard.h b/firmware/PIMORONI_YUKON_W/mpconfigboard.h index ddbee02..0c54f78 100644 --- a/firmware/PIMORONI_YUKON_W/mpconfigboard.h +++ b/firmware/PIMORONI_YUKON_W/mpconfigboard.h @@ -1,5 +1,5 @@ // This is a hack! Need to replace with upstream board definition. -#define MICROPY_HW_BOARD_NAME "Pimoroni Yukon W" +#define MICROPY_HW_BOARD_NAME "Pimoroni Yukon (+ Wireless)" #define MICROPY_HW_FLASH_STORAGE_BYTES (14160 * 1024) #define MICROPY_HW_USB_VID (0x2E8A) @@ -20,7 +20,7 @@ // Enable networking. #define MICROPY_PY_NETWORK 1 -#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "YukonW" +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Yukon" // CYW43 driver configuration. #define CYW43_USE_SPI (1) diff --git a/lib/pimoroni_yukon/__init__.py b/lib/pimoroni_yukon/__init__.py index 1e41bdb..17ce07a 100644 --- a/lib/pimoroni_yukon/__init__.py +++ b/lib/pimoroni_yukon/__init__.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2023 Christopher Parrott for Pimoroni Ltd +# SPDX-FileCopyrightText: 2025 Christopher Parrott for Pimoroni Ltd # # SPDX-License-Identifier: MIT @@ -15,7 +15,7 @@ from ucollections import OrderedDict, namedtuple -YUKON_VERSION = "1.0.2" +YUKON_VERSION = "1.0.3" Slot = namedtuple("Slot", ("ID", "FAST1", From de3b0e577dfb0a5d59963cd394328f05133a5cd1 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Tue, 17 Dec 2024 12:52:05 +0000 Subject: [PATCH 12/13] Rename wireless module for clarity --- docs/modules/rm2_wireless.md | 16 ++++++++-------- examples/modules/rm2_wireless/cheerlights.py | 6 +++--- examples/modules/rm2_wireless/detect_module.py | 10 +++++----- examples/modules/rm2_wireless/wifi_scan.py | 12 ++++++------ lib/pimoroni_yukon/modules/__init__.py | 6 +++--- lib/pimoroni_yukon/modules/rm2_wireless.py | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/modules/rm2_wireless.md b/docs/modules/rm2_wireless.md index 0a8e931..0701290 100644 --- a/docs/modules/rm2_wireless.md +++ b/docs/modules/rm2_wireless.md @@ -13,27 +13,27 @@ This is the library reference for the [RM2 Wireless Module for Yukon](https://pi ## Getting Started -To start using a Wireless Module, you first need to import the class from `pimoroni_yukon.modules`. +To start using a RM2 Wireless Module, you first need to import the class from `pimoroni_yukon.modules`. ```python -from pimoroni_yukon.modules import WirelessModule +from pimoroni_yukon.modules import RM2WirelessModule ``` -Then create an instance of `WirelessModule`. This will also confirm that you have a wireless capable build flashed to your Yukon. +Then create an instance of `RM2WirelessModule`. This will also confirm that you have a wireless capable build flashed to your Yukon. ```python -module = WirelessModule() +module = RM2WirelessModule() ``` ## Initialising the Module -As with all Yukon modules, `WirelessModule` must be initialised before it can be used. This is achieved by first registering the module with the `Yukon` class, with the slot it is attached to. +As with all Yukon modules, `RM2WirelessModule` must be initialised before it can be used. This is achieved by first registering the module with the `Yukon` class, with the slot it is attached to. ```python from pimoroni_yukon import SLOT5 as SLOT # Only SLOT5 supports the RM2 Wireless Module at present -# Import and set up Yukon and WirelessModule instances +# Import and set up Yukon and RM2WirelessModule instances yukon.register_with_slot(module, SLOT) ``` @@ -44,7 +44,7 @@ Then `Yukon` can verify and initialise its modules. yukon.verify_and_initialise() ``` -This checks each slot on the board to see if the modules expected by your program are physically attached to the board. Only if they match will the `WirelessModule` be initialised. +This checks each slot on the board to see if the modules expected by your program are physically attached to the board. Only if they match will the `RM2WirelessModule` be initialised. The RM2 Wireless Module is now ready to use. It can be interacted with using Micropython's `network` libraries, see Raspberry Pi's [Pico W tutorial](https://projects.raspberrypi.org/en/projects/get-started-pico-w/2). @@ -71,6 +71,6 @@ NAME = "RM2 Wireless" is_module(adc1_level: int, adc2_level: int, slow1: bool, slow2: bool, slow3: bool) -> bool # Initialisation -WirelessModule() +RM2WirelessModule() initialise(slot: SLOT, adc1_func: Callable, adc2_func: Callable) -> None ``` diff --git a/examples/modules/rm2_wireless/cheerlights.py b/examples/modules/rm2_wireless/cheerlights.py index 41d9483..47ee95e 100644 --- a/examples/modules/rm2_wireless/cheerlights.py +++ b/examples/modules/rm2_wireless/cheerlights.py @@ -3,7 +3,7 @@ from pimoroni_yukon import Yukon from pimoroni_yukon import SLOT2 as STRIP_SLOT from pimoroni_yukon import SLOT5 as RM2_SLOT -from pimoroni_yukon.modules import LEDStripModule, WirelessModule +from pimoroni_yukon.modules import LEDStripModule, RM2WirelessModule """ @@ -41,13 +41,13 @@ STRIP_SM, LEDS_PER_STRIP, BRIGHTNESS) -wireless = WirelessModule() # Create a WirelessModule object +wireless = RM2WirelessModule() # Create a RM2WirelessModule object # Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) try: yukon.register_with_slot(leds, STRIP_SLOT) # Register the LEDStripModule object with the slot - yukon.register_with_slot(wireless, RM2_SLOT) # Register the WirelessModule object with the slot + yukon.register_with_slot(wireless, RM2_SLOT) # Register the RM2WirelessModule object with the slot yukon.verify_and_initialise() # Verify that the modules are attached to Yukon, and initialise them wlan = network.WLAN(network.STA_IF) # Create a new network object for interacting with WiFi diff --git a/examples/modules/rm2_wireless/detect_module.py b/examples/modules/rm2_wireless/detect_module.py index 0ef71b3..967ec2d 100644 --- a/examples/modules/rm2_wireless/detect_module.py +++ b/examples/modules/rm2_wireless/detect_module.py @@ -1,6 +1,6 @@ from pimoroni_yukon import Yukon from pimoroni_yukon import SLOT5 as SLOT -from pimoroni_yukon.modules import WirelessModule +from pimoroni_yukon.modules import RM2WirelessModule """ A boilerplate example showing how to detect if the RM2 Wireless Module @@ -8,13 +8,13 @@ """ # Variables -yukon = Yukon() # Create a new Yukon object, with a lower voltage limit set -module = WirelessModule() # Create a WirelessModule object +yukon = Yukon() # Create a new Yukon object, with a lower voltage limit set +module = RM2WirelessModule() # Create a RM2WirelessModule object # Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) try: - yukon.register_with_slot(module, SLOT) # Register the WirelessModule object with the slot - yukon.verify_and_initialise() # Verify that a WirelessModule is attached to Yukon, and initialise it + yukon.register_with_slot(module, SLOT) # Register the RM2WirelessModule object with the slot + yukon.verify_and_initialise() # Verify that a RM2WirelessModule is attached to Yukon, and initialise it # Do wireless things here diff --git a/examples/modules/rm2_wireless/wifi_scan.py b/examples/modules/rm2_wireless/wifi_scan.py index f820fa8..26208bf 100644 --- a/examples/modules/rm2_wireless/wifi_scan.py +++ b/examples/modules/rm2_wireless/wifi_scan.py @@ -2,7 +2,7 @@ import binascii from pimoroni_yukon import Yukon from pimoroni_yukon import SLOT5 as SLOT -from pimoroni_yukon.modules import WirelessModule +from pimoroni_yukon.modules import RM2WirelessModule """ Periodically scan for available WiFi networks using a RM2 Wireless Module connected to Slot 5, @@ -12,17 +12,17 @@ """ # Constants -SCAN_INTERVAL = 5.0 # The time to sleep between each network scan +SCAN_INTERVAL = 5.0 # The time to sleep between each network scan # Variables -yukon = Yukon() # Create a new Yukon object, with a lower voltage limit set -module = WirelessModule() # Create a WirelessModule object +yukon = Yukon() # Create a new Yukon object, with a lower voltage limit set +module = RM2WirelessModule() # Create a RM2WirelessModule object # Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) try: - yukon.register_with_slot(module, SLOT) # Register the WirelessModule object with the slot - yukon.verify_and_initialise() # Verify that a WirelessModule is attached to Yukon, and initialise it + yukon.register_with_slot(module, SLOT) # Register the RM2WirelessModule object with the slot + yukon.verify_and_initialise() # Verify that a RM2WirelessModule is attached to Yukon, and initialise it wlan = network.WLAN(network.STA_IF) # Create a new network object for interacting with WiFi wlan.active(True) # Turn on WLAN communications diff --git a/lib/pimoroni_yukon/modules/__init__.py b/lib/pimoroni_yukon/modules/__init__.py index fd2b8d8..5f6308e 100644 --- a/lib/pimoroni_yukon/modules/__init__.py +++ b/lib/pimoroni_yukon/modules/__init__.py @@ -11,8 +11,8 @@ from .proto import ProtoPotModule from .quad_servo_direct import QuadServoDirectModule from .quad_servo_reg import QuadServoRegModule +from .rm2_wireless import RM2WirelessModule from .serial_servo import SerialServoModule -from .rm2_wireless import WirelessModule KNOWN_MODULES = ( @@ -25,5 +25,5 @@ ProtoPotModule, QuadServoDirectModule, QuadServoRegModule, - SerialServoModule, - WirelessModule) + RM2WirelessModule, + SerialServoModule) diff --git a/lib/pimoroni_yukon/modules/rm2_wireless.py b/lib/pimoroni_yukon/modules/rm2_wireless.py index f504047..dea6ec1 100644 --- a/lib/pimoroni_yukon/modules/rm2_wireless.py +++ b/lib/pimoroni_yukon/modules/rm2_wireless.py @@ -5,7 +5,7 @@ from .common import YukonModule, ADC_LOW, ADC_FLOAT, IO_LOW, IO_HIGH -class WirelessModule(YukonModule): +class RM2WirelessModule(YukonModule): NAME = "RM2 Wireless" # | ADC1 | ADC2 | SLOW1 | SLOW2 | SLOW3 | Module | Condition (if any) | From 90683fea215ce152ec7bd83c3bde05b742e0b03f Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Tue, 17 Dec 2024 13:01:47 +0000 Subject: [PATCH 13/13] Make build name clearer --- .github/workflows/micropython.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 6d2af4f..4640df6 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -65,7 +65,7 @@ jobs: shortname: yukon board: PIMORONI_YUKON - name: Yukon W - shortname: yukon_w + shortname: yukon+wireless board: PIMORONI_YUKON_W env: