@web-font-path: "roboto-debian.css";
Loading...
Searching...
No Matches
pico_status_led

Enables access to the on-board status LED(s). More...

Macros

#define PICO_COLORED_STATUS_LED_COLOR_FROM_RGB(r, g, b)
 Generate an RGB color value for /ref colored_status_led_set_on_with_color.
#define PICO_COLORED_STATUS_LED_COLOR_FROM_WRGB(w, r, g, b)
 Generate an WRGB color value for colored_status_led_set_on_with_color.

Functions

bool status_led_init (void)
 Initialize the status LED(s).
bool status_led_init_with_context (struct async_context *context)
 Initialise the status LED(s).
static bool colored_status_led_supported (void)
 Determine if the colored_status_led_ APIs are supported (i.e. if there is a colored status LED, and its use isn't disabled via PICO_COLORED_STATUS_LED_AVAILABLE being set to 0.
static bool status_led_via_colored_status_led (void)
 Determine if the colored status LED is being used for the single-color status_led_ APIs.
static bool status_led_supported (void)
 Determine if the single-color status_led_ APIs are supported (i.e. if there is a regular LED, and its use isn't disabled via PICO_STATUS_LED_AVAILABLE being set to 0, or if the colored status LED is being used for the single-color status_led_ APIs.
bool colored_status_led_set_state (bool led_on)
 Set the colored status LED on or off.
bool colored_status_led_get_state (void)
 Get the state of the colored status LED.
bool colored_status_led_set_on_with_color (uint32_t color)
 Ensure the colored status LED is on, with the specified color.
uint32_t colored_status_led_get_on_color (void)
 Get the color used for the status LED value when it is on.
static bool status_led_set_state (bool led_on)
 Set the status LED on or off.
static bool status_led_get_state ()
 Get the state of the status LED.
void status_led_deinit ()
 De-initialize the status LED(s).

Detailed Description

Enables access to the on-board status LED(s).

Boards usually have access to one or two on-board status LEDs which are configured via the board header (PICO_DEFAULT_LED_PIN, CYW43_WL_GPIO_LED_PIN and/or PICO_DEFAULT_WS2812_PIN). This library hides the low-level details so you can use the status LEDs for all boards without changing your code.

Note
If your board has both a single-color LED and a colored LED, you can independently control the single-color LED with the status_led_ APIs, and the colored LED with the colored_status_led_ APIs

Macro Definition Documentation

◆ PICO_COLORED_STATUS_LED_COLOR_FROM_RGB

#define PICO_COLORED_STATUS_LED_COLOR_FROM_RGB ( r,
g,
b )
Value:
(((r) << 16) | ((g) << 8) | (b))

Generate an RGB color value for /ref colored_status_led_set_on_with_color.

◆ PICO_COLORED_STATUS_LED_COLOR_FROM_WRGB

#define PICO_COLORED_STATUS_LED_COLOR_FROM_WRGB ( w,
r,
g,
b )
Value:
(((w) << 24) | ((r) << 16) | ((g) << 8) | (b))

Generate an WRGB color value for colored_status_led_set_on_with_color.

Note
If your hardware does not support a white pixel, the white component is ignored

Function Documentation

◆ colored_status_led_get_on_color()

uint32_t colored_status_led_get_on_color ( void )

Get the color used for the status LED value when it is on.

Note
If your hardware does not support a colored status LED (PICO_DEFAULT_WS2812_PIN), this function always returns 0x0.
Returns
The color used for the colored status LED when it is on, in 0xWWRRGGBB format

◆ colored_status_led_get_state()

bool colored_status_led_get_state ( void )

Get the state of the colored status LED.

Note
If your hardware does not support a colored status LED (PICO_DEFAULT_WS2812_PIN), this function returns false.
Returns
true if the colored status LED is on, or false if the colored status LED is off

◆ colored_status_led_set_on_with_color()

