mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-18 22:29:50 +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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,7 +470,7 @@ void UI_SortMenu(const bool hide_hidden)
|
||||
void UI_DisplayMenu(void)
|
||||
{
|
||||
const unsigned int menu_list_width = 6; // max no. of characters on the menu list (left side)
|
||||
const unsigned int sub_menu_x1 = (8 * menu_list_width) + 2; // start x corrd
|
||||
const unsigned int sub_menu_x1 = (8 * menu_list_width) + 0; // start x corrd
|
||||
const unsigned int sub_menu_x2 = LCD_WIDTH - 1; // end x coord
|
||||
bool channel_setting = false; // set if the setting is a channel setting
|
||||
unsigned int i;
|
||||
|
Reference in New Issue
Block a user