SDSPI fix for ESP32-C5: correct API v5.5, CMake dependencies, pin mapping
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
/**
|
||||
* ASCII-Font (6x8 Pixel) + Text-Ausgabe
|
||||
* Verwendet st7735_draw_pixel statt esp_lcd_panel_draw_bitmap
|
||||
*/
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "v2x_display.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "st7735.h"
|
||||
|
||||
#define FONT_START 32
|
||||
#define FONT_END 126
|
||||
|
||||
extern esp_lcd_panel_handle_t s_panel;
|
||||
extern bool s_initialized;
|
||||
extern void *s_dev;
|
||||
|
||||
static const uint8_t font6x8[][6] = {
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00}, // space
|
||||
@@ -69,7 +73,7 @@ static const uint8_t font6x8[][6] = {
|
||||
{0x07,0x08,0x70,0x08,0x07,0x00}, // Y
|
||||
{0x61,0x51,0x49,0x45,0x43,0x00}, // Z
|
||||
{0x00,0x7F,0x41,0x41,0x00,0x00}, // [
|
||||
{0x55,0x2A,0x55,0x2A,0x55,0x00}, // \
|
||||
{0x55,0x2A,0x55,0x2A,0x55,0x00}, /* backslash */
|
||||
{0x00,0x41,0x41,0x7F,0x00,0x00}, // ]
|
||||
{0x04,0x02,0x01,0x02,0x04,0x00}, // ^
|
||||
{0x40,0x40,0x40,0x40,0x40,0x00}, // _
|
||||
@@ -107,8 +111,9 @@ static const uint8_t font6x8[][6] = {
|
||||
};
|
||||
|
||||
esp_err_t v2x_display_text(int16_t x, int16_t y, const char *text,
|
||||
uint16_t color, disp_font_t font)
|
||||
uint16_t color, uint8_t font)
|
||||
{
|
||||
(void)font;
|
||||
if (!s_initialized) return ESP_ERR_INVALID_STATE;
|
||||
|
||||
uint8_t char_bytes[6];
|
||||
@@ -124,11 +129,10 @@ esp_err_t v2x_display_text(int16_t x, int16_t y, const char *text,
|
||||
uint16_t row = char_bytes[c];
|
||||
for (int r = 0; r < 8; r++) {
|
||||
if (row & 0x01) {
|
||||
uint16_t pixel = color;
|
||||
int px = tx + c;
|
||||
int py = y + r;
|
||||
if (px >= 0 && px < DISP_W && py >= 0 && py < DISP_H) {
|
||||
esp_lcd_panel_draw_bitmap(s_panel, px, py, px + 1, py + 1, &pixel);
|
||||
st7735_draw_pixel((void *)s_dev, px, py, color);
|
||||
}
|
||||
}
|
||||
row >>= 1;
|
||||
@@ -147,6 +151,7 @@ esp_err_t v2x_display_frame_count(uint32_t count)
|
||||
snprintf(buf, sizeof(buf), "%lu", (unsigned long)count);
|
||||
int len = strlen(buf);
|
||||
int x = (DISP_W - len * 7) / 2;
|
||||
int y = 20;
|
||||
|
||||
uint8_t char_bytes[6];
|
||||
for (int ci = 0; ci < len; ci++) {
|
||||
@@ -159,13 +164,12 @@ esp_err_t v2x_display_frame_count(uint32_t count)
|
||||
uint16_t row = char_bytes[c];
|
||||
for (int r = 0; r < 8; r++) {
|
||||
if (row & 0x01) {
|
||||
uint16_t pixel = DISP_COLOR_RED;
|
||||
int px = x + ci * 18 + c * 3;
|
||||
int px = x + ci * 7 + c;
|
||||
for (int dy = 0; dy < 3; dy++) {
|
||||
for (int dx = 0; dx < 3; dx++) {
|
||||
int py = y + r * 3 + dy;
|
||||
if (px + dx >= 0 && px + dx < DISP_W && py < DISP_H) {
|
||||
esp_lcd_panel_draw_bitmap(s_panel, px + dx, py, px + dx + 1, py + 1, &pixel);
|
||||
if (px + dx >= 0 && px + dx < DISP_W && py >= 0 && py < DISP_H) {
|
||||
st7735_draw_pixel((void *)s_dev, px + dx, py, DISP_COLOR_RED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,13 +184,22 @@ esp_err_t v2x_display_frame_count(uint32_t count)
|
||||
esp_err_t v2x_display_storage_bar(int16_t x, int16_t y, int16_t w, int16_t h, float pct)
|
||||
{
|
||||
pct = (pct < 0.0f) ? 0.0f : (pct > 1.0f) ? 1.0f : pct;
|
||||
v2x_display_rect(x, y, w, h, DISP_COLOR_GRAY, true);
|
||||
|
||||
for (int16_t py = 0; py < h; py++) {
|
||||
for (int16_t px = 0; px < w; px++) {
|
||||
st7735_draw_pixel((void *)s_dev, x + px, y + py, DISP_COLOR_GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t fg = DISP_COLOR_GREEN;
|
||||
if (pct < 0.3f) fg = DISP_COLOR_RED;
|
||||
else if (pct < 0.6f) fg = DISP_COLOR_YELLOW;
|
||||
|
||||
int16_t fw = (int16_t)(w * pct);
|
||||
v2x_display_rect(x, y, fw, h, fg, true);
|
||||
for (int16_t py = 0; py < h; py++) {
|
||||
for (int16_t px = 0; px < fw; px++) {
|
||||
st7735_draw_pixel((void *)s_dev, x + px, y + py, fg);
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user