mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-09-01 18:38:17 +00:00
Improve UI color and respect UI CONFIG_ZEPHCORE_DISPLAY_LARGE_FONT
This commit is contained in:
@@ -92,20 +92,20 @@ static inline int ui_content_y(void)
|
||||
* mc_display_has_color(); monochrome displays keep the existing CFB path. */
|
||||
#define UI_COLOR_BG MC_COLOR_BLACK
|
||||
#define UI_COLOR_HEADER_BG 0x2104 /* dark neutral panel */
|
||||
#define UI_COLOR_TITLE 0xffde /* warm white */
|
||||
#define UI_COLOR_TITLE MC_COLOR_GRAY /* warm white */
|
||||
#define UI_COLOR_LABEL MC_COLOR_WHITE /* small-TFT gamma renders mid-gray near-black */
|
||||
#define UI_COLOR_VALUE MC_COLOR_WHITE
|
||||
#define UI_COLOR_OK 0x07e0
|
||||
#define UI_COLOR_OK MC_COLOR_GREEN
|
||||
#define UI_COLOR_ACTIVE UI_COLOR_OK
|
||||
#define UI_COLOR_WARN 0xffa0
|
||||
#define UI_COLOR_ERROR MC_COLOR_RED
|
||||
#define UI_COLOR_DIM 0x4208
|
||||
#define UI_COLOR_DIM MC_COLOR_GRAY
|
||||
#define UI_COLOR_DISABLED UI_COLOR_DIM /* off/disabled states stay as faint as possible */
|
||||
#define UI_COLOR_TX MC_COLOR_ORANGE
|
||||
#define UI_COLOR_RX UI_COLOR_OK
|
||||
|
||||
#define COLOR_FONT_W 6
|
||||
#define COLOR_FONT_H 8
|
||||
#define COLOR_FONT_W mc_display_font_width()
|
||||
#define COLOR_FONT_H mc_display_font_height()
|
||||
#define ACTIVITY_GRAPH_SAMPLES 16
|
||||
|
||||
/* Vertically center `total` rows of text within the content area and
|
||||
@@ -373,7 +373,7 @@ static void draw_color_segments_at(int x, int y, const char *label,
|
||||
const char *value, uint16_t value_color)
|
||||
{
|
||||
mc_display_color_text(x, y, label, UI_COLOR_LABEL);
|
||||
x += (int)strlen(label) * 6;
|
||||
x += (int)strlen(label) * COLOR_FONT_W;
|
||||
mc_display_color_text(x, y, value, value_color);
|
||||
}
|
||||
|
||||
@@ -1030,7 +1030,7 @@ static void render_bluetooth_color(void)
|
||||
!state.ble_enabled ? "disabled" :
|
||||
state.ble_connected ? "connected" : "advertising",
|
||||
color);
|
||||
y += LINE_H + 4;
|
||||
y += LINE_H + (FONT_H / 4);
|
||||
draw_centered_color(y,
|
||||
state.ble_enabled ? "Press to disable"
|
||||
: "Press to enable",
|
||||
@@ -1081,7 +1081,7 @@ static void render_advert_color(void)
|
||||
|
||||
draw_badge(0, y, "ADV", just_sent ? UI_COLOR_OK : UI_COLOR_ACTIVE);
|
||||
mc_display_color_text(32, y, "Zero-hop advert", UI_COLOR_VALUE);
|
||||
y += LINE_H + 2;
|
||||
y += LINE_H + (FONT_H / 2);
|
||||
|
||||
if (just_sent) {
|
||||
draw_centered_color(y,
|
||||
|
||||
@@ -61,6 +61,17 @@ static bool has_color; /* true when a raw RGB565 TFT is available */
|
||||
|
||||
const uint8_t *zephcore_font_6x8_glyph(uint8_t c);
|
||||
|
||||
#if IS_ENABLED(CONFIG_ZEPHCORE_DISPLAY_LARGE_FONT)
|
||||
#define COLOR_FONT_SCALE_NUM 3
|
||||
#define COLOR_FONT_SCALE_DEN 2
|
||||
#else
|
||||
#define COLOR_FONT_SCALE_NUM 1
|
||||
#define COLOR_FONT_SCALE_DEN 1
|
||||
#endif
|
||||
|
||||
#define COLOR_FONT_W (6 * COLOR_FONT_SCALE_NUM / COLOR_FONT_SCALE_DEN)
|
||||
#define COLOR_FONT_H (8 * COLOR_FONT_SCALE_NUM / COLOR_FONT_SCALE_DEN)
|
||||
|
||||
#define COLOR_TEXT_MAX_CHARS 32
|
||||
#define COLOR_MAX_OPS 72
|
||||
#define COLOR_MAX_WIDTH 320
|
||||
@@ -257,23 +268,37 @@ static void color_write_rect_now(int x, int y, int w, int h, uint16_t color)
|
||||
|
||||
static void color_write_char_now(int x, int y, uint8_t c, uint16_t color)
|
||||
{
|
||||
uint16_t glyph_buf[6 * 8];
|
||||
uint16_t glyph_buf[COLOR_FONT_W * COLOR_FONT_H];
|
||||
const uint8_t *glyph = zephcore_font_6x8_glyph(c);
|
||||
uint16_t fg = sys_cpu_to_be16(color);
|
||||
uint16_t bg = sys_cpu_to_be16(MC_COLOR_BLACK);
|
||||
|
||||
for (int row = 0; row < 8; row++) {
|
||||
for (int col = 0; col < 6; col++) {
|
||||
bool on = (glyph[col] >> row) & 0x01;
|
||||
glyph_buf[row * 6 + col] = on ? fg : bg;
|
||||
uint16_t pixel =
|
||||
((glyph[col] >> row) & 0x01) ? fg : bg;
|
||||
|
||||
int dx = col * COLOR_FONT_SCALE_NUM / COLOR_FONT_SCALE_DEN;
|
||||
int dy = row * COLOR_FONT_SCALE_NUM / COLOR_FONT_SCALE_DEN;
|
||||
|
||||
for (int sy = 0; sy < COLOR_FONT_SCALE_NUM; sy++) {
|
||||
for (int sx = 0; sx < COLOR_FONT_SCALE_NUM; sx++) {
|
||||
int px = dx + sx;
|
||||
int py = dy + sy;
|
||||
|
||||
if (px < COLOR_FONT_W && py < COLOR_FONT_H) {
|
||||
glyph_buf[py * COLOR_FONT_W + px] = pixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const struct display_buffer_descriptor desc = {
|
||||
.buf_size = sizeof(glyph_buf),
|
||||
.width = 6,
|
||||
.height = 8,
|
||||
.pitch = 6,
|
||||
.width = COLOR_FONT_W,
|
||||
.height = COLOR_FONT_H,
|
||||
.pitch = COLOR_FONT_W,
|
||||
};
|
||||
|
||||
display_write(color_dev, (uint16_t)(x + DISP_INSET),
|
||||
@@ -286,13 +311,13 @@ static void color_write_text_now(int x, int y, const char *text, uint16_t color)
|
||||
return;
|
||||
}
|
||||
|
||||
for (const char *p = text; *p; p++, x += 6) {
|
||||
for (const char *p = text; *p; p++, x += COLOR_FONT_W) {
|
||||
uint8_t c = (uint8_t)*p;
|
||||
|
||||
if (c < 32) {
|
||||
c = '?';
|
||||
}
|
||||
if (x + 6 > (int)mc_display_width() || y + 8 > (int)mc_display_height()) {
|
||||
if (x + COLOR_FONT_W > (int)mc_display_width() || y + COLOR_FONT_H > (int)mc_display_height()) {
|
||||
break;
|
||||
}
|
||||
color_write_char_now(x, y, c, color);
|
||||
|
||||
@@ -130,7 +130,7 @@ void mc_display_text(int x, int y, const char *text, bool invert);
|
||||
#define MC_COLOR_ORANGE 0xfd20
|
||||
#define MC_COLOR_RED 0xf800
|
||||
#define MC_COLOR_BLUE 0x001f
|
||||
#define MC_COLOR_GRAY 0x8410
|
||||
#define MC_COLOR_GRAY 0xEF7D
|
||||
|
||||
/**
|
||||
* Draw text using RGB565 color when supported. On non-color displays this
|
||||
|
||||
Reference in New Issue
Block a user