0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 14:21:25 +03:00

Added fagci's teeny teeny font

This commit is contained in:
OneOfEleven 2023-10-20 14:09:12 +01:00
parent 78b4c93f67
commit d3000206d6
16 changed files with 631 additions and 375 deletions

View File

@ -8,7 +8,7 @@ ENABLE_SWD := 0
ENABLE_OVERLAY := 0 ENABLE_OVERLAY := 0
ENABLE_LTO := 1 ENABLE_LTO := 1
ENABLE_UART := 1 ENABLE_UART := 1
ENABLE_UART_DEBUG := 1 ENABLE_UART_DEBUG := 0
ENABLE_AIRCOPY := 1 ENABLE_AIRCOPY := 1
ENABLE_AIRCOPY_REMEMBER_FREQ := 1 ENABLE_AIRCOPY_REMEMBER_FREQ := 1
ENABLE_AIRCOPY_RX_REBOOT := 0 ENABLE_AIRCOPY_RX_REBOOT := 0
@ -23,7 +23,7 @@ ENABLE_TX1750 := 0
ENABLE_PWRON_PASSWORD := 0 ENABLE_PWRON_PASSWORD := 0
ENABLE_RESET_AES_KEY := 1 ENABLE_RESET_AES_KEY := 1
ENABLE_BIG_FREQ := 0 ENABLE_BIG_FREQ := 0
ENABLE_SMALL_BOLD := 1 ENABLE_SMALL_BOLD := 0
ENABLE_KEEP_MEM_NAME := 1 ENABLE_KEEP_MEM_NAME := 1
ENABLE_WIDE_RX := 1 ENABLE_WIDE_RX := 1
ENABLE_TX_WHEN_AM := 0 ENABLE_TX_WHEN_AM := 0
@ -39,7 +39,7 @@ ENABLE_FREQ_SEARCH_TIMEOUT := 0
ENABLE_CODE_SEARCH_TIMEOUT := 0 ENABLE_CODE_SEARCH_TIMEOUT := 0
ENABLE_KILL_REVIVE := 0 ENABLE_KILL_REVIVE := 0
ENABLE_AM_FIX := 1 ENABLE_AM_FIX := 1
ENABLE_AM_FIX_SHOW_DATA := 1 ENABLE_AM_FIX_SHOW_DATA := 0
ENABLE_SQUELCH_MORE_SENSITIVE := 1 ENABLE_SQUELCH_MORE_SENSITIVE := 1
ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS := 1 ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS := 1
ENABLE_FASTER_CHANNEL_SCAN := 1 ENABLE_FASTER_CHANNEL_SCAN := 1

View File

@ -36,6 +36,11 @@
// ********************** // **********************
// aircopy packet format is very simple ..
//
// payloads ................ 0xABCD + 2 byte eeprom address + 64 byte payload + 2 byte CRC + 0xDCBA
// 1of11 req/ack additon ... 0xBCDA + 2 byte eeprom address + 2 byte CRC + 0xCDBA
#define AIRCOPY_MAGIC_START_REQ 0xBCDA // used to request a block resend #define AIRCOPY_MAGIC_START_REQ 0xBCDA // used to request a block resend
#define AIRCOPY_MAGIC_END_REQ 0xCDBA // used to request a block resend #define AIRCOPY_MAGIC_END_REQ 0xCDBA // used to request a block resend
@ -44,11 +49,11 @@
#define AIRCOPY_LAST_EEPROM_ADDR 0x1E00 // size of eeprom transferred #define AIRCOPY_LAST_EEPROM_ADDR 0x1E00 // size of eeprom transferred
// FSK Data Length .. 0xABCD + 2 byte eeprom address + 64 byte payload + 2 byte CRC + 0xDCBA // FSK payload data length
#define AIRCOPY_DATA_PACKET_SIZE (2 + 2 + 64 + 2 + 2) #define AIRCOPY_DATA_PACKET_SIZE (2 + 2 + 64 + 2 + 2)
// FSK Data Length .. 0xBCDA + 2 byte eeprom address + 2 byte CRC + 0xCDBA // FSK req/ack data length .. 0xBCDA + 2 byte eeprom address + 2 byte CRC + 0xCDBA
#define AIRCOPY_REQ_PACKET_SIZE (2 + 2 + 64 + 2 + 2) #define AIRCOPY_REQ_PACKET_SIZE (2 + 2 + 2 + 2)
// ********************** // **********************

