File tree Expand file tree Collapse file tree 5 files changed +98
-0
lines changed Expand file tree Collapse file tree 5 files changed +98
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ add_subdirectory(pio)
85
85
add_subdirectory (pwm )
86
86
add_subdirectory (reset )
87
87
add_subdirectory (rtc )
88
+ add_subdirectory (status_led )
88
89
add_subdirectory (spi )
89
90
add_subdirectory (system )
90
91
add_subdirectory (timer )
Original file line number Diff line number Diff line change @@ -371,6 +371,13 @@ App|Description
371
371
[ max7219_8x7seg_spi] ( spi/max7219_8x7seg_spi ) | Attaching a Max7219 driving an 8 digit 7 segment display via SPI.
372
372
[ max7219_32x8_spi] ( spi/max7219_32x8_spi ) | Attaching a Max7219 driving an 32x8 LED display via SPI.
373
373
374
+ ### Status Led
375
+
376
+ App|Description
377
+ ---|---
378
+ [ status_blink] ( status_led ) | Blink the onboard LED using the status LED API.
379
+ [ color_blink] ( status_led ) | Blink the onboard colored (WS2812) LED using the status LED API if supported by the board.
380
+
374
381
### System
375
382
376
383
App|Description
Original file line number Diff line number Diff line change
1
+ # Blink the "status" LED connected to the GPIO defined by PICO_DEFAULT_LED_PIN for your board
2
+ add_executable (status_blink
3
+ status_blink.c
4
+ )
5
+ # You can define PICO_DEFAULT_LED_PIN yourself to add a led to a different GPIO
6
+ #target_compile_definitions(status_blink PRIVATE
7
+ # PICO_DEFAULT_LED_PIN=15
8
+ #)
9
+ target_link_libraries (status_blink
10
+ pico_stdlib
11
+ pico_status_led
12
+ )
13
+ pico_add_extra_outputs (status_blink )
14
+ example_auto_set_url (status_blink )
15
+
16
+ # Blink the colored "status" LED connected to the GPIO defined by PICO_DEFAULT_WS2812_PIN for your board
17
+ add_executable (color_blink
18
+ color_blink.c
19
+ )
20
+ # You can define PICO_DEFAULT_WS2812_PIN yourself to add a WS2812 led to a normal GPIO
21
+ target_compile_definitions (color_blink PRIVATE
22
+ PICO_DEFAULT_WS2812_PIN=16
23
+ )
24
+ target_link_libraries (color_blink
25
+ pico_stdlib
26
+ pico_status_led
27
+ )
28
+ pico_add_extra_outputs (color_blink )
29
+ example_auto_set_url (color_blink )
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) 2025 Raspberry Pi (Trading) Ltd.
3
+ *
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+
7
+ #include "pico/stdlib.h"
8
+ #include "pico/status_led.h"
9
+
10
+ #if !PICO_COLORED_STATUS_LED_AVAILABLE
11
+ #warning The color_blink example requires a board with a WS2812 LED
12
+ #endif
13
+
14
+ #ifndef LED_DELAY_MS
15
+ #define LED_DELAY_MS 250
16
+ #endif
17
+
18
+ int main () {
19
+ bool rc = status_led_init ();
20
+ hard_assert (rc );
21
+ hard_assert (colored_status_led_supported ()); // This assert fails if your board does not have WS2812 support
22
+ uint32_t count = 0 ;
23
+ while (true) {
24
+ // flash red then green then blue
25
+ uint32_t color = PICO_COLORED_STATUS_LED_COLOR_FROM_RGB (count % 3 == 0 ? 0xaa : 0 , count % 3 == 1 ? 0xaa : 0 , count % 3 == 2 ? 0xaa : 0 );
26
+ colored_status_led_set_on_with_color (color );
27
+ count ++ ;
28
+ sleep_ms (LED_DELAY_MS );
29
+ assert (colored_status_led_get_state ());
30
+ colored_status_led_set_state (false);
31
+ sleep_ms (LED_DELAY_MS );
32
+ assert (!colored_status_led_get_state ());
33
+ }
34
+ status_led_deinit ();
35
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) 2025 Raspberry Pi (Trading) Ltd.
3
+ *
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+
7
+ #include "pico/stdlib.h"
8
+ #include "pico/status_led.h"
9
+
10
+ #ifndef LED_DELAY_MS
11
+ #define LED_DELAY_MS 250
12
+ #endif
13
+
14
+ int main () {
15
+ bool rc = status_led_init ();
16
+ hard_assert (rc );
17
+ while (true) {
18
+ status_led_set_state (true);
19
+ sleep_ms (LED_DELAY_MS );
20
+ assert (status_led_get_state ());
21
+ status_led_set_state (false);
22
+ sleep_ms (LED_DELAY_MS );
23
+ assert (!status_led_get_state ());
24
+ }
25
+ status_led_deinit ();
26
+ }
You can’t perform that action at this time.
0 commit comments