diff --git a/Makefile b/Makefile index f2e7271..e6fbd1e 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,7 @@ ENABLE_OVERLAY := 0 ENABLE_LTO := 1 # UART Programming 2.9 kb ENABLE_UART := 1 -ENABLE_UART_DEBUG := 1 -# Air Copy 3.1 kb +ENABLE_UART_DEBUG := 0 ENABLE_AIRCOPY := 1 ENABLE_AIRCOPY_REMEMBER_FREQ := 1 ENABLE_AIRCOPY_RX_REBOOT := 0 @@ -33,8 +32,7 @@ ENABLE_TX1750 := 0 ENABLE_PWRON_PASSWORD := 0 ENABLE_RESET_AES_KEY := 1 ENABLE_BIG_FREQ := 0 -# Small Bold Font 0.6 kb -ENABLE_SMALL_BOLD := 1 +ENABLE_SMALL_BOLD := 0 ENABLE_KEEP_MEM_NAME := 1 ENABLE_WIDE_RX := 1 ENABLE_TX_WHEN_AM := 0 @@ -52,7 +50,7 @@ ENABLE_CODE_SEARCH_TIMEOUT := 0 ENABLE_KILL_REVIVE := 0 # AM Fix 0.8 kb ENABLE_AM_FIX := 1 -ENABLE_AM_FIX_SHOW_DATA := 1 +ENABLE_AM_FIX_SHOW_DATA := 0 ENABLE_SQUELCH_MORE_SENSITIVE := 1 ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS := 1 ENABLE_FASTER_CHANNEL_SCAN := 1 diff --git a/app/aircopy.c b/app/aircopy.c index 933461a..32e4619 100644 --- a/app/aircopy.c +++ b/app/aircopy.c @@ -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_END_REQ 0xCDBA // used to request a block resend @@ -44,11 +49,11 @@ #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) -// FSK Data Length .. 0xBCDA + 2 byte eeprom address + 2 byte CRC + 0xCDBA -#define AIRCOPY_REQ_PACKET_SIZE (2 + 2 + 64 + 2 + 2) +// FSK req/ack data length .. 0xBCDA + 2 byte eeprom address + 2 byte CRC + 0xCDBA +#define AIRCOPY_REQ_PACKET_SIZE (2 + 2 + 2 + 2) // ********************** diff --git a/app/main.c b/app/main.c index c15f2b6..719116b 100644 --- a/app/main.c +++ b/app/main.c @@ -88,6 +88,86 @@ void toggle_chan_scanlist(void) 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) { uint8_t Band; @@ -625,81 +705,7 @@ void MAIN_Key_MENU(const bool key_pressed, const bool key_held) g_update_status = true; #ifdef ENABLE_COPY_CHAN_TO_VFO_TO_CHAN - - 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; - } - + MAIN_copy_mem_vfo_mem(); #endif } } @@ -747,13 +753,7 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held) ACTION_Scan(false); - g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - return; - } - - if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_current_function == FUNCTION_TRANSMIT) - { // RF scanning or TX'ing - g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; +// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; return; } @@ -763,6 +763,12 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held) return; } + if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_current_function == FUNCTION_TRANSMIT) + { // RF scanning or TX'ing +// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + return; + } + if (!g_fkey_pressed) { // pressed without the F-key diff --git a/bitmaps.c b/bitmaps.c index 8f3bfef..cf54647 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -392,23 +392,3 @@ const uint8_t BITMAP_SCANLIST2[6] = __extension__ 0b01111110, __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 -}; diff --git a/bitmaps.h b/bitmaps.h index b41c4a2..2fb03e2 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -61,9 +61,5 @@ extern const uint8_t BITMAP_VFO_NOT_DEFAULT[8]; extern const uint8_t BITMAP_SCANLIST1[6]; extern const uint8_t BITMAP_SCANLIST2[6]; -extern const uint8_t BITMAP_COMPAND[6]; - -extern const uint8_t BITMAP_FREQ_CHAN[6]; - #endif diff --git a/firmware.bin b/firmware.bin index 8f1d8e0..93badc4 100755 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index e8a2b1e..c0c7898 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/font.c b/font.c index 07fa0c1..70a82a1 100644 --- a/font.c +++ b/font.c @@ -477,169 +477,266 @@ const uint8_t g_font_small[95][6] = {0x0C, 0x06, 0x0C, 0x18, 0x0C, 0x00} }; #endif - -#ifdef ENABLE_SPECTRUM - const uint8_t g_font3x5[160][3] = - { - {0x00, 0x00, 0x00}, // 32 - space - {0x00, 0x17, 0x00}, // 33 - exclam - {0x03, 0x00, 0x03}, // 34 - quotedbl - {0x1f, 0x0a, 0x1f}, // 35 - numbersign - {0x0a, 0x1f, 0x05}, // 36 - dollar - {0x09, 0x04, 0x12}, // 37 - percent - {0x0f, 0x17, 0x1c}, // 38 - ampersand - {0x00, 0x03, 0x00}, // 39 - quotesingle - {0x00, 0x0e, 0x11}, // 40 - parenleft - {0x11, 0x0e, 0x00}, // 41 - parenright - {0x05, 0x02, 0x05}, // 42 - asterisk - {0x04, 0x0e, 0x04}, // 43 - plus - {0x10, 0x08, 0x00}, // 44 - comma - {0x04, 0x04, 0x04}, // 45 - hyphen - {0x00, 0x10, 0x00}, // 46 - period - {0x18, 0x04, 0x03}, // 47 - slash - {0x1e, 0x11, 0x0f}, // 48 - zero - {0x02, 0x1f, 0x00}, // 49 - one - {0x19, 0x15, 0x12}, // 50 - two - {0x11, 0x15, 0x0a}, // 51 - three - {0x07, 0x04, 0x1f}, // 52 - four - {0x17, 0x15, 0x09}, // 53 - five - {0x1e, 0x15, 0x1d}, // 54 - six - {0x19, 0x05, 0x03}, // 55 - seven - {0x1f, 0x15, 0x1f}, // 56 - eight - {0x17, 0x15, 0x0f}, // 57 - nine - {0x00, 0x0a, 0x00}, // 58 - colon - {0x10, 0x0a, 0x00}, // 59 - semicolon - {0x04, 0x0a, 0x11}, // 60 - less - {0x0a, 0x0a, 0x0a}, // 61 - equal - {0x11, 0x0a, 0x04}, // 62 - greater - {0x01, 0x15, 0x03}, // 63 - question - {0x0e, 0x15, 0x16}, // 64 - at - {0x1e, 0x05, 0x1e}, // 65 - A - {0x1f, 0x15, 0x0a}, // 66 - B - {0x0e, 0x11, 0x11}, // 67 - C - {0x1f, 0x11, 0x0e}, // 68 - D - {0x1f, 0x15, 0x15}, // 69 - E - {0x1f, 0x05, 0x05}, // 70 - F - {0x0e, 0x15, 0x1d}, // 71 - G - {0x1f, 0x04, 0x1f}, // 72 - H - {0x11, 0x1f, 0x11}, // 73 - I - {0x08, 0x10, 0x0f}, // 74 - J - {0x1f, 0x04, 0x1b}, // 75 - K - {0x1f, 0x10, 0x10}, // 76 - L - {0x1f, 0x06, 0x1f}, // 77 - M - {0x1f, 0x0e, 0x1f}, // 78 - N - {0x0e, 0x11, 0x0e}, // 79 - O - {0x1f, 0x05, 0x02}, // 80 - P - {0x0e, 0x19, 0x1e}, // 81 - Q - {0x1f, 0x0d, 0x16}, // 82 - R - {0x12, 0x15, 0x09}, // 83 - S - {0x01, 0x1f, 0x01}, // 84 - T - {0x0f, 0x10, 0x1f}, // 85 - U - {0x07, 0x18, 0x07}, // 86 - V - {0x1f, 0x0c, 0x1f}, // 87 - W - {0x1b, 0x04, 0x1b}, // 88 - X - {0x03, 0x1c, 0x03}, // 89 - Y - {0x19, 0x15, 0x13}, // 90 - Z - {0x1f, 0x11, 0x11}, // 91 - bracketleft - {0x02, 0x04, 0x08}, // 92 - backslash - {0x11, 0x11, 0x1f}, // 93 - bracketright - {0x02, 0x01, 0x02}, // 94 - asciicircum - {0x10, 0x10, 0x10}, // 95 - underscore - {0x01, 0x02, 0x00}, // 96 - grave - {0x1a, 0x16, 0x1c}, // 97 - a - {0x1f, 0x12, 0x0c}, // 98 - b - {0x0c, 0x12, 0x12}, // 99 - c - {0x0c, 0x12, 0x1f}, // 100 - d - {0x0c, 0x1a, 0x16}, // 101 - e - {0x04, 0x1e, 0x05}, // 102 - f - {0x0c, 0x2a, 0x1e}, // 103 - g - {0x1f, 0x02, 0x1c}, // 104 - h - {0x00, 0x1d, 0x00}, // 105 - i - {0x10, 0x20, 0x1d}, // 106 - j - {0x1f, 0x0c, 0x12}, // 107 - k - {0x11, 0x1f, 0x10}, // 108 - l - {0x1e, 0x0e, 0x1e}, // 109 - m - {0x1e, 0x02, 0x1c}, // 110 - n - {0x0c, 0x12, 0x0c}, // 111 - o - {0x3e, 0x12, 0x0c}, // 112 - p - {0x0c, 0x12, 0x3e}, // 113 - q - {0x1c, 0x02, 0x02}, // 114 - r - {0x14, 0x1e, 0x0a}, // 115 - s - {0x02, 0x1f, 0x12}, // 116 - t - {0x0e, 0x10, 0x1e}, // 117 - u - {0x0e, 0x18, 0x0e}, // 118 - v - {0x1e, 0x1c, 0x1e}, // 119 - w - {0x12, 0x0c, 0x12}, // 120 - x - {0x06, 0x28, 0x1e}, // 121 - y - {0x1a, 0x1e, 0x16}, // 122 - z - {0x04, 0x1b, 0x11}, // 123 - braceleft - {0x00, 0x1b, 0x00}, // 124 - bar - {0x11, 0x1b, 0x04}, // 125 - braceright - {0x02, 0x03, 0x01}, // 126 - asciitilde - {0x00, 0x00, 0x00}, // 127 - empty - {0x00, 0x00, 0x00}, // 128 - empty - {0x00, 0x00, 0x00}, // 129 - empty - {0x00, 0x00, 0x00}, // 130 - empty - {0x00, 0x00, 0x00}, // 131 - empty - {0x00, 0x00, 0x00}, // 132 - empty - {0x00, 0x00, 0x00}, // 133 - empty - {0x00, 0x00, 0x00}, // 134 - empty - {0x00, 0x00, 0x00}, // 135 - empty - {0x00, 0x00, 0x00}, // 136 - empty - {0x00, 0x00, 0x00}, // 137 - empty - {0x00, 0x00, 0x00}, // 138 - empty - {0x00, 0x00, 0x00}, // 139 - empty - {0x00, 0x00, 0x00}, // 140 - empty - {0x00, 0x00, 0x00}, // 141 - empty - {0x00, 0x00, 0x00}, // 142 - empty - {0x00, 0x00, 0x00}, // 143 - empty - {0x00, 0x00, 0x00}, // 144 - empty - {0x00, 0x00, 0x00}, // 145 - empty - {0x00, 0x00, 0x00}, // 146 - empty - {0x00, 0x00, 0x00}, // 147 - empty - {0x00, 0x00, 0x00}, // 148 - empty - {0x00, 0x00, 0x00}, // 149 - empty - {0x00, 0x00, 0x00}, // 150 - empty - {0x00, 0x00, 0x00}, // 151 - empty - {0x00, 0x00, 0x00}, // 152 - empty - {0x00, 0x00, 0x00}, // 153 - empty - {0x00, 0x00, 0x00}, // 154 - empty - {0x00, 0x00, 0x00}, // 155 - empty - {0x00, 0x00, 0x00}, // 156 - empty - {0x00, 0x00, 0x00}, // 157 - empty - {0x00, 0x00, 0x00}, // 158 - empty - {0x00, 0x00, 0x00}, // 159 - empty - {0x00, 0x00, 0x00}, // 160 - empty - {0x00, 0x1d, 0x00}, // 161 - exclamdown - {0x0e, 0x1b, 0x0a}, // 162 - cent - {0x14, 0x1f, 0x15}, // 163 - sterling - {0x15, 0x0e, 0x15}, // 164 - currency - {0x0b, 0x1c, 0x0b}, // 165 - yen - {0x00, 0x1b, 0x00}, // 166 - brokenbar - {0x14, 0x1b, 0x05}, // 167 - section - {0x01, 0x00, 0x01}, // 168 - dieresis - {0x02, 0x05, 0x05}, // 169 - copyright - {0x16, 0x15, 0x17}, // 170 - ordfeminine - {0x02, 0x05, 0x00}, // 171 - guillemotleft - {0x02, 0x02, 0x06}, // 172 - logicalnot - {0x04, 0x04, 0x00}, // 173 - softhyphen - {0x07, 0x03, 0x04}, // 174 - registered - {0x01, 0x01, 0x01}, // 175 - macron - {0x02, 0x05, 0x02}, // 176 - degree - {0x12, 0x17, 0x12}, // 177 - plusminus - {0x01, 0x07, 0x04}, // 178 - twosuperior - {0x05, 0x07, 0x07}, // 179 - threesuperior - {0x00, 0x02, 0x01}, // 180 - acute - {0x1f, 0x08, 0x07}, // 181 - mu - {0x02, 0x1d, 0x1f}, // 182 - paragraph - {0x0e, 0x0e, 0x0e}, // 183 - periodcentered - {0x10, 0x14, 0x08}, // 184 - cedilla - {0x00, 0x07, 0x00}, // 185 - onesuperior - {0x12, 0x15, 0x12}, // 186 - ordmasculine - {0x00, 0x05, 0x02}, // 187 - guillemotright - {0x03, 0x08, 0x18}, // 188 - onequarter - {0x0b, 0x18, 0x10}, // 189 - onehalf - {0x03, 0x0b, 0x18}, // 190 - threequarters - {0x18, 0x15, 0x10}, // 191 - questiondown - }; -#endif +/* +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] = +{ + {0x00, 0x00, 0x00}, // 32 - space + {0x00, 0x17, 0x00}, // 33 - exclam + {0x03, 0x00, 0x03}, // 34 - quotedbl + {0x1f, 0x0a, 0x1f}, // 35 - numbersign + {0x0a, 0x1f, 0x05}, // 36 - dollar + {0x09, 0x04, 0x12}, // 37 - percent + {0x0f, 0x17, 0x1c}, // 38 - ampersand + {0x00, 0x03, 0x00}, // 39 - quotesingle + {0x00, 0x0e, 0x11}, // 40 - parenleft + {0x11, 0x0e, 0x00}, // 41 - parenright + {0x05, 0x02, 0x05}, // 42 - asterisk + {0x04, 0x0e, 0x04}, // 43 - plus + {0x10, 0x08, 0x00}, // 44 - comma + {0x04, 0x04, 0x04}, // 45 - hyphen + {0x00, 0x10, 0x00}, // 46 - period + {0x18, 0x04, 0x03}, // 47 - slash + {0x1e, 0x11, 0x0f}, // 48 - zero + {0x02, 0x1f, 0x00}, // 49 - one + {0x19, 0x15, 0x12}, // 50 - two + {0x11, 0x15, 0x0a}, // 51 - three + {0x07, 0x04, 0x1f}, // 52 - four + {0x17, 0x15, 0x09}, // 53 - five + {0x1e, 0x15, 0x1d}, // 54 - six + {0x19, 0x05, 0x03}, // 55 - seven + {0x1f, 0x15, 0x1f}, // 56 - eight + {0x17, 0x15, 0x0f}, // 57 - nine + {0x00, 0x0a, 0x00}, // 58 - colon + {0x10, 0x0a, 0x00}, // 59 - semicolon + {0x04, 0x0a, 0x11}, // 60 - less + {0x0a, 0x0a, 0x0a}, // 61 - equal + {0x11, 0x0a, 0x04}, // 62 - greater + {0x01, 0x15, 0x03}, // 63 - question + {0x0e, 0x15, 0x16}, // 64 - at + {0x1e, 0x05, 0x1e}, // 65 - A + {0x1f, 0x15, 0x0a}, // 66 - B + {0x0e, 0x11, 0x11}, // 67 - C + {0x1f, 0x11, 0x0e}, // 68 - D + {0x1f, 0x15, 0x15}, // 69 - E + {0x1f, 0x05, 0x05}, // 70 - F + {0x0e, 0x15, 0x1d}, // 71 - G + {0x1f, 0x04, 0x1f}, // 72 - H + {0x11, 0x1f, 0x11}, // 73 - I + {0x08, 0x10, 0x0f}, // 74 - J + {0x1f, 0x04, 0x1b}, // 75 - K + {0x1f, 0x10, 0x10}, // 76 - L + {0x1f, 0x06, 0x1f}, // 77 - M + {0x1f, 0x0e, 0x1f}, // 78 - N + {0x0e, 0x11, 0x0e}, // 79 - O + {0x1f, 0x05, 0x02}, // 80 - P + {0x0e, 0x19, 0x1e}, // 81 - Q + {0x1f, 0x0d, 0x16}, // 82 - R + {0x12, 0x15, 0x09}, // 83 - S + {0x01, 0x1f, 0x01}, // 84 - T + {0x0f, 0x10, 0x1f}, // 85 - U + {0x07, 0x18, 0x07}, // 86 - V + {0x1f, 0x0c, 0x1f}, // 87 - W + {0x1b, 0x04, 0x1b}, // 88 - X + {0x03, 0x1c, 0x03}, // 89 - Y + {0x19, 0x15, 0x13}, // 90 - Z + {0x1f, 0x11, 0x11}, // 91 - bracketleft + {0x02, 0x04, 0x08}, // 92 - backslash + {0x11, 0x11, 0x1f}, // 93 - bracketright + {0x02, 0x01, 0x02}, // 94 - asciicircum + {0x10, 0x10, 0x10}, // 95 - underscore + {0x01, 0x02, 0x00}, // 96 - grave + {0x1a, 0x16, 0x1c}, // 97 - a + {0x1f, 0x12, 0x0c}, // 98 - b + {0x0c, 0x12, 0x12}, // 99 - c + {0x0c, 0x12, 0x1f}, // 100 - d + {0x0c, 0x1a, 0x16}, // 101 - e + {0x04, 0x1e, 0x05}, // 102 - f + {0x0c, 0x2a, 0x1e}, // 103 - g + {0x1f, 0x02, 0x1c}, // 104 - h + {0x00, 0x1d, 0x00}, // 105 - i + {0x10, 0x20, 0x1d}, // 106 - j + {0x1f, 0x0c, 0x12}, // 107 - k + {0x11, 0x1f, 0x10}, // 108 - l + {0x1e, 0x0e, 0x1e}, // 109 - m + {0x1e, 0x02, 0x1c}, // 110 - n + {0x0c, 0x12, 0x0c}, // 111 - o + {0x3e, 0x12, 0x0c}, // 112 - p + {0x0c, 0x12, 0x3e}, // 113 - q + {0x1c, 0x02, 0x02}, // 114 - r + {0x14, 0x1e, 0x0a}, // 115 - s + {0x02, 0x1f, 0x12}, // 116 - t + {0x0e, 0x10, 0x1e}, // 117 - u + {0x0e, 0x18, 0x0e}, // 118 - v + {0x1e, 0x1c, 0x1e}, // 119 - w + {0x12, 0x0c, 0x12}, // 120 - x + {0x06, 0x28, 0x1e}, // 121 - y + {0x1a, 0x1e, 0x16}, // 122 - z + {0x04, 0x1b, 0x11}, // 123 - braceleft + {0x00, 0x1b, 0x00}, // 124 - bar + {0x11, 0x1b, 0x04}, // 125 - braceright + {0x02, 0x03, 0x01}, // 126 - asciitilde + {0x00, 0x00, 0x00}, // 127 - empty + {0x00, 0x00, 0x00}, // 128 - empty + {0x00, 0x00, 0x00}, // 129 - empty + {0x00, 0x00, 0x00}, // 130 - empty + {0x00, 0x00, 0x00}, // 131 - empty + {0x00, 0x00, 0x00}, // 132 - empty + {0x00, 0x00, 0x00}, // 133 - empty + {0x00, 0x00, 0x00}, // 134 - empty + {0x00, 0x00, 0x00}, // 135 - empty + {0x00, 0x00, 0x00}, // 136 - empty + {0x00, 0x00, 0x00}, // 137 - empty + {0x00, 0x00, 0x00}, // 138 - empty + {0x00, 0x00, 0x00}, // 139 - empty + {0x00, 0x00, 0x00}, // 140 - empty + {0x00, 0x00, 0x00}, // 141 - empty + {0x00, 0x00, 0x00}, // 142 - empty + {0x00, 0x00, 0x00}, // 143 - empty + {0x00, 0x00, 0x00}, // 144 - empty + {0x00, 0x00, 0x00}, // 145 - empty + {0x00, 0x00, 0x00}, // 146 - empty + {0x00, 0x00, 0x00}, // 147 - empty + {0x00, 0x00, 0x00}, // 148 - empty + {0x00, 0x00, 0x00}, // 149 - empty + {0x00, 0x00, 0x00}, // 150 - empty + {0x00, 0x00, 0x00}, // 151 - empty + {0x00, 0x00, 0x00}, // 152 - empty + {0x00, 0x00, 0x00}, // 153 - empty + {0x00, 0x00, 0x00}, // 154 - empty + {0x00, 0x00, 0x00}, // 155 - empty + {0x00, 0x00, 0x00}, // 156 - empty + {0x00, 0x00, 0x00}, // 157 - empty + {0x00, 0x00, 0x00}, // 158 - empty + {0x00, 0x00, 0x00}, // 159 - empty + {0x00, 0x00, 0x00}, // 160 - empty + {0x00, 0x1d, 0x00}, // 161 - exclamdown + {0x0e, 0x1b, 0x0a}, // 162 - cent + {0x14, 0x1f, 0x15}, // 163 - sterling + {0x15, 0x0e, 0x15}, // 164 - currency + {0x0b, 0x1c, 0x0b}, // 165 - yen + {0x00, 0x1b, 0x00}, // 166 - brokenbar + {0x14, 0x1b, 0x05}, // 167 - section + {0x01, 0x00, 0x01}, // 168 - dieresis + {0x02, 0x05, 0x05}, // 169 - copyright + {0x16, 0x15, 0x17}, // 170 - ordfeminine + {0x02, 0x05, 0x00}, // 171 - guillemotleft + {0x02, 0x02, 0x06}, // 172 - logicalnot + {0x04, 0x04, 0x00}, // 173 - softhyphen + {0x07, 0x03, 0x04}, // 174 - registered + {0x01, 0x01, 0x01}, // 175 - macron + {0x02, 0x05, 0x02}, // 176 - degree + {0x12, 0x17, 0x12}, // 177 - plusminus + {0x01, 0x07, 0x04}, // 178 - twosuperior + {0x05, 0x07, 0x07}, // 179 - threesuperior + {0x00, 0x02, 0x01}, // 180 - acute + {0x1f, 0x08, 0x07}, // 181 - mu + {0x02, 0x1d, 0x1f}, // 182 - paragraph + {0x0e, 0x0e, 0x0e}, // 183 - periodcentered + {0x10, 0x14, 0x08}, // 184 - cedilla + {0x00, 0x07, 0x00}, // 185 - onesuperior + {0x12, 0x15, 0x12}, // 186 - ordmasculine + {0x00, 0x05, 0x02}, // 187 - guillemotright + {0x03, 0x08, 0x18}, // 188 - onequarter + {0x0b, 0x18, 0x10}, // 189 - onehalf + {0x03, 0x0b, 0x18}, // 190 - threequarters + {0x18, 0x15, 0x10}, // 191 - questiondown +}; diff --git a/font.h b/font.h index b3dbe4a..0e6a0c6 100644 --- a/font.h +++ b/font.h @@ -26,6 +26,8 @@ extern const uint8_t g_font_small[95][6]; #ifdef ENABLE_SMALL_BOLD extern const uint8_t g_font_small_bold[95][6]; #endif +//extern const uint8_t g_font_small_4x5[95][4]; +extern const uint8_t g_font3x5[160][3]; #endif diff --git a/settings.h b/settings.h index ace90f1..6cc312f 100644 --- a/settings.h +++ b/settings.h @@ -135,52 +135,59 @@ typedef enum mdf_display_mode_e mdf_display_mode_t; // 16 bytes typedef struct { // [0] - uint32_t frequency; // + uint32_t frequency; // // [4] - uint32_t offset; // + uint32_t offset; // // [8] - uint8_t rx_ctcss_cdcss_code; // + uint8_t rx_ctcss_cdcss_code; // // [9] - uint8_t tx_ctcss_cdcss_code; // + uint8_t tx_ctcss_cdcss_code; // // [10] - uint8_t rx_ctcss_cdcss_type:2; // - uint8_t unused1:2; // - uint8_t tx_ctcss_cdcss_type:2; // - uint8_t unused2:2; // + uint8_t rx_ctcss_cdcss_type:2; // + uint8_t unused1:2; // + uint8_t tx_ctcss_cdcss_type:2; // + uint8_t unused2:2; // // [11] - uint8_t tx_offset_dir:2; // - uint8_t unused3:2; // - uint8_t am_mode:1; // - uint8_t unused4:3; // + uint8_t tx_offset_dir:2; // + uint8_t unused3:2; // + uint8_t am_mode:1; // + uint8_t unused4:3; // // [12] - uint8_t frequency_reverse:1; // reverse repeater - uint8_t channel_bandwidth:1; // wide/narrow - uint8_t tx_power:2; // 0, 1 or 2 .. L, M or H - uint8_t busy_channel_lock:1; // + uint8_t frequency_reverse:1; // reverse repeater + uint8_t channel_bandwidth:1; // wide/narrow + uint8_t tx_power:2; // 0, 1 or 2 .. L, M or H + uint8_t busy_channel_lock:1; // #if 0 // QS - uint8_t unused5:3; // + uint8_t unused5:3; // #else // 1of11 - uint8_t unused5:1; // - uint8_t compand:2; // 0 = off, 1 = TX, 2 = RX, 3 = TX/RX + uint8_t unused5:1; // + uint8_t compand:2; // 0 = off, 1 = TX, 2 = RX, 3 = TX/RX #endif // [13] - uint8_t dtmf_decoding_enable:1; // - uint8_t dtmf_ptt_id_tx_mode:3; // - uint8_t unused6:4; // + uint8_t dtmf_decoding_enable:1; // + uint8_t dtmf_ptt_id_tx_mode:3; // + uint8_t unused6:4; // // [14] - uint8_t step_setting; // + uint8_t step_setting; // // [15] - uint8_t scrambler:4; // + uint8_t scrambler:4; // #if 0 // QS - uint8_t unused7:4; // + uint8_t unused7:4; // #else // 1of11 - uint8_t squelch_level:4; // 0 ~ 9 per channel squelch, 0 = use main squelch level + uint8_t squelch_level:4; // 0 ~ 9 per channel squelch, 0 = use main squelch level #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 typedef struct { @@ -270,12 +277,7 @@ typedef struct { } __attribute__((packed)); // // 0x0D60 - struct { // these channel attribute settings could have been in the t_channel structure ! - 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]; // + t_channel_attr channel_attr[200]; // 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 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 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 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 #endif diff --git a/ui/helper.c b/ui/helper.c index e439db3..ff652e9 100644 --- a/ui/helper.c +++ b/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) { diff --git a/ui/helper.h b/ui/helper.h index 6a4d115..536e26d 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -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); diff --git a/ui/main.c b/ui/main.c index 4faa8df..48d78fa 100644 --- a/ui/main.c +++ b/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" @@ -399,6 +400,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]; @@ -752,19 +754,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 } @@ -852,6 +857,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 diff --git a/utils/main.cpp b/utils/main.cpp index ec5d917..aecd428 100644 --- a/utils/main.cpp +++ b/utils/main.cpp @@ -20,6 +20,10 @@ #include #include +#ifndef ARRAY_SIZE + #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + // ************************************************************************ // create a front end gain table for the firmware @@ -346,7 +350,7 @@ void create_gain_table(const char *filename) 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 @@ -397,19 +401,19 @@ void rotate_font(const char *filename1, const char *filename2) { uint8_t c1[8]; uint8_t c2[8]; - memcpy(c1, &data[i], 8); - memset(c2, 0, 8); - for (unsigned int k = 0; k < 8; k++) + memcpy(c1, &data[i], ARRAY_SIZE(c1)); + memset(c2, 0, ARRAY_SIZE(c2)); + for (unsigned int k = 0; k < ARRAY_SIZE(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) c2[m] |= 1u << k; 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, "{\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]; memset(s, 0, sizeof(s)); @@ -445,13 +449,122 @@ void rotate_font(const char *filename1, const char *filename2) else { 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 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"); @@ -466,8 +579,9 @@ int main(int argc, char* argv[]) { create_gain_table("gain_table.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.bin", "uv-k5_small.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; } diff --git a/utils/misc.exe b/utils/misc.exe index e81385a..507a27e 100644 Binary files a/utils/misc.exe and b/utils/misc.exe differ diff --git a/utils/uv-k5_small_4x5.bin b/utils/uv-k5_small_4x5.bin new file mode 100644 index 0000000..0ec28eb Binary files /dev/null and b/utils/uv-k5_small_4x5.bin differ