View File

@ -88,6 +88,86 @@ void toggle_chan_scanlist(void)
g_flag_reset_vfos = true; g_flag_reset_vfos = true;
} }
#ifdef ENABLE_COPY_CHAN_TO_VFO_TO_CHAN
void MAIN_copy_mem_vfo_mem(void)
{
//const unsigned int vfo = get_RX_VFO();
const unsigned int vfo = g_eeprom.tx_vfo;
if (g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
g_eeprom.dual_watch != DUAL_WATCH_OFF ||
!g_eeprom.vfo_open)
{ // scanning
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (IS_USER_CHANNEL(g_eeprom.screen_channel[vfo]))
{ // copy channel to VFO, then swap to the VFO
const unsigned int channel = FREQ_CHANNEL_FIRST + g_eeprom.vfo_info[vfo].band;
g_eeprom.screen_channel[vfo] = channel;
g_eeprom.vfo_info[vfo].channel_save = channel;
g_eeprom.tx_vfo = vfo;
RADIO_select_vfos();
RADIO_ApplyOffset(g_tx_vfo);
RADIO_ConfigureSquelchAndOutputPower(g_tx_vfo);
RADIO_setup_registers(true);
// find the first channel that contains this frequency
g_tx_vfo->frequency_channel = BOARD_find_channel(g_tx_vfo->freq_config_tx.frequency);
g_request_save_vfo = true;
g_beep_to_play = BEEP_880HZ_60MS_TRIPLE_BEEP;
//g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
g_update_status = true;
g_update_display = true;
}
else
if (IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[vfo]))
{ // copy VFO to a channel
// search the channels to see if the frequency is already present
unsigned int chan = BOARD_find_channel(g_eeprom.vfo_info[vfo].p_tx->frequency);
if (chan > USER_CHANNEL_LAST)
{ // find next next free channel
//for (chan = g_eeprom.screen_channel[vfo]; chan <= USER_CHANNEL_LAST; chan++)
for (chan = 0; chan <= USER_CHANNEL_LAST; chan++)
if (!RADIO_CheckValidChannel(chan, false, vfo))
break;
}
g_screen_to_display = DISPLAY_INVALID;
GUI_SelectNextDisplay(DISPLAY_MENU);
g_menu_cursor = MENU_MEM_SAVE;
g_is_in_sub_menu = true;
if (chan <= USER_CHANNEL_LAST)
{
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("vfo to mem %u\r\n", chan);
#endif
g_sub_menu_selection = chan;
g_flag_refresh_menu = false;
g_screen_to_display = DISPLAY_MENU;
g_update_display = false;
UI_DisplayMenu();
}
#ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_MENU;
#endif
g_beep_to_play = BEEP_880HZ_60MS_TRIPLE_BEEP;
}
}
#endif
void processFKeyFunction(const key_code_t Key) void processFKeyFunction(const key_code_t Key)
{ {
uint8_t Band; uint8_t Band;
@ -625,81 +705,7 @@ void MAIN_Key_MENU(const bool key_pressed, const bool key_held)
g_update_status = true; g_update_status = true;
#ifdef ENABLE_COPY_CHAN_TO_VFO_TO_CHAN #ifdef ENABLE_COPY_CHAN_TO_VFO_TO_CHAN
MAIN_copy_mem_vfo_mem();
if (g_scan_state_dir == SCAN_STATE_DIR_OFF &&
g_css_scan_mode == CSS_SCAN_MODE_OFF &&
g_eeprom.dual_watch == DUAL_WATCH_OFF &&
g_eeprom.vfo_open)
{ // not scanning
//const unsigned int vfo = get_RX_VFO();
const unsigned int vfo = g_eeprom.tx_vfo;
if (IS_USER_CHANNEL(g_eeprom.screen_channel[vfo]))
{ // copy channel to VFO, then swap to the VFO
const unsigned int channel = FREQ_CHANNEL_FIRST + g_eeprom.vfo_info[vfo].band;
g_eeprom.screen_channel[vfo] = channel;
g_eeprom.vfo_info[vfo].channel_save = channel;
g_eeprom.tx_vfo = vfo;
RADIO_select_vfos();
RADIO_ApplyOffset(g_rx_vfo);
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
RADIO_setup_registers(true);
g_request_save_vfo = true;
g_beep_to_play = BEEP_880HZ_60MS_TRIPLE_BEEP;
//g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
g_update_status = true;
g_update_display = true;
}
else
if (IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[vfo]))
{ // copy VFO to a channel
// search the channels to see if the frequency is already present
unsigned int chan = BOARD_find_channel(g_eeprom.vfo_info[vfo].p_tx->frequency);
if (chan > USER_CHANNEL_LAST)
{ // find next next free channel
//for (chan = g_eeprom.screen_channel[vfo]; chan <= USER_CHANNEL_LAST; chan++)
for (chan = 0; chan <= USER_CHANNEL_LAST; chan++)
if (!RADIO_CheckValidChannel(chan, false, vfo))
break;
}
g_screen_to_display = DISPLAY_INVALID;
GUI_SelectNextDisplay(DISPLAY_MENU);
g_menu_cursor = MENU_MEM_SAVE;
g_is_in_sub_menu = true;
if (chan <= USER_CHANNEL_LAST)
{
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("vfo to mem %u\r\n", chan);
#endif
g_sub_menu_selection = chan;
g_flag_refresh_menu = false;
g_screen_to_display = DISPLAY_MENU;
g_update_display = false;
UI_DisplayMenu();
}
#ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_MENU;
#endif
g_beep_to_play = BEEP_880HZ_60MS_TRIPLE_BEEP;
}
}
else
{
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
}
#endif #endif
} }
} }

