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_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_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 = static LEDMatrix_Parameters_t ledmatrix_parameters =
{ {
LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT, LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT,
LEDMATRIX_ORIENTATION_COLUM_DOWN_UP, LEDMATRIX_ORIENTATION_COLUM_UP_DOWN,
LEDMATRIX_ORIENTATION_COLUM, LEDMATRIX_ORIENTATION_ROW,
11, 6,
10, 4,
&led_chan, &led_chan,
&led_encoder, &led_encoder,
&tx_config &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; static gptimer_handle_t matrixRefreshTimer = NULL;
@@ -183,10 +201,39 @@ extern "C" void app_main(void)
tx_config.loop_count = 0; 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 // 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 // GP Timer for automatic matrix re-draw trigger
@@ -216,11 +263,11 @@ extern "C" void app_main(void)
LOGGER_ERROR("Task not created"); LOGGER_ERROR("Task not created");
} }
// Create the colour Map task // // Create the colour Map task
if(xTaskCreate(colourMapTask, "ColourTask", 2048, NULL, 3, &colourMapTaskHandle) != pdPASS) // if(xTaskCreate(colourMapTask, "ColourTask", 2048, NULL, 3, &colourMapTaskHandle) != pdPASS)
{ // {
LOGGER_ERROR("Task not created"); // LOGGER_ERROR("Task not created");
} // }
Wifi wifi; Wifi wifi;
wifi.start_client(); wifi.start_client();
@@ -235,7 +282,7 @@ extern "C" void app_main(void)
{ {
clock.generateWordlist(&wordlist); clock.generateWordlist(&wordlist);
LEDMatrix.clear(); matrix.clear();
std::list<string>::iterator it; std::list<string>::iterator it;
for(it = wordlist.begin(); it != wordlist.end(); it++) for(it = wordlist.begin(); it != wordlist.end(); it++)
{ {
@@ -243,7 +290,7 @@ extern "C" void app_main(void)
} }
// Add a seconds indicator // 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) // Update the clock every second (1000 ms)
vTaskDelay(1000); vTaskDelay(1000);
@@ -276,7 +323,7 @@ static void colourMapTask(void* parameters)
while (true) while (true)
{ {
LEDMatrix.setGlobalColour(red, green, blue); matrix.setGlobalColour(red, green, blue);
red = counter & 0xFF; red = counter & 0xFF;
green = (counter >> 8) & 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; BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xHigherPriorityTaskWoken = LEDMatrix.tick(); xHigherPriorityTaskWoken = matrix.tick();
return xHigherPriorityTaskWoken == pdTRUE; return xHigherPriorityTaskWoken == pdTRUE;
} }
+9 -4
View File
@@ -54,7 +54,7 @@
Clock::Clock(Clock::mode mode) Clock::Clock(Clock::mode mode)
{ {
Clock::currentTime = 0; Clock::currentTime = 40000;
Clock::clockmode = mode; Clock::clockmode = mode;
@@ -71,6 +71,7 @@ void Clock::generateWordlist(list<string>* wordlist)
struct tm tm; struct tm tm;
time(&currentTime); time(&currentTime);
// currentTime += 100;
localtime_r(&currentTime, &tm); localtime_r(&currentTime, &tm);
LOGGER_INFO("%lld\n\r", currentTime); LOGGER_INFO("%lld\n\r", currentTime);
@@ -157,7 +158,7 @@ void Clock::generateWordlist(list<string>* wordlist)
time_t Clock::getTime(void) time_t Clock::getTime(void)
{ {
time(&currentTime); // time(&currentTime);
return currentTime; return currentTime;
} }
@@ -172,11 +173,15 @@ int Clock::calculateHours(struct tm time)
} }
// Calculate hours to 12hour system // Calculate hours to 12hour system
if (time.tm_hour > 12) if (hours > 12)
{ {
hours = hours - 12; hours = hours - 12;
} }
// Start at 1, not 0
if (hours == 0)
{
hours++;
}
return hours; return hours;
} }
+4 -4
View File
@@ -48,10 +48,10 @@
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
static const char* ssid = "Kowalski"; //static const char* ssid = "Kowalski";
static const char* pass = "madagascar"; //static const char* pass = "madagascar";
//static const char* ssid = "vbchaos"; static const char* ssid = "vbchaos";
//static const char* pass = "mijninternet"; static const char* pass = "mijninternet";
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
// Function declarations // Function declarations