This commit is contained in:
Matthias Mitscherlich
2023-02-01 13:08:13 +01:00
parent 0c644d404c
commit bc0da9ec9e
3 changed files with 76 additions and 24 deletions
+63 -16
View File
@@ -49,6 +49,7 @@
#define RMT_LED_STRIP_RESOLUTION_HZ 10000000 // 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
#define RMT_LED_STRIP_GPIO_NUM 0
#define RMT_LED_STRIP_GPIO_AUX 1
// --------------------------------------------------------------------------------------------------------------------
@@ -80,17 +81,34 @@ static rmt_encoder_handle_t led_encoder = NULL;
static LEDMatrix_Parameters_t ledmatrix_parameters =
{
LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT,
LEDMATRIX_ORIENTATION_COLUM_DOWN_UP,
LEDMATRIX_ORIENTATION_COLUM,
11,
10,
LEDMATRIX_ORIENTATION_COLUM_UP_DOWN,
LEDMATRIX_ORIENTATION_ROW,
6,
4,
&led_chan,
&led_encoder,
&tx_config
};
static LEDMatrix LEDMatrix(&ledmatrix_parameters);
static Wordmap map(&LEDMatrix);
static rmt_channel_handle_t led_aux_chan = NULL;
static rmt_transmit_config_t tx_aux_config;
static rmt_encoder_handle_t led_aux_encoder = NULL;
static LEDMatrix_Parameters_t ledmatrix_aux_parameters =
{
LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT,
LEDMATRIX_ORIENTATION_COLUM_DOWN_UP,
LEDMATRIX_ORIENTATION_COLUM,
11,
10,
&led_aux_chan,
&led_aux_encoder,
&tx_aux_config
};
static LEDMatrix matrix(&ledmatrix_parameters);
static LEDMatrix aux(&ledmatrix_aux_parameters);
static Wordmap map(&matrix);
static gptimer_handle_t matrixRefreshTimer = NULL;
@@ -183,10 +201,39 @@ extern "C" void app_main(void)
tx_config.loop_count = 0;
//--------------------------------------------
// RMT Channel
//
LOGGER_INFO("Create RMT TX channel");
// memset(&tx_chan_config, 0, sizeof(tx_chan_config));
// tx_chan_config.clk_src = RMT_CLK_SRC_DEFAULT; // select source clock
// tx_chan_config.gpio_num = RMT_LED_STRIP_GPIO_AUX;
// tx_chan_config.mem_block_symbols = 64; // increase the block size can make the LED less flickering
// tx_chan_config.resolution_hz = RMT_LED_STRIP_RESOLUTION_HZ;
// tx_chan_config.trans_queue_depth = 4;
// ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &led_aux_chan));
// LOGGER_INFO("Install led strip encoder");
// led_strip_encoder_config_t encoder_aux_config;
// memset(&encoder_aux_config, 0, sizeof(encoder_aux_config));
// encoder_config.resolution = RMT_LED_STRIP_RESOLUTION_HZ;
// ESP_ERROR_CHECK(rmt_new_led_strip_encoder(&encoder_aux_config, &led_aux_encoder));
// LOGGER_INFO("Enable RMT TX channel");
// ESP_ERROR_CHECK(rmt_enable(led_chan));
// memset(&tx_config, 0, sizeof(tx_config));
// tx_config.loop_count = 0;
//--------------------------------------------
// LED Matrix
//
LEDMatrix.setGlobalColour(0x10, 0, 0x04);
matrix.setGlobalColour(0x10, 0, 0x04);
matrix.setGlobalColour(0x80, 0, 0x40);
//--------------------------------------------
// GP Timer for automatic matrix re-draw trigger
@@ -216,11 +263,11 @@ extern "C" void app_main(void)
LOGGER_ERROR("Task not created");
}
// Create the colour Map task
if(xTaskCreate(colourMapTask, "ColourTask", 2048, NULL, 3, &colourMapTaskHandle) != pdPASS)
{
LOGGER_ERROR("Task not created");
}
// // Create the colour Map task
// if(xTaskCreate(colourMapTask, "ColourTask", 2048, NULL, 3, &colourMapTaskHandle) != pdPASS)
// {
// LOGGER_ERROR("Task not created");
// }
Wifi wifi;
wifi.start_client();
@@ -235,7 +282,7 @@ extern "C" void app_main(void)
{
clock.generateWordlist(&wordlist);
LEDMatrix.clear();
matrix.clear();
std::list<string>::iterator it;
for(it = wordlist.begin(); it != wordlist.end(); it++)
{
@@ -243,7 +290,7 @@ extern "C" void app_main(void)
}
// Add a seconds indicator
LEDMatrix.setPixelValue(10, 9, clock.getTime() % 2);
matrix.setPixelValue(10, 9, clock.getTime() % 2);
// Update the clock every second (1000 ms)
vTaskDelay(1000);
@@ -276,7 +323,7 @@ static void colourMapTask(void* parameters)
while (true)
{
LEDMatrix.setGlobalColour(red, green, blue);
matrix.setGlobalColour(red, green, blue);
red = counter & 0xFF;
green = (counter >> 8) & 0xFF;
@@ -325,7 +372,7 @@ static bool IRAM_ATTR timerCallback(gptimer_handle_t timer, const gptimer_alarm_
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xHigherPriorityTaskWoken = LEDMatrix.tick();
xHigherPriorityTaskWoken = matrix.tick();
return xHigherPriorityTaskWoken == pdTRUE;
}