View File

@ -390,23 +390,3 @@ const uint8_t BITMAP_SCANLIST2[6] =
__extension__ 0b01111110, __extension__ 0b01111110,
__extension__ 0b01000010 __extension__ 0b01000010
}; };
const uint8_t BITMAP_COMPAND[6] =
{
__extension__ 0b00000000,
__extension__ 0b00111100,
__extension__ 0b01000010,
__extension__ 0b01000010,
__extension__ 0b01000010,
__extension__ 0b00100100
};
const uint8_t BITMAP_FREQ_CHAN[6] =
{
__extension__ 0b00000000,
__extension__ 0b01111110,
__extension__ 0b00010010,
__extension__ 0b00010010,
__extension__ 0b00000010,
__extension__ 0b00000010
};

View File

@ -59,9 +59,5 @@ extern const uint8_t BITMAP_VFO_NOT_DEFAULT[8];
extern const uint8_t BITMAP_SCANLIST1[6]; extern const uint8_t BITMAP_SCANLIST1[6];
extern const uint8_t BITMAP_SCANLIST2[6]; extern const uint8_t BITMAP_SCANLIST2[6];
extern const uint8_t BITMAP_COMPAND[6];
extern const uint8_t BITMAP_FREQ_CHAN[6];
#endif #endif

Binary file not shown.

Binary file not shown.

103
font.c
View File