bool colored_status_led_set_on_with_color ( uint32_t color)

Ensure the colored status LED is on, with the specified color.

Note
If your hardware does not support a colored status LED (PICO_DEFAULT_WS2812_PIN), this function does nothing and returns false.
Parameters
colorThe color to use for the colored status LED when it is on, in 0xWWRRGGBB format
Returns
true if the colored status LED could be set, otherwise false on failure

◆ colored_status_led_set_state()

bool colored_status_led_set_state ( bool led_on)

Set the colored status LED on or off.

Note
If your hardware does not support a colored status LED (PICO_DEFAULT_WS2812_PIN), this function does nothing and returns false.
Parameters
led_ontrue to turn the colored LED on. Pass false to turn the colored LED off
Returns
true if the colored status LED could be set, otherwise false

◆ colored_status_led_supported()

bool colored_status_led_supported ( void )
inlinestatic

Determine if the colored_status_led_ APIs are supported (i.e. if there is a colored status LED, and its use isn't disabled via PICO_COLORED_STATUS_LED_AVAILABLE being set to 0.

Returns
true if the colored status LED API is available and expected to produce visible results
See also
PICO_COLORED_STATUS_LED_AVAILABLE

◆ status_led_deinit()

void status_led_deinit ( )

De-initialize the status LED(s).

De-initializes the status LED(s) when they are no longer needed.

◆ status_led_get_state()

bool status_led_get_state ( )
inlinestatic

Get the state of the status LED.

Note
If your hardware does not support a status LED, this function always returns false.
Returns
true if the status LED is on, or false if the status LED is off

◆ status_led_init()

bool status_led_init ( void )

Initialize the status LED(s).

Initialize the status LED(s) and the resources they need before use. On some devices (e.g. Pico W, Pico 2 W) accessing the status LED requires talking to the WiFi chip, which requires an async_context. This method will create an async_context for you.

However an application should only use a single async_context instance to talk to the WiFi chip. If the application already has an async context (e.g. created by cyw43_arch_init) you should use status_led_init_with_context instead and pass it the async_context already created by your application

Note
You must call this function (or status_led_init_with_context) before using any other pico_status_led functions.
Returns
Returns true if the LED was initialized successfully, otherwise false on failure
See also
status_led_init_with_context

◆ status_led_init_with_context()

bool status_led_init_with_context ( struct async_context * context)

Initialise the status LED(s).

Initialize the status LED(s) and the resources they need before use.

Note
You must call this function (or status_led_init) before using any other pico_status_led functions.
Parameters
contextAn async_context used to communicate with the status LED (e.g. on Pico W or Pico 2 W)
Returns
Returns true if the LED was initialized successfully, otherwise false on failure
See also
status_led_init_with_context

◆ status_led_set_state()

bool status_led_set_state ( bool led_on)
inlinestatic

Set the status LED on or off.

Note
If your hardware does not support a status LED, this function does nothing and returns false.
Parameters
led_ontrue to turn the LED on. Pass false to turn the LED off
Returns
true if the status LED could be set, otherwise false

◆ status_led_supported()

bool status_led_supported ( void )
inlinestatic

Determine if the single-color status_led_ APIs are supported (i.e. if there is a regular LED, and its use isn't disabled via PICO_STATUS_LED_AVAILABLE being set to 0, or if the colored status LED is being used for the single-color status_led_ APIs.

Returns
true if the single-color status LED API is available and expected to produce visible results
See also
PICO_STATUS_LED_AVAILABLE
PICO_STATUS_LED_VIA_COLORED_STATUS_LED

◆ status_led_via_colored_status_led()

bool status_led_via_colored_status_led ( void )
inlinestatic

Determine if the colored status LED is being used for the single-color status_led_ APIs.

Returns
true if the colored status LED is being used for the single-color status_led_ API
See also
PICO_STATUS_LED_VIA_COLORED_STATUS_LED