starting drawing text

- zlib from components
- framebuffer for faster drawing
- disable currently smartconfig

Signed-off-by: Peter Siegmund <peter@rdkr.com>
This commit is contained in:
Peter Siegmund
2024-06-06 21:56:47 +02:00
parent 3094274ad8
commit ca68e9786c
67 changed files with 49140 additions and 15496 deletions

View File

@@ -1,21 +1,62 @@
#include "mapView.h"
#include <esp_task_wdt.h>
#include <cstring>
#include <string>
#include "epd_driver.h"
#include "fonts/opensans26b.h"
#include "staticmap.h"
#include "utilities.h"
uint8_t* framebuffer;
GFXfont currentFont;
enum alignment { LEFT, RIGHT, CENTER };
void drawString(int32_t x, int32_t y, std::string text, alignment align) {
char* data = const_cast<char*>(text.c_str());
int32_t x1, y1; // the bounds of x,y and w and h of the variable 'text' in
// pixels.
int32_t w, h;
int32_t xx = x, yy = y;
get_text_bounds(&currentFont, data, &xx, &yy, &x1, &y1, &w, &h, NULL);
if (align == RIGHT)
x = x - w;
if (align == CENTER)
x = x - w / 2;
int32_t cursor_y = y + h;
write_string(&currentFont, data, &x, &cursor_y, framebuffer);
}
void mapView(void* args) {
framebuffer =
(uint8_t*)heap_caps_malloc(EPD_WIDTH * EPD_HEIGHT / 2, MALLOC_CAP_SPIRAM);
if (!framebuffer) {
printf("alloc memory failed !!!");
while (1) {
}
}
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);
epd_poweron();
epd_clear();
epd_draw_image(area, (uint8_t*)data, BLACK_ON_WHITE);
epd_draw_grayscale_image(epd_full_screen(), framebuffer);
epd_poweroff();
while (1) {