@ -477,8 +477,106 @@ const uint8_t g_font_small[95][6] =
{0x0C, 0x06, 0x0C, 0x18, 0x0C, 0x00} {0x0C, 0x06, 0x0C, 0x18, 0x0C, 0x00}
}; };
#endif #endif
/*
#ifdef ENABLE_SPECTRUM const uint8_t g_font_small_4x5[95][4] =
{
{0x00, 0x00, 0x00, 0x00}, // ' '
{0x00, 0x00, 0x17, 0x00}, // '!'
{0x20, 0x00, 0x03, 0x00}, // '"'
{0x00, 0x00, 0x00, 0x0A}, // '#'
{0x0A, 0x1F, 0x28, 0x00}, // '$'
{0x15, 0x1F, 0x09, 0x70}, // '%'
{0x11, 0x08, 0x04, 0x13}, // '&'
{0x00, 0x1E, 0x15, 0x15}, // '''
{0x78, 0x00, 0x00, 0x00}, // '('
{0x07, 0x00, 0x00, 0x0E}, // ')'
{0x00, 0x00, 0x20, 0x00}, // '*'
{0x11, 0x0E, 0x00, 0x20}, // '+'
{0x12, 0x0C, 0x0C, 0x12}, // ','
{0x00, 0x04, 0x0E, 0x04}, // '-'
{0x00, 0x00, 0x00, 0x10}, // '.'
{0x00, 0x20, 0x00, 0x04}, // '/'
{0x04, 0x00, 0x00, 0x00}, // '0'
{0x10, 0x00, 0x00, 0x20}, // '1'
{0x10, 0x08, 0x04, 0x03}, // '2'
{0x00, 0x0E, 0x11, 0x11}, // '3'
{0x30, 0x00, 0x00, 0x12}, // '4'
{0x10, 0x38, 0x00, 0x19}, // '5'
{0x15, 0x12, 0x78, 0x00}, // '6'
{0x15, 0x15, 0x1F, 0x78}, // '7'
{0x0C, 0x0A, 0x09, 0x1F}, // '8'
{0x00, 0x17, 0x15, 0x15}, // '9'
{0x78, 0x00, 0x1E, 0x15}, // ':'
{0x1D, 0x78, 0x00, 0x01}, // ';'
{0x05, 0x03, 0x20, 0x00}, // '<'
{0x15, 0x15, 0x0A, 0x30}, // '='
{0x07, 0x05, 0x05, 0x1F}, // '>'
{0x00, 0x00, 0x16, 0x00}, // '?'
{0x20, 0x00, 0x00, 0x10}, // '@'
{0x00, 0x20, 0x00, 0x08}, // 'A'
{0x22, 0x01, 0x20, 0x10}, // 'B'
{0x0A, 0x0A, 0x00, 0x00}, // 'C'
{0x00, 0x01, 0x22, 0x14}, // 'D'
{0x10, 0x02, 0x11, 0x05}, // 'E'
{0x20, 0x00, 0x0E, 0x15}, // 'F'
{0x0E, 0x30, 0x00, 0x1E}, // 'G'
{0x05, 0x1E, 0x48, 0x00}, // 'H'
{0x15, 0x15, 0x0E, 0x70}, // 'I'
{0x1F, 0x11, 0x11, 0x11}, // 'J'
{0x00, 0x1F, 0x11, 0x11}, // 'K'
{0x70, 0x00, 0x1F, 0x15}, // 'L'
{0x11, 0x78, 0x00, 0x1F}, // 'M'
{0x05, 0x01, 0x40, 0x00}, // 'N'
{0x11, 0x15, 0x1D, 0x78}, // 'O'
{0x1F, 0x04, 0x04, 0x1F}, // 'P'
{0x00, 0x11, 0x1F, 0x11}, // 'Q'
{0x70, 0x00, 0x08, 0x11}, // 'R'
{0x1F, 0x38, 0x00, 0x1F}, // 'S'
{0x0A, 0x11, 0x48, 0x00}, // 'T'
{0x10, 0x10, 0x10, 0x78}, // 'U'
{0x1F, 0x02, 0x02, 0x1F}, // 'V'
{0x00, 0x1F, 0x02, 0x04}, // 'W'
{0x48, 0x00, 0x0E, 0x11}, // 'X'
{0x0E, 0x30, 0x00, 0x1F}, // 'Y'
{0x05, 0x02, 0x40, 0x00}, // 'Z'
{0x11, 0x19, 0x1E, 0x38}, // '['
{0x1F, 0x05, 0x05, 0x1A}, // '\'
{0x00, 0x12, 0x15, 0x15}, // ']'
{0x70, 0x00, 0x01, 0x1F}, // '^'
{0x00, 0x20, 0x00, 0x1F}, // '_'
{0x10, 0x1F, 0x78, 0x00}, // '`'
{0x10, 0x10, 0x0F, 0x30}, // 'a'
{0x1F, 0x08, 0x08, 0x1F}, // 'b'
{0x00, 0x1B, 0x04, 0x04}, // 'c'
{0x48, 0x00, 0x07, 0x1C}, // 'd'
{0x00, 0x20, 0x00, 0x19}, // 'e'
{0x15, 0x13, 0x78, 0x00}, // 'f'
{0x11, 0x00, 0x00, 0x60}, // 'g'
{0x01, 0x02, 0x04, 0x08}, // 'h'
{0x00, 0x00, 0x11, 0x1F}, // 'i'
{0x30, 0x00, 0x02, 0x01}, // 'j'
{0x00, 0x00, 0x00, 0x10}, // 'k'
{0x10, 0x10, 0x78, 0x00}, // 'l'
{0x03, 0x07, 0x06, 0x00}, // 'm'
{0x1D, 0x15, 0x15, 0x1E}, // 'n'
{0x00, 0x1F, 0x14, 0x14}, // 'o'
{0x70, 0x00, 0x0C, 0x12}, // 'p'
{0x12, 0x38, 0x00, 0x08}, // 'q'
{0x14, 0x1F, 0x38, 0x00}, // 'r'
{0x15, 0x15, 0x16, 0x38}, // 's'
{0x1E, 0x05, 0x05, 0x00}, // 't'
{0x00, 0x02, 0x15, 0x15}, // 'u'
{0x38, 0x00, 0x1F, 0x04}, // 'v'
{0x18, 0x48, 0x00, 0x00}, // 'w'
{0x00, 0x00, 0x20, 0x00}, // 'x'
{0x10, 0x1D, 0x00, 0x30}, // 'y'
{0x1F, 0x04, 0x0A, 0x10}, // 'z'
{0x00, 0x00, 0x1F, 0x00}, // '{'
{0x20, 0x00, 0x1E, 0x04}, // '|'
{0x1E, 0x48, 0x00, 0x1E}, // '}'
{0x02, 0x1C, 0x48, 0x00}, // '~'
};
*/
const uint8_t g_font3x5[160][3] = const uint8_t g_font3x5[160][3] =
{ {
{0x00, 0x00, 0x00}, // 32 - space {0x00, 0x00, 0x00}, // 32 - space
@ -642,4 +740,3 @@ const uint8_t g_font_small[95][6] =
{0x03, 0x0b, 0x18}, // 190 - threequarters {0x03, 0x0b, 0x18}, // 190 - threequarters
{0x18, 0x15, 0x10}, // 191 - questiondown {0x18, 0x15, 0x10}, // 191 - questiondown
}; };
#endif

