SRA Board Components
ESP-IDF component for SRA Board
Functions
led_matrix.c File Reference
#include "led_matrix.h"
#include "led_matrix_font.h"
Include dependency graph for led_matrix.c:

Functions

led_matrix led_matrix_init (void)
 Enables and configures the LED Matrix and corresponding shift registers. More...
 
led_matrix_data_t bool_to_uint32 (const led_matrix_data_arr_t input_arr)
 Converts a boolean array of size CONFIG_LED_MATRIX_ROWSxCONFIG_LED_MATRIX_COLUMNS to a 32-bit unsigned integer. More...
 
esp_err_t led_matrix_set_bit (led_matrix *matrix, const uint8_t logical_pin, const uint8_t led_value)
 Sets a single bit of the "data" field of the passed in matrix. More...
 
esp_err_t led_matrix_set_data (led_matrix *matrix, const led_matrix_data_t data)
 Sets all the bits of the "data" field of the passed in matrix using led_matrix_set_bit(). More...
 
esp_err_t led_matrix_set_data_raw (led_matrix *matrix, const led_matrix_data_t data)
 Sets all the bits of the "data" field. More...
 
esp_err_t led_matrix_write (const led_matrix *matrix, const led_matrix_output_mode_t mode)
 Performs the write from the led_matrix structure to the actual LEDs on board. More...
 
esp_err_t led_matrix_display_string (led_matrix *matrix, const char *message, double wait_ms)
 Displays the entered string character by character on the LED Matrix with a delay of "wait_ms" ms between characters. More...
 
esp_err_t led_matrix_cleanup (led_matrix matrix)
 Performs cleanup on the LED Matrix contents. More...
 

Function Documentation

◆ bool_to_uint32()

led_matrix_data_t bool_to_uint32 ( const led_matrix_data_arr_t  input_arr)

Converts a boolean array of size CONFIG_LED_MATRIX_ROWSxCONFIG_LED_MATRIX_COLUMNS to a 32-bit unsigned integer.

Parameters
input_arrBoolean input array of dimensions (CONFIG_LED_MATRIX_ROWS, CONFIG_LED_MATRIX_COLUMNS)
Returns
A 32-bit value representing the LED states, where each bit corresponds to one physical LED as defined by led_matrix_map.

◆ led_matrix_cleanup()

esp_err_t led_matrix_cleanup ( led_matrix  matrix)

Performs cleanup on the LED Matrix contents.

Parameters
matrixThe handle to represent and use the matrix of LEDs
Returns
Returns an error if there is an error while cleaning up the shift register, else returns ESP_OK

◆ led_matrix_display_string()

esp_err_t led_matrix_display_string ( led_matrix matrix,
const char *  message,
double  wait_ms 
)

Displays the entered string character by character on the LED Matrix with a delay of "wait_ms" ms between characters.

Parameters
matrixThe handle to represent and use the matrix of LEDs.
messageThe message to be displayed on the screen.
wait_msThe time to wait between two characters (in ms)
Returns
Returns an error if a NULL matrix or message is passed, else returns ESP_OK

◆ led_matrix_init()

led_matrix led_matrix_init ( void  )

Enables and configures the LED Matrix and corresponding shift registers.

Parameters
matrixThe handle to represent and use the matrix of LEDs.
Returns
Returns an error if the could not allocate enough memory or if shift register configuration failed, else returns ESP_OK

◆ led_matrix_set_bit()

esp_err_t led_matrix_set_bit ( led_matrix matrix,
const uint8_t  led_number,
const uint8_t  led_value 
)

Sets a single bit of the "data" field of the passed in matrix.

Parameters
matrixThe handle to represent and use the matrix of LEDs.
led_numberThe logical index of the pin (varies from [0, led_matrix_rows * led_matrix_columns - 1])
led_valueThe value to set the LED (can be 0 - LOW or 1 - HIGH)
Returns
Returns an error if a NULL matrix is passed or if the led number exceeds (led_matrix_rows * led_matrix_columns - 1), else returns ESP_OK

◆ led_matrix_set_data()

esp_err_t led_matrix_set_data ( led_matrix matrix,
const led_matrix_data_t  data 
)

Sets all the bits of the "data" field of the passed in matrix using led_matrix_set_bit().

Parameters
matrixThe handle to represent and use the matrix of LEDs.
dataThe data to write to the LED matrix.
Returns
Returns an error if a NULL matrix is passed, else returns ESP_OK

◆ led_matrix_set_data_raw()

esp_err_t led_matrix_set_data_raw ( led_matrix matrix,
const led_matrix_data_t  data 
)

Sets all the bits of the "data" field.

Parameters
matrixThe handle to represent and use the matrix of LEDs.
dataThe bitfield used to set the values of the LED matrix.
Returns
Returns an error if a NULL matrix is passed, else returns ESP_OK

◆ led_matrix_write()

esp_err_t led_matrix_write ( const led_matrix matrix,
const led_matrix_output_mode_t  mode 
)

Performs the write from the led_matrix structure to the actual LEDs on board.

Parameters
matrixThe handle to represent and use the matrix of LEDs.
modeThe way in which to display the values from the shift register.
Returns
Returns an error if a NULL matrix is passed, else returns ESP_OK