mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-20 06:58:39 +03:00
fix sub-menu text wrap-a-around
This commit is contained in:
50
ui/helper.c
50
ui/helper.c
@ -69,58 +69,58 @@ void UI_GenerateChannelStringEx(char *pString, const char *prefix, const uint8_t
|
||||
sprintf(pString + strlen(prefix), "%03u", ChannelNumber + 1);
|
||||
}
|
||||
|
||||
void UI_PrintString(const char *str, unsigned int start, const unsigned int end, const unsigned int line, const unsigned int width)
|
||||
void UI_PrintString(const char *str, unsigned int x, const unsigned int end, const unsigned int line, const unsigned int width)
|
||||
{
|
||||
const size_t length = strlen(str);
|
||||
size_t i;
|
||||
const unsigned int length = strlen(str);
|
||||
const unsigned int font_size = ARRAY_SIZE(g_font_big);
|
||||
uint8_t *f_buf1 = g_frame_buffer[line + 0];
|
||||
uint8_t *f_buf2 = g_frame_buffer[line + 1];
|
||||
unsigned int i;
|
||||
|
||||
if (end > start)
|
||||
if (end > x)
|
||||
{
|
||||
const int ofs = ((int)(end - start) - (length * width) - 1) / 2;
|
||||
if (ofs > 0 && (start + ofs) <= end)
|
||||
start += ofs;
|
||||
const int ofs = ((int)(end - x) - (length * width) - 1) / 2;
|
||||
if (ofs > 0 && (x + ofs) <= end)
|
||||
x += ofs;
|
||||
}
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
for (i = 0; i < length && (x + width) <= LCD_WIDTH; i++, x += width)
|
||||
{
|
||||
if (str[i] >= ' ' && str[i] < 127)
|
||||
const int c = (int)str[i] - ' ';
|
||||
if (c >= 0 && c < (int)font_size)
|
||||
{
|
||||
const unsigned int index = str[i] - ' ';
|
||||
const unsigned int ofs = start + (i * width);
|
||||
memcpy(g_frame_buffer[line + 0] + ofs, &g_font_big[index][0], 8);
|
||||
memcpy(g_frame_buffer[line + 1] + ofs, &g_font_big[index][8], 7);
|
||||
memcpy(f_buf1 + x, &g_font_big[c][0], 8);
|
||||
memcpy(f_buf2 + x, &g_font_big[c][8], 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UI_print_string(
|
||||
static void UI_print_string(
|
||||
const char *str,
|
||||
unsigned int start,
|
||||
unsigned int x,
|
||||
const unsigned int end,
|
||||
const unsigned int line,
|
||||
const uint8_t *font,
|
||||
const unsigned int font_size,
|
||||
const unsigned int char_width)
|
||||
{
|
||||
const unsigned int char_pitch = char_width + 1;
|
||||
const unsigned int char_pitch = char_width + 1; // char width + 1 pixel space between chars
|
||||
const size_t length = strlen(str);
|
||||
uint8_t *f_buf = g_frame_buffer[line];
|
||||
unsigned int i;
|
||||
uint8_t *f_buf;
|
||||
|
||||
if (end > start)
|
||||
if (end > x)
|
||||
{
|
||||
const int ofs = ((int)(end - start) - (length * char_pitch) - 1) / 2;
|
||||
if (ofs > 0 && (start + ofs) <= end)
|
||||
start += ofs;
|
||||
const int ofs = ((int)(end - x) - (length * char_pitch) - 1) / 2;
|
||||
if (ofs > 0 && (x + ofs) <= end)
|
||||
x += ofs;
|
||||
}
|
||||
|
||||
f_buf = g_frame_buffer[line] + start;
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
for (i = 0; i < length && (x + char_width) <= LCD_WIDTH; i++, x += char_pitch)
|
||||
{
|
||||
const int c = (int)str[i] - ' ';
|
||||
if (c >= 0 && c < (int)font_size)
|
||||
memcpy(f_buf + (char_pitch * i), font + (char_width * c), char_width);
|
||||
memcpy(f_buf + x, font + (char_width * c), char_width);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user