2
font.h
View File

@ -26,6 +26,8 @@ extern const uint8_t g_font_small[95][6];
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
extern const uint8_t g_font_small_bold[95][6]; extern const uint8_t g_font_small_bold[95][6];
#endif #endif
//extern const uint8_t g_font_small_4x5[95][4];
extern const uint8_t g_font3x5[160][3];
#endif #endif

View File

@ -182,6 +182,13 @@ typedef struct {
#endif #endif
} __attribute__((packed)) t_channel; // } __attribute__((packed)) t_channel; //
typedef struct {
uint8_t band:4; // why do QS have these bits ? band can/is computed from the frequency
uint8_t unused:2; //
uint8_t scanlist2:1; // set if in scan list 2
uint8_t scanlist1:1; // set if in scan list 1
} __attribute__((packed)) t_channel_attr; //
// 512 bytes // 512 bytes
typedef struct { typedef struct {
@ -270,12 +277,7 @@ typedef struct {
} __attribute__((packed)); // } __attribute__((packed)); //
// 0x0D60 // 0x0D60
struct { // these channel attribute settings could have been in the t_channel structure ! t_channel_attr channel_attr[200]; //
uint8_t band:4; // why do QS have these bits ? band can/is computed from the frequency
uint8_t unused:2; //
uint8_t scanlist2:1; // set if in scan list 2
uint8_t scanlist1:1; // set if in scan list 1
} __attribute__((packed)) channel_attr[200]; //
uint8_t unused1[8]; // 0xff's uint8_t unused1[8]; // 0xff's
@ -412,10 +414,10 @@ typedef struct {
uint8_t dtmf_live_decoder:1; // 1 = enable on-screen live DTMF decoder uint8_t dtmf_live_decoder:1; // 1 = enable on-screen live DTMF decoder
uint8_t battery_text:2; // 0 = no battery text, 1 = voltage, 2 = percent .. on the status bar uint8_t battery_text:2; // 0 = no battery text, 1 = voltage, 2 = percent .. on the status bar
uint8_t mic_bar:1; // 1 = on-screen TX audio level uint8_t mic_bar:1; // 1 = on-screen TX audio level
uint8_t am_fix:1; // 1 = RX AM fix uint8_t am_fix:1; // 1 = enable RX AM fix
uint8_t backlight_on_tx_rx:2; // 0 = no backlight when TX/RX, 1 = when TX, 2 = when RX, 3 = both RX/TX uint8_t backlight_on_tx_rx:2; // 0 = no backlight when TX/RX, 1 = when TX, 2 = when RX, 3 = both RX/TX
uint8_t scan_hold_time; // ticks we stay paused on a signal when scanning uint8_t scan_hold_time; // ticks we stay paused for on an RX'ed signal when scanning
uint8_t unused12[7]; // 0xff's uint8_t unused12[7]; // 0xff's
#endif #endif

View File

@ -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; const unsigned int char_spacing = char_width + 1;
uint8_t *pFb = g_frame_buffer[Line] + Start; const size_t length = strlen(str);
for (i = 0; i < Length; i++) 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 int c = (int)str[i] - ' ';
{ if (c >= 0 && c < (int)font_size)
const unsigned int index = (unsigned int)pString[i] - 32; memmove(f_buf + (char_spacing * i) + 1, font + (char_width * c), char_width);
if (index < ARRAY_SIZE(g_font_small))
memmove(pFb + (i * char_spacing) + 1, &g_font_small[index], 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 #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); 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]));
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);
}
}
} }
#endif #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) 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_width = ARRAY_SIZE(g_font_small[0]);
const unsigned int char_spacing = char_width + 1; const unsigned int char_spacing = char_width + 1;
unsigned int i;
for (i = 0; i < strlen(pString); i++) for (i = 0; i < strlen(pString); i++)
{ {
if (pString[i] >= 32) const int c = (int)pString[i] - ' ';
{ if (c >= 0 && c < (int)ARRAY_SIZE(g_font_small))
const unsigned int index = (unsigned int)pString[i] - 32; memmove(buffer + (i * char_spacing) + 1, &g_font_small[c], char_width);
if (index < ARRAY_SIZE(g_font_small))
memmove(buffer + (i * char_spacing) + 1, &g_font_small[index], char_width);
}
} }
} }

