Added clock and wordclock - functional

the matrix needs an update, though. Not all words are well put
This commit is contained in:
Matthias Mitscherlich
2023-01-18 14:54:23 +01:00
parent 1ae7d6ec5a
commit 7cb84d1660
8 changed files with 667 additions and 25 deletions
+13 -20
View File
@@ -1,11 +1,11 @@
#include "string.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_sntp.h"
#include "esp_wifi.h"
#include "time.h"
#include "nvs_flash.h"
@@ -19,12 +19,14 @@
#include "inc/logger.h"
#include "inc/wifi.h"
#include "clock.h"
#include "wordclock.h"
static const uart_port_t uartPort = UART_NUM_0;
static TaskHandle_t devTaskHandle = NULL;
static void devTask(void* parameters);
static GPIO gpio0(4, GPIO_DIRECTION_OUTPUT);
static GPIO gpio1(18, GPIO_DIRECTION_OUTPUT);
static time_t currentTime;
static rmt_channel_handle_t led_chan = NULL;
static rmt_transmit_config_t tx_config;
@@ -113,6 +115,8 @@ extern "C" void app_main(void)
ledmatrix_parameters.width = 11;
LEDMatrix LEDMatrix(&ledmatrix_parameters);
// Set an initial colour map
LEDMatrix.setGlobalColour(0x10, 0, 0x04);
// Create the development task
if(xTaskCreate(devTask, "DevTask", 2048, NULL, 3, &devTaskHandle) != pdPASS)
@@ -123,28 +127,17 @@ extern "C" void app_main(void)
Wifi wifi;
wifi.start_client();
// Start NTP
setenv("TZ", "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00", 1);
tzset();
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_setservername(0, "pool.ntp.org");
sntp_init();
Clock clock;
Clock::TimeStructure time;
unsigned int row = 0;
unsigned int colum = 0;
Wordclock wordclock(&LEDMatrix);
while (true)
{
time = clock.updateTime();
wordclock.update(&time);
struct tm tm;
time(&currentTime);
localtime_r(&currentTime, &tm);
LOGGER_INFO("%lld\n\r", currentTime);
LOGGER_INFO("%02i:%02i:%02i\n\r", tm.tm_hour, tm.tm_min, tm.tm_sec);
vTaskDelay(300);
vTaskDelay(1000);
}
}