Phase 4: ST7789 240x320 panel (esp_lcd), 5x7 font, Core 1 UI task, streaming tjpgd JPEG decode + baked storage image

This commit is contained in:
2026-09-09 17:35:54 +02:00
parent ec1e7a0d5a
commit e09ec04946
15 changed files with 631 additions and 4 deletions

71
main/display_manager.h Normal file
View File

@@ -0,0 +1,71 @@
/*
* MTG RFID Companion - ST7789 display manager (Core 1)
*
* Phase 4: Initializes the ST7789 240x320 panel via esp_lcd as a device on
* the shared SPI2_HOST bus, provides RGB565 rendering primitives, glyph text,
* and streaming tjpgd JPEG decode into the panel.
*/
#pragma once
#include "esp_err.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define DISP_W (240)
#define DISP_H (320)
#define RGB565(r, g, b) ((uint16_t)((((r)&0xF8) << 8) | (((g)&0xFC) << 3) | (((b)&0xF8) >> 3)))
#define COLOR_BLACK RGB565(0, 0, 0)
#define COLOR_WHITE RGB565(255, 255, 255)
#define COLOR_RED RGB565(255, 0, 0)
#define COLOR_GREEN RGB565(0, 255, 0)
#define COLOR_BLUE RGB565(0, 0, 255)
#define COLOR_YELLOW RGB565(255, 255, 0)
#define COLOR_CYAN RGB565(0, 255, 255)
#define COLOR_MAGENTA RGB565(255, 0, 255)
#define COLOR_GRAY RGB565(128, 128, 128)
/**
* @brief Initialize the ST7789 panel. Requires the shared SPI bus to exist.
*/
esp_err_t display_manager_init(void);
/**
* @brief Fill the whole screen with a color.
*/
void display_fill(uint16_t color);
/**
* @brief Fill a rectangle. x1/y1 are exclusive.
*/
void display_fill_rect(int x0, int y0, int x1, int y1, uint16_t color);
/**
* @brief Draw pixels. x1/y1 exclusive, buffer length = (x1-x0)*(y1-y0) RGB565 words.
*/
void display_draw_bitmap(int x0, int y0, int x1, int y1, const uint16_t *pixels);
/**
* @brief Draw text with a 5x7 font. Returns pixel width consumed.
*/
int display_put_text(int x, int y, const char *str, uint16_t fg, uint16_t bg);
/**
* @brief Draw text centered horizontally on the given row.
*/
void display_put_text_center(int y, const char *str, uint16_t fg, uint16_t bg);
/**
* @brief Stream-decode a JPEG from LittleFS and draw it at the top-left.
* Uses tjpgd with a line-by-line output into the panel DMA path.
*/
esp_err_t display_show_jpeg_file(const char *path);
#ifdef __cplusplus
}
#endif