View File

@ -23,10 +23,12 @@
void UI_GenerateChannelString(char *pString, const uint8_t Channel, const char separating_char); 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_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_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 #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 #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_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_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); void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero);

View File

@ -31,6 +31,7 @@
#include "driver/bk4819.h" #include "driver/bk4819.h"
#include "driver/st7565.h" #include "driver/st7565.h"
#include "external/printf/printf.h" #include "external/printf/printf.h"
#include "font.h"
#include "functions.h" #include "functions.h"
#include "helper/battery.h" #include "helper/battery.h"
#include "misc.h" #include "misc.h"
@ -395,6 +396,7 @@ void UI_update_rssi(const int16_t rssi, const int vfo)
void UI_DisplayMain(void) 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 line0 = 0; // text screen line
const unsigned int line1 = 4; const unsigned int line1 = 4;
char String[17]; char String[17];
@ -746,20 +748,23 @@ void UI_DisplayMain(void)
#else #else
{ {
unsigned int x = LCD_WIDTH + LCD_WIDTH - 1 - sizeof(BITMAP_FREQ_CHAN) - sizeof(BITMAP_COMPAND); unsigned int x = LCD_WIDTH + LCD_WIDTH - 1 - (smallest_char_spacing * 1) - (smallest_char_spacing * 4);
if (g_eeprom.vfo_info[vfo_num].compand)
memmove(p_line0 + x, BITMAP_COMPAND, sizeof(BITMAP_COMPAND));
x += sizeof(BITMAP_COMPAND);
if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num])) if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]))
{ {
//g_eeprom.vfo_info[vfo_num].frequency_channel = BOARD_find_channel(frequency); //g_eeprom.vfo_info[vfo_num].frequency_channel = BOARD_find_channel(frequency);
if (g_eeprom.vfo_info[vfo_num].frequency_channel <= USER_CHANNEL_LAST) if (g_eeprom.vfo_info[vfo_num].frequency_channel <= USER_CHANNEL_LAST)
memmove(p_line0 + x, BITMAP_FREQ_CHAN, sizeof(BITMAP_FREQ_CHAN)); { // the channel number that contains this VFO frequency
//x += sizeof(BITMAP_FREQ_CHAN); 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 #endif
} }
@ -846,6 +851,8 @@ void UI_DisplayMain(void)
#else #else
if (g_eeprom.vfo_info[vfo_num].dtmf_decoding_enable) if (g_eeprom.vfo_info[vfo_num].dtmf_decoding_enable)
UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1); 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 #endif
// show the audio scramble symbol // show the audio scramble symbol

