diff --git a/code/main/main.cpp b/code/main/main.cpp index 816add1..3b17f85 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -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::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; } diff --git a/code/main/src/clock.cpp b/code/main/src/clock.cpp index d24b129..aa226bc 100644 --- a/code/main/src/clock.cpp +++ b/code/main/src/clock.cpp @@ -54,7 +54,7 @@ Clock::Clock(Clock::mode mode) { - Clock::currentTime = 0; + Clock::currentTime = 40000; Clock::clockmode = mode; @@ -71,6 +71,7 @@ void Clock::generateWordlist(list* wordlist) struct tm tm; time(¤tTime); +// currentTime += 100; localtime_r(¤tTime, &tm); LOGGER_INFO("%lld\n\r", currentTime); @@ -157,7 +158,7 @@ void Clock::generateWordlist(list* wordlist) time_t Clock::getTime(void) { - time(¤tTime); +// time(¤tTime); return currentTime; } @@ -172,11 +173,15 @@ int Clock::calculateHours(struct tm time) } // Calculate hours to 12hour system - if (time.tm_hour > 12) + if (hours > 12) { hours = hours - 12; } - + // Start at 1, not 0 + if (hours == 0) + { + hours++; + } return hours; } diff --git a/code/main/src/wifi.cpp b/code/main/src/wifi.cpp index 9436f63..550a57f 100644 --- a/code/main/src/wifi.cpp +++ b/code/main/src/wifi.cpp @@ -48,10 +48,10 @@ // -------------------------------------------------------------------------------------------------------------------- -static const char* ssid = "Kowalski"; -static const char* pass = "madagascar"; -//static const char* ssid = "vbchaos"; -//static const char* pass = "mijninternet"; +//static const char* ssid = "Kowalski"; +//static const char* pass = "madagascar"; +static const char* ssid = "vbchaos"; +static const char* pass = "mijninternet"; // -------------------------------------------------------------------------------------------------------------------- // Function declarations