Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 powerDownLed (void)
 Power down the LEDs.
 
void powerUpLed (void)
 Power up the 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.
 
const led_tgetLedState (void)
 Return a pointer to the current LED state, always of length CONFIG_NUM_LEDS
 
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

◆ powerDownLed()

void powerDownLed ( void )

Power down the LEDs.

◆ powerUpLed()

void powerUpLed ( void )

Power up the LEDs.

◆ 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()

const led_t * getLedState ( void )

Return a pointer to the current LED state, always of length CONFIG_NUM_LEDS

Returns
A pointer to the current LED state

◆ flushLeds()

void flushLeds ( void )

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