From 4dec2714ad5e2a3e156ca79428d8e8bff5bd1942 Mon Sep 17 00:00:00 2001 From: Ahmad Mahmoudi <59058087+A404M@users.noreply.github.com> Date: Wed, 20 Aug 2025 20:18:47 +0000 Subject: [PATCH 1/2] Update CMakeLists.txt For pico 2 w support --- picoboard/button/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/picoboard/button/CMakeLists.txt b/picoboard/button/CMakeLists.txt index c3ef5d726..4e888eaa9 100644 --- a/picoboard/button/CMakeLists.txt +++ b/picoboard/button/CMakeLists.txt @@ -3,7 +3,7 @@ add_executable(picoboard_button ) # pull in common dependencies -target_link_libraries(picoboard_button pico_stdlib) +target_link_libraries(picoboard_button pico_stdlib pico_status_led) # create map/bin/hex file etc. pico_add_extra_outputs(picoboard_button) From 0087ceb04c9cd0e9370ad996507915e40368667e Mon Sep 17 00:00:00 2001 From: Ahmad Mahmoudi <59058087+A404M@users.noreply.github.com> Date: Wed, 20 Aug 2025 20:25:32 +0000 Subject: [PATCH 2/2] Update button.c Add support for pico 2 w --- picoboard/button/button.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/picoboard/button/button.c b/picoboard/button/button.c index 527eaa246..8821d8680 100644 --- a/picoboard/button/button.c +++ b/picoboard/button/button.c @@ -6,6 +6,7 @@ #include #include "pico/stdlib.h" +#include "pico/status_led.h" #include "hardware/gpio.h" #include "hardware/sync.h" #include "hardware/structs/ioqspi.h" @@ -58,13 +59,16 @@ bool __no_inline_not_in_flash_func(get_bootsel_button)() { } int main() { -#ifndef PICO_DEFAULT_LED_PIN -#warning picoboard/button example requires a board with a regular LED +#ifndef PICO_STATUS_LED_AVAILABLE +#warning picoboard/button example requires a board with status LED #else - gpio_init(PICO_DEFAULT_LED_PIN); - gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); + int result = status_led_init(); + hard_assert(result); + result = status_led_supported(); + hard_assert(result); while (true) { - gpio_put(PICO_DEFAULT_LED_PIN, get_bootsel_button() ^ PICO_DEFAULT_LED_PIN_INVERTED); + result = status_led_set_state(get_bootsel_button()); + hard_assert(result); sleep_ms(10); } #endif