loading date/time via SNTP
Signed-off-by: Peter Siegmund <peter@rdkr.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
#include "mapView.h"
|
||||
|
||||
#include <esp_task_wdt.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include "epd_driver.h"
|
||||
#include "fonts/opensans12b.h"
|
||||
#include "fonts/opensans26b.h"
|
||||
#include "fonts/opensans6.h"
|
||||
#include "staticmap.h"
|
||||
@@ -52,29 +55,39 @@ void mapView(void* args) {
|
||||
|
||||
std::memset(framebuffer, 0xFF, EPD_WIDTH * EPD_HEIGHT / 2);
|
||||
|
||||
int32_t width = staticmap_width;
|
||||
int32_t height = staticmap_height;
|
||||
const uint8_t* data = staticmap_data;
|
||||
|
||||
Rect_t area = {
|
||||
.x = EPD_WIDTH - width, .y = 0, .width = width, .height = height};
|
||||
epd_copy_to_framebuffer(area, (uint8_t*)data, framebuffer);
|
||||
epd_draw_rect(area.x, area.y, area.width, area.height, 0, framebuffer);
|
||||
|
||||
int32_t x = area.x / 2;
|
||||
int32_t y = area.height / 2 - 26;
|
||||
currentFont = OpenSans26B;
|
||||
drawString(x, y, "Hello, World!", CENTER);
|
||||
|
||||
drawVessel(EPD_WIDTH - EPD_WIDTH / 4, EPD_HEIGHT - EPD_HEIGHT / 5,
|
||||
"DEEPENSCHRIEWER 1");
|
||||
|
||||
epd_poweron();
|
||||
epd_clear();
|
||||
epd_draw_grayscale_image(epd_full_screen(), framebuffer);
|
||||
epd_poweroff_all();
|
||||
|
||||
while (1) {
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
int32_t width = staticmap_width;
|
||||
int32_t height = staticmap_height;
|
||||
const uint8_t* data = staticmap_data;
|
||||
|
||||
Rect_t area = {
|
||||
.x = EPD_WIDTH - width, .y = 0, .width = width, .height = height};
|
||||
epd_copy_to_framebuffer(area, (uint8_t*)data, framebuffer);
|
||||
epd_draw_rect(area.x, area.y, area.width, area.height, 0, framebuffer);
|
||||
|
||||
int32_t x = area.x / 2;
|
||||
int32_t y = 26;
|
||||
currentFont = OpenSans26B;
|
||||
drawString(x, y, "Tide Display", CENTER);
|
||||
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
char strftime_buf[64];
|
||||
|
||||
currentFont = OpenSans12B;
|
||||
time(&now);
|
||||
localtime_r(&now, &timeinfo);
|
||||
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
|
||||
drawString(6, area.height - 33, strftime_buf, LEFT);
|
||||
|
||||
drawVessel(EPD_WIDTH - EPD_WIDTH / 4, EPD_HEIGHT - EPD_HEIGHT / 5,
|
||||
"DEEPENSCHRIEWER 1");
|
||||
|
||||
epd_poweron();
|
||||
epd_clear();
|
||||
epd_draw_grayscale_image(epd_full_screen(), framebuffer);
|
||||
epd_poweroff_all();
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(60000));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user