picofuse

led.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include "gpio.h"
9 #include "pwm.h"
10 #include <stdint.h>
11 
13 // CONSTANTS
14 
19 #define HW_LED_GPIO_NONE 0xFFu
20 
27 #ifndef HW_LED_POOL_CAPACITY
28 #define HW_LED_POOL_CAPACITY 8u
29 #endif
30 
44 #ifndef HW_LED_CONTEXT_SIZE
45 #define HW_LED_CONTEXT_SIZE 32
46 #endif
47 
49 // TYPES
50 
55 typedef enum {
62 
68 typedef struct hw_led_t hw_led_t;
69 
71 // LIFECYCLE
72 
83 
91 hw_led_t *hw_led_init_neopixel(hw_gpio_t *gpio, uint8_t led_count);
92 
99 
109 
123 hw_led_t *hw_led_init_device(const char *name);
124 
136 
142 void hw_led_deinit(hw_led_t *led);
143 
146 // PROPERTIES
148 
164 uint8_t hw_led_gpio_default(hw_led_type_t *out_type, uint8_t *out_count);
165 
168 // METHODS
170 
183 bool hw_led_set(hw_led_t *led, uint8_t index, bool enabled);
184 
199 bool hw_led_set_brightness(hw_led_t *led, uint8_t index, float percent);
200 
211 bool hw_led_clear(hw_led_t *led);
212 
229 bool hw_led_blink(hw_led_t *led, uint8_t index, uint32_t period_ms,
230  bool repeating);
231 
No default board LED is available.
Definition: led.h:56
struct hw_led_t hw_led_t
Opaque LED handle.
Definition: led.h:68
PWM (Pulse Width Modulation) interface.
struct hw_pwm_t hw_pwm_t
Opaque PWM handle.
Definition: pwm.h:58
struct hw_gpio_t hw_gpio_t
GPIO logical pin structure.
Definition: gpio.h:50
hw_led_t * hw_led_init_gpio(hw_gpio_t *gpio)
Initialize a direct GPIO LED.
GPIO (General Purpose Input/Output) interface.
hw_led_t * hw_led_init_device(const char *name)
Initialize an LED from a platform-specific device path or name.
bool hw_led_set(hw_led_t *led, uint8_t index, bool enabled)
Set LED state on or off.
bool hw_led_clear(hw_led_t *led)
Turn off all LED state, cancelling any active blink.
uint8_t hw_led_gpio_default(hw_led_type_t *out_type, uint8_t *out_count)
Return the default board LED&#39;s control pin.
bool hw_led_set_brightness(hw_led_t *led, uint8_t index, float percent)
Set LED brightness.
LED is a directly controlled GPIO pin.
Definition: led.h:59
hw_led_t * hw_led_init_default(void)
Initialize the default on-board LED.
LED is controlled through PWM on a GPIO pin.
Definition: led.h:60
LED is a WS2812/NeoPixel data pin.
Definition: led.h:58
LED is controlled through CYW43 Wi-Fi GPIO.
Definition: led.h:57
hw_led_t * hw_led_init_neopixel(hw_gpio_t *gpio, uint8_t led_count)
Initialize a NeoPixel/WS2812 LED data pin.
void hw_led_deinit(hw_led_t *led)
Deinitialize an LED handle.
hw_led_t * hw_led_init_wifi(void)
Initialize a Wi-Fi controlled LED.
hw_led_type_t
Default board LED access type.
Definition: led.h:55
hw_led_t * hw_led_init_pwm(hw_pwm_t *pwm)
Initialize a PWM controlled LED.
bool hw_led_blink(hw_led_t *led, uint8_t index, uint32_t period_ms, bool repeating)
Blink an LED using a timer.