picofuse

led.h
Go to the documentation of this file.
1 
47 #pragma once
48 #include "gpio.h"
49 #include "pwm.h"
50 #include <picofuse/pix/color.h>
51 #include <stdint.h>
52 
54 // CONSTANTS
55 
60 #define HW_LED_GPIO_NONE 0xFFu
61 
68 #ifndef HW_LED_POOL_CAPACITY
69 #define HW_LED_POOL_CAPACITY 8u
70 #endif
71 
85 #ifndef HW_LED_CONTEXT_SIZE
86 #define HW_LED_CONTEXT_SIZE 32
87 #endif
88 
90 // TYPES
91 
96 typedef enum {
102 } hw_led_type_t;
103 
109 typedef struct hw_led_t hw_led_t;
110 
112 // LIFECYCLE
113 
124 
132 hw_led_t *hw_led_init_neopixel(hw_gpio_t *gpio, uint8_t led_count);
133 
140 
150 
164 hw_led_t *hw_led_init_device(const char *name);
165 
177 
183 void hw_led_deinit(hw_led_t *led);
184 
187 // PROPERTIES
189 
205 uint8_t hw_led_gpio_default(hw_led_type_t *out_type, uint8_t *out_count);
206 
209 // METHODS
211 
224 bool hw_led_set(hw_led_t *led, uint8_t index, bool enabled);
225 
240 bool hw_led_set_brightness(hw_led_t *led, uint8_t index, float percent);
241 
264 bool hw_led_set_color(hw_led_t *led, uint8_t index, pix_color_t color);
265 
276 bool hw_led_clear(hw_led_t *led);
277 
310 bool hw_led_blink(hw_led_t *led, uint8_t index, uint32_t period_ms,
311  bool repeating);
312 
No default board LED is available.
Definition: led.h:97
struct hw_led_t hw_led_t
Opaque LED handle.
Definition: led.h:109
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.
uint32_t pix_color_t
Color value type for pixel operations.
Definition: color.h:17
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.
bool hw_led_set_color(hw_led_t *led, uint8_t index, pix_color_t color)
Set LED color.
LED is a directly controlled GPIO pin.
Definition: led.h:100
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:101
RGBA color type and helpers.
LED is a WS2812/NeoPixel data pin.
Definition: led.h:99
LED is controlled through CYW43 Wi-Fi GPIO.
Definition: led.h:98
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:96
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.