Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
hdw-led.c File Reference

Macros

#define RMT_LED_STRIP_RESOLUTION_HZ   10000000
 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
 

Functions

esp_err_t initLeds (gpio_num_t gpio, gpio_num_t gpioAlt, uint8_t brightness)
 Initialize the RGB LEDs.
 
esp_err_t deinitLeds (void)
 Deinitialize LEDs.
 
void setLedBrightness (uint8_t brightness)
 Set the global LED brightness. setLedBrightnessSetting() should be called instead if the new volume should be persistent through a reboot.
 
esp_err_t setLeds (led_t *leds, uint8_t numLeds)
 Set the RGB LEDs to the given values.
 
uint8_t getLedState (led_t *leds, uint8_t numLeds)
 Write the current LED state into the given array.
 
void flushLeds (void)
 Wait until any pending LED transactions are finished, then return.
 

Macro Definition Documentation

◆ RMT_LED_STRIP_RESOLUTION_HZ

#define RMT_LED_STRIP_RESOLUTION_HZ   10000000

10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)

Function Documentation

◆ initLeds()

esp_err_t initLeds ( gpio_num_t gpio,
gpio_num_t gpioAlt,
uint8_t brightness )

Initialize the RGB LEDs.

Parameters
gpioThe GPIO the LEDs are attached to
gpioAltA GPIO to mirror the LED output to
brightnessThe brightness to start the LEDs at
Returns
ESP_OK if the LEDs initialized, or a nonzero value if they did not

◆ deinitLeds()

esp_err_t deinitLeds ( void )

Deinitialize LEDs.

Returns
ESP_OK

◆ setLedBrightness()

void setLedBrightness ( uint8_t brightness)

Set the global LED brightness. setLedBrightnessSetting() should be called instead if the new volume should be persistent through a reboot.

Parameters
brightness0 (off) to MAX_LED_BRIGHTNESS (max bright)

◆ setLeds()

esp_err_t setLeds ( led_t * leds,
uint8_t numLeds )

Set the RGB LEDs to the given values.

Parameters
ledsA pointer to an array of led_t structs to set the LEDs to. The array must have at least numLeds elements
numLedsThe number of LEDs to set, probably CONFIG_NUM_LEDS
Returns
ESP_OK if the LEDs were set, or a nonzero value if they did were not

◆ getLedState()

uint8_t getLedState ( led_t * leds,
uint8_t numLeds )

Write the current LED state into the given array.

Parameters
[out]ledsThe LED array to write the state into
numLedsThe maximum number of LEDs to write
Returns
uint8_t The number of LEDs actually written to the array

◆ flushLeds()

void flushLeds ( void )

Wait until any pending LED transactions are finished, then return.