Phase 7: EC11 encoder, life counter views, WS2812B RMT + LEDC buzzer feedback, E2E UI state machine; document build/hardware notes
This commit is contained in:
@@ -155,6 +155,48 @@ void display_put_text_center(int y, const char *str, uint16_t fg, uint16_t bg)
|
||||
display_put_text(x, y, str, fg, bg);
|
||||
}
|
||||
|
||||
void display_draw_big_text(int x, int y, const char *str, int scale, uint16_t fg, uint16_t bg)
|
||||
{
|
||||
int cell_w = FONT5X7_W * scale;
|
||||
int cell_h = FONT5X7_H * scale;
|
||||
int num = (int)strlen(str);
|
||||
if (num <= 0) {
|
||||
return;
|
||||
}
|
||||
if (x + num * (cell_w + scale) - scale > DISP_W || y + cell_h > DISP_H) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Staging buffer for one glyph, scaled */
|
||||
uint16_t *glyph_buf = malloc((size_t)cell_w * cell_h * sizeof(uint16_t));
|
||||
if (glyph_buf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
char c = str[i];
|
||||
if (c < FONT5X7_FIRST_CHAR || c > FONT5X7_LAST_CHAR) {
|
||||
x += cell_w + scale;
|
||||
continue;
|
||||
}
|
||||
const uint8_t *g = font5x7[c - FONT5X7_FIRST_CHAR];
|
||||
|
||||
for (int gy = 0; gy < FONT5X7_H; gy++) {
|
||||
for (int gx = 0; gx < FONT5X7_W; gx++) {
|
||||
uint16_t color = ((g[gy] >> gx) & 1) ? fg : bg;
|
||||
for (int sy = 0; sy < scale; sy++) {
|
||||
for (int sx = 0; sx < scale; sx++) {
|
||||
glyph_buf[(gy * scale + sy) * cell_w + (gx * scale + sx)] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
display_draw_bitmap(x, y, x + cell_w, y + cell_h, glyph_buf);
|
||||
x += cell_w + scale;
|
||||
}
|
||||
free(glyph_buf);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* tjpgd streaming decode */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
Reference in New Issue
Block a user