mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-19 22:58:04 +03:00
Added fagci's teeny teeny font
This commit is contained in:
141
ui/helper.c
141
ui/helper.c
@ -32,7 +32,7 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel, const char s
|
||||
|
||||
if (pString == NULL)
|
||||
return;
|
||||
|
||||
|
||||
if (g_input_box_index == 0)
|
||||
{
|
||||
sprintf(pString, "CH%c%02u", separating_char, Channel + 1);
|
||||
@ -50,7 +50,7 @@ void UI_GenerateChannelStringEx(char *pString, const char *prefix, const uint8_t
|
||||
{
|
||||
if (pString == NULL)
|
||||
return;
|
||||
|
||||
|
||||
if (g_input_box_index > 0)
|
||||
{
|
||||
unsigned int i;
|
||||
@ -60,10 +60,10 @@ void UI_GenerateChannelStringEx(char *pString, const char *prefix, const uint8_t
|
||||
}
|
||||
|
||||
pString[0] = 0;
|
||||
|
||||
|
||||
if (prefix)
|
||||
strcpy(pString, prefix);
|
||||
|
||||
|
||||
if (ChannelNumber == 0xFF)
|
||||
strcpy(pString, "NULL");
|
||||
else
|
||||
@ -90,65 +90,110 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin
|
||||
}
|
||||
}
|
||||
|
||||
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
|
||||
void UI_print_string(
|
||||
const char *str,
|
||||
unsigned int start,
|
||||
const unsigned int end,
|
||||
const unsigned int line,
|
||||
const uint8_t *font,
|
||||
const unsigned int font_size,
|
||||
const unsigned int char_width)
|
||||
{
|
||||
const size_t Length = strlen(pString);
|
||||
size_t i;
|
||||
|
||||
if (End > Start)
|
||||
Start += (((End - Start) - (Length * 7)) + 1) / 2;
|
||||
|
||||
const unsigned int char_width = ARRAY_SIZE(g_font_small[0]);
|
||||
const unsigned int char_spacing = char_width + 1;
|
||||
uint8_t *pFb = g_frame_buffer[Line] + Start;
|
||||
for (i = 0; i < Length; i++)
|
||||
const size_t length = strlen(str);
|
||||
unsigned int i;
|
||||
uint8_t *f_buf;
|
||||
|
||||
if (end > start)
|
||||
start += (((end - start) - (length * (char_width - 1))) + 1) / 2;
|
||||
|
||||
f_buf = g_frame_buffer[line] + start;
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
if (pString[i] >= 32)
|
||||
{
|
||||
const unsigned int index = (unsigned int)pString[i] - 32;
|
||||
if (index < ARRAY_SIZE(g_font_small))
|
||||
memmove(pFb + (i * char_spacing) + 1, &g_font_small[index], char_width);
|
||||
}
|
||||
const int c = (int)str[i] - ' ';
|
||||
if (c >= 0 && c < (int)font_size)
|
||||
memmove(f_buf + (char_spacing * i) + 1, font + (char_width * c), char_width);
|
||||
}
|
||||
}
|
||||
|
||||
void UI_PrintStringSmall(const char *str, const unsigned int start, const unsigned int end, const unsigned int line)
|
||||
{
|
||||
UI_print_string(str, start, end, line, (const uint8_t *)g_font_small, ARRAY_SIZE(g_font_small), ARRAY_SIZE(g_font_small[0]));
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line)
|
||||
void UI_PrintStringSmallBold(const char *str, const unsigned int start, const unsigned int end, const unsigned int line)
|
||||
{
|
||||
const size_t Length = strlen(pString);
|
||||
size_t i;
|
||||
|
||||
if (End > Start)
|
||||
Start += (((End - Start) - (Length * 7)) + 1) / 2;
|
||||
|
||||
const unsigned int char_width = ARRAY_SIZE(g_font_small_bold[0]);
|
||||
const unsigned int char_spacing = char_width + 1;
|
||||
uint8_t *pFb = g_frame_buffer[Line] + Start;
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
if (pString[i] >= 32)
|
||||
{
|
||||
const unsigned int index = (unsigned int)pString[i] - 32;
|
||||
if (index < ARRAY_SIZE(g_font_small_bold))
|
||||
memmove(pFb + (i * char_spacing) + 1, &g_font_small_bold[index], char_width);
|
||||
}
|
||||
}
|
||||
UI_print_string(str, start, end, line, (const uint8_t *)g_font_small_bold, ARRAY_SIZE(g_font_small_bold), ARRAY_SIZE(g_font_small_bold[0]));
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
void UI_PrintStringSmall4x5(const char *str, const unsigned int start, const unsigned int end, const unsigned int line)
|
||||
{
|
||||
UI_print_string(str, start, end, line, (const uint8_t *)g_font_small_4x5, ARRAY_SIZE(g_font_small_4x5), ARRAY_SIZE(g_font_small_4x5[0]));
|
||||
}
|
||||
*/
|
||||
|
||||
void PutPixel(const unsigned int x, const unsigned int y, const bool fill)
|
||||
{
|
||||
if (fill)
|
||||
g_frame_buffer[y >> 3][x] |= 1u << (y & 7u);
|
||||
else
|
||||
g_frame_buffer[y >> 3][x] &= ~(1u << (y & 7u));
|
||||
}
|
||||
|
||||
void PutPixelStatus(const unsigned int x, const unsigned int y, bool fill)
|
||||
{
|
||||
if (fill)
|
||||
g_status_line[x] |= 1u << y;
|
||||
else
|
||||
g_status_line[x] &= ~(1u << y);
|
||||
}
|
||||
|
||||
void UI_PrintStringSmallest(const void *pString, unsigned int x, const unsigned int y, const bool statusbar, const bool fill)
|
||||
{
|
||||
const unsigned int char_width = ARRAY_SIZE(g_font3x5[0]);
|
||||
const unsigned int char_height = 5;
|
||||
// const uint8_t pixel_mask = (1u << char_height) - 1;
|
||||
const uint8_t *p = (const uint8_t *)pString;
|
||||
int c;
|
||||
|
||||
while ((c = *p++) != 0)
|
||||
{
|
||||
c -= ' ';
|
||||
if (c >= 0 && c < (int)ARRAY_SIZE(g_font3x5))
|
||||
{
|
||||
for (unsigned int xx = 0; xx < char_width; xx++)
|
||||
{
|
||||
uint8_t pixels = g_font3x5[c][xx];
|
||||
if (statusbar)
|
||||
{
|
||||
for (unsigned int yy = 0; yy <= char_height; yy++, pixels >>= 1)
|
||||
if (pixels & 1u)
|
||||
PutPixelStatus(x + xx, y + yy, fill);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int yy = 0; yy <= char_height; yy++, pixels >>= 1)
|
||||
if (pixels & 1u)
|
||||
PutPixel(x + xx, y + yy, fill);
|
||||
}
|
||||
}
|
||||
}
|
||||
x += char_width + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer)
|
||||
{
|
||||
size_t i;
|
||||
const unsigned int char_width = ARRAY_SIZE(g_font_small[0]);
|
||||
const unsigned int char_spacing = char_width + 1;
|
||||
unsigned int i;
|
||||
for (i = 0; i < strlen(pString); i++)
|
||||
{
|
||||
if (pString[i] >= 32)
|
||||
{
|
||||
const unsigned int index = (unsigned int)pString[i] - 32;
|
||||
if (index < ARRAY_SIZE(g_font_small))
|
||||
memmove(buffer + (i * char_spacing) + 1, &g_font_small[index], char_width);
|
||||
}
|
||||
const int c = (int)pString[i] - ' ';
|
||||
if (c >= 0 && c < (int)ARRAY_SIZE(g_font_small))
|
||||
memmove(buffer + (i * char_spacing) + 1, &g_font_small[c], char_width);
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,7 +204,7 @@ void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDispla
|
||||
uint8_t *pFb1 = pFb0 + 128;
|
||||
bool bCanDisplay = false;
|
||||
unsigned int i = 0;
|
||||
|
||||
|
||||
// MHz
|
||||
while (i < 3)
|
||||
{
|
||||
@ -184,7 +229,7 @@ void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDispla
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
|
||||
|
||||
// kHz
|
||||
while (i < 6)
|
||||
{
|
||||
|
@ -23,10 +23,12 @@
|
||||
void UI_GenerateChannelString(char *pString, const uint8_t Channel, const char separating_char);
|
||||
void UI_GenerateChannelStringEx(char *pString, const char *prefix, const uint8_t ChannelNumber);
|
||||
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width);
|
||||
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||
void UI_PrintStringSmall(const char *str, const unsigned int start, const unsigned int end, const unsigned int line);
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||
void UI_PrintStringSmallBold(const char *str, const unsigned int start, const unsigned int end, const unsigned int line);
|
||||
#endif
|
||||
//void UI_PrintStringSmall4x5(const char *str, const unsigned int start, const unsigned int end, const unsigned int line);
|
||||
void UI_PrintStringSmallest(const void *pString, unsigned int x, const unsigned int y, const bool statusbar, const bool fill);
|
||||
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer);
|
||||
void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool flag);
|
||||
void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero);
|
||||
|
21
ui/main.c
21
ui/main.c
@ -31,6 +31,7 @@
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/st7565.h"
|
||||
#include "external/printf/printf.h"
|
||||
#include "font.h"
|
||||
#include "functions.h"
|
||||
#include "helper/battery.h"
|
||||
#include "misc.h"
|
||||
@ -395,6 +396,7 @@ void UI_update_rssi(const int16_t rssi, const int vfo)
|
||||
|
||||
void UI_DisplayMain(void)
|
||||
{
|
||||
const unsigned int smallest_char_spacing = ARRAY_SIZE(g_font3x5[0]) + 1;
|
||||
const unsigned int line0 = 0; // text screen line
|
||||
const unsigned int line1 = 4;
|
||||
char String[17];
|
||||
@ -746,19 +748,22 @@ void UI_DisplayMain(void)
|
||||
|
||||
#else
|
||||
{
|
||||
unsigned int x = LCD_WIDTH + LCD_WIDTH - 1 - sizeof(BITMAP_FREQ_CHAN) - sizeof(BITMAP_COMPAND);
|
||||
|
||||
if (g_eeprom.vfo_info[vfo_num].compand)
|
||||
memmove(p_line0 + x, BITMAP_COMPAND, sizeof(BITMAP_COMPAND));
|
||||
x += sizeof(BITMAP_COMPAND);
|
||||
unsigned int x = LCD_WIDTH + LCD_WIDTH - 1 - (smallest_char_spacing * 1) - (smallest_char_spacing * 4);
|
||||
|
||||
if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]))
|
||||
{
|
||||
//g_eeprom.vfo_info[vfo_num].frequency_channel = BOARD_find_channel(frequency);
|
||||
if (g_eeprom.vfo_info[vfo_num].frequency_channel <= USER_CHANNEL_LAST)
|
||||
memmove(p_line0 + x, BITMAP_FREQ_CHAN, sizeof(BITMAP_FREQ_CHAN));
|
||||
//x += sizeof(BITMAP_FREQ_CHAN);
|
||||
{ // the channel number that contains this VFO frequency
|
||||
sprintf(String, "%03u", g_eeprom.vfo_info[vfo_num].frequency_channel);
|
||||
UI_PrintStringSmallest(String, x, (line + 0) * 8, false, true);
|
||||
}
|
||||
}
|
||||
x += smallest_char_spacing * 4;
|
||||
|
||||
if (g_eeprom.vfo_info[vfo_num].compand)
|
||||
UI_PrintStringSmallest("C", x, (line + 0) * 8, false, true);
|
||||
//x += smallest_char_spacing * 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -846,6 +851,8 @@ void UI_DisplayMain(void)
|
||||
#else
|
||||
if (g_eeprom.vfo_info[vfo_num].dtmf_decoding_enable)
|
||||
UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1);
|
||||
//UI_PrintStringSmall4x5("DTMF", LCD_WIDTH + 78, 0, line + 1); // font table is currently wrong
|
||||
//UI_PrintStringSmallest("DTMF", LCD_WIDTH + 78, (line + 1) * 8, false, true);
|
||||
#endif
|
||||
|
||||
// show the audio scramble symbol
|
||||
|
Reference in New Issue
Block a user