View File

@ -20,6 +20,10 @@
#include <string.h> #include <string.h>
#include <vector> #include <vector>
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
// ************************************************************************ // ************************************************************************
// create a front end gain table for the firmware // create a front end gain table for the firmware
@ -397,19 +401,19 @@ void rotate_font(const char *filename1, const char *filename2)
{ {
uint8_t c1[8]; uint8_t c1[8];
uint8_t c2[8]; uint8_t c2[8];
memcpy(c1, &data[i], 8); memcpy(c1, &data[i], ARRAY_SIZE(c1));
memset(c2, 0, 8); memset(c2, 0, ARRAY_SIZE(c2));
for (unsigned int k = 0; k < 8; k++) for (unsigned int k = 0; k < ARRAY_SIZE(c1); k++)
{ {
uint8_t b = c1[k]; uint8_t b = c1[k];
for (unsigned int m = 0; m < 8; m++) for (unsigned int m = 0; m < ARRAY_SIZE(c2); m++)
{ {
if (b & 0x80) if (b & 0x80)
c2[m] |= 1u << k; c2[m] |= 1u << k;
b <<= 1; b <<= 1;
} }
} }
memcpy(&data[i], c2, 8); memcpy(&data[i], c2, ARRAY_SIZE(c2));
} }
// *************************** // ***************************
@ -422,7 +426,7 @@ void rotate_font(const char *filename1, const char *filename2)
fprintf(file, "const uint8_t gFontSmall[95][7] =\n"); fprintf(file, "const uint8_t gFontSmall[95][7] =\n");
fprintf(file, "{\n"); fprintf(file, "{\n");
for (unsigned int i = 0; i < data.size(); ) for (unsigned int i = 0, c = ' '; i < data.size() && c < (' ' + 95); i++, c++)
{ {
char s[1024]; char s[1024];
memset(s, 0, sizeof(s)); memset(s, 0, sizeof(s));
@ -445,13 +449,122 @@ void rotate_font(const char *filename1, const char *filename2)
else else
{ {
strcat(s, s2); strcat(s, s2);
strcat(s, "},\n"); strcat(s, "},");
} }
} }
i++; fprintf(file, "%s // '%c'\n", s, c);
}
fprintf(file, "%s", s); fprintf(file, "};\n");
fclose(file);
// ***************************
}
// ************************************************************************
// "rotate_font()" has nothing to do with this program at all, I just needed
// to write a bit of code to rotate some fonts I've drawn
void rotate_font_4x5(const char *filename1, const char *filename2)
{
std::vector <uint8_t> data;
if (filename1 == NULL || filename2 == NULL)
return;
// ****************************
// load the file
FILE *file = fopen(filename1, "rb");
if (file == NULL)
return;
if (fseek(file, 0, SEEK_END) != 0)
{
fclose(file);
return;
}
const size_t file_size = ftell(file);
if (file_size <= 0)
{
fclose(file);
return;
}
if (fseek(file, 0, SEEK_SET) != 0)
{
fclose(file);
return;
}
data.resize(file_size);
const size_t bytes_loaded = fread(&data[0], 1, file_size, file);
fclose(file);
if (bytes_loaded != file_size)
return;
// ***************************
// rotate the font 90-deg clockwise
for (unsigned int i = 0; i <= (data.size() - 6); i += 6)
{
uint8_t c1[6];
uint8_t c2[4];
memcpy(c1, &data[i], 6);
memset(c2, 0, 4);
for (unsigned int k = 0; k < ARRAY_SIZE(c1); k++)
{
uint8_t b = c1[k];
for (unsigned int m = 0; m < ARRAY_SIZE(c2); m++)
{
if (b & 0x40)
c2[m] |= 1u << k;
b <<= 1;
}
}
memcpy(&data[i], c2, 4);
}
// ***************************
// save the file
file = fopen(filename2, "wt");
if (file == NULL)
return;
fprintf(file, "const uint8_t g_font_small_4x5[95][4] =\n");
fprintf(file, "{\n");
for (unsigned int i = 0, c = ' '; i < data.size() && c < (' ' + 95); i++, c++)
{
char s[1024];
memset(s, 0, sizeof(s));
for (unsigned int k = 0; k < 4 && i < data.size(); k++)
{
char s2[16];
sprintf(s2, "0x%02X", data[i++]);
if (k == 0)
strcat(s, "\t{");
if (k < 3)
{
strcat(s, s2);
strcat(s, ", ");
}
else
{
strcat(s, s2);
strcat(s, "},");
}
}
fprintf(file, "%s // '%c'\n", s, c);
} }
fprintf(file, "};\n"); fprintf(file, "};\n");
@ -468,6 +581,7 @@ int main(int argc, char* argv[])
rotate_font("uv-k5_small.bin", "uv-k5_small.c"); rotate_font("uv-k5_small.bin", "uv-k5_small.c");
rotate_font("uv-k5_small_bold.bin", "uv-k5_small_bold.c"); rotate_font("uv-k5_small_bold.bin", "uv-k5_small_bold.c");
rotate_font_4x5("uv-k5_small_4x5.bin", "uv-k5_small_4x5.c");
return 0; return 0;
} }

Binary file not shown.

BIN
utils/uv-k5_small_4x5.bin Normal file

Binary file not shown.