mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
trim away trailing zeros compile option
This commit is contained in:
parent
0d36e997d4
commit
74f52f9d14
4
Makefile
4
Makefile
@ -37,6 +37,7 @@ 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 := 0
|
ENABLE_SMALL_BOLD := 0
|
||||||
|
ENABLE_TRIM_TRAILING_ZEROS := 1
|
||||||
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
|
||||||
@ -304,6 +305,9 @@ endif
|
|||||||
ifeq ($(ENABLE_SMALL_BOLD),1)
|
ifeq ($(ENABLE_SMALL_BOLD),1)
|
||||||
CFLAGS += -DENABLE_SMALL_BOLD
|
CFLAGS += -DENABLE_SMALL_BOLD
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(ENABLE_TRIM_TRAILING_ZEROS),1)
|
||||||
|
CFLAGS += -DENABLE_TRIM_TRAILING_ZEROS
|
||||||
|
endif
|
||||||
ifeq ($(ENABLE_NOAA),1)
|
ifeq ($(ENABLE_NOAA),1)
|
||||||
CFLAGS += -DENABLE_NOAA
|
CFLAGS += -DENABLE_NOAA
|
||||||
endif
|
endif
|
||||||
|
@ -59,6 +59,7 @@ ENABLE_PWRON_PASSWORD := 0 include power-on password code
|
|||||||
ENABLE_RESET_AES_KEY := 1 '1' = reset/clear the AES key stored in the eeprom (only if it's set)
|
ENABLE_RESET_AES_KEY := 1 '1' = reset/clear the AES key stored in the eeprom (only if it's set)
|
||||||
ENABLE_BIG_FREQ := 0 big font frequencies (like original QS firmware)
|
ENABLE_BIG_FREQ := 0 big font frequencies (like original QS firmware)
|
||||||
ENABLE_SMALL_BOLD := 1 bold channel name/no. (when name + freq channel display mode)
|
ENABLE_SMALL_BOLD := 1 bold channel name/no. (when name + freq channel display mode)
|
||||||
|
ENABLE_TRIM_TRAILING_ZEROS := 1 trim away any trailing zeros on frequencies
|
||||||
ENABLE_KEEP_MEM_NAME := 1 maintain channel name when (re)saving memory channel
|
ENABLE_KEEP_MEM_NAME := 1 maintain channel name when (re)saving memory channel
|
||||||
ENABLE_WIDE_RX := 1 full 18MHz to 1300MHz RX (though front-end/PA not designed for full range)
|
ENABLE_WIDE_RX := 1 full 18MHz to 1300MHz RX (though front-end/PA not designed for full range)
|
||||||
ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM
|
ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM
|
||||||
|
10
misc.c
10
misc.c
@ -341,3 +341,13 @@ int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit,
|
|||||||
|
|
||||||
return Base;
|
return Base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NUMBER_trim_trailing_zeros(char *str)
|
||||||
|
{
|
||||||
|
if (str != NULL)
|
||||||
|
{
|
||||||
|
int i = (int)strlen(str) - 1;
|
||||||
|
while (i > 0 && (str[i] == '0' || str[i] == ' ') && str[i - 1] != '.')
|
||||||
|
str[i--] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1
misc.h
1
misc.h
@ -352,6 +352,7 @@ unsigned int get_RX_VFO(void);
|
|||||||
void NUMBER_Get(char *pDigits, uint32_t *pInteger);
|
void NUMBER_Get(char *pDigits, uint32_t *pInteger);
|
||||||
void NUMBER_ToDigits(uint32_t Value, char *pDigits);
|
void NUMBER_ToDigits(uint32_t Value, char *pDigits);
|
||||||
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
|
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
|
||||||
|
void NUMBER_trim_trailing_zeros(char *str);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -99,20 +99,21 @@ void UI_print_string(
|
|||||||
const unsigned int font_size,
|
const unsigned int font_size,
|
||||||
const unsigned int char_width)
|
const unsigned int char_width)
|
||||||
{
|
{
|
||||||
const unsigned int char_spacing = char_width + 1;
|
const unsigned int char_pitch = char_width + 1;
|
||||||
const size_t length = strlen(str);
|
const size_t length = strlen(str);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
uint8_t *f_buf;
|
uint8_t *f_buf;
|
||||||
|
|
||||||
if (end > start)
|
if (end > start)
|
||||||
start += ((end - start) - (length * char_spacing)) / 2;
|
start += ((end - start) - (length * char_pitch)) / 2;
|
||||||
|
|
||||||
f_buf = g_frame_buffer[line] + start;
|
f_buf = g_frame_buffer[line] + start;
|
||||||
|
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
const int c = (int)str[i] - ' ';
|
const int c = (int)str[i] - ' ';
|
||||||
if (c >= 0 && c < (int)font_size)
|
if (c >= 0 && c < (int)font_size)
|
||||||
memmove(f_buf + (char_spacing * i) + 1, font + (char_width * c), char_width);
|
memmove(f_buf + (char_pitch * i), font + (char_width * c), char_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
41
ui/main.c
41
ui/main.c
@ -643,6 +643,8 @@ void UI_DisplayMain(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const unsigned int x = 32;
|
||||||
|
|
||||||
uint32_t frequency = g_eeprom.vfo_info[vfo_num].p_rx->frequency;
|
uint32_t frequency = g_eeprom.vfo_info[vfo_num].p_rx->frequency;
|
||||||
if (g_current_function == FUNCTION_TRANSMIT)
|
if (g_current_function == FUNCTION_TRANSMIT)
|
||||||
{ // transmitting
|
{ // transmitting
|
||||||
@ -663,13 +665,16 @@ void UI_DisplayMain(void)
|
|||||||
#ifdef ENABLE_BIG_FREQ
|
#ifdef ENABLE_BIG_FREQ
|
||||||
NUMBER_ToDigits(frequency, String);
|
NUMBER_ToDigits(frequency, String);
|
||||||
// show the main large frequency digits
|
// show the main large frequency digits
|
||||||
UI_DisplayFrequency(String, 32, line, false, false);
|
UI_DisplayFrequency(String, x, line, false, false);
|
||||||
// show the remaining 2 small frequency digits
|
// show the remaining 2 small frequency digits
|
||||||
UI_Displaysmall_digits(2, String + 6, 113, line + 1, true);
|
UI_Displaysmall_digits(2, String + 6, x + 81, line + 1, true);
|
||||||
#else
|
#else
|
||||||
// show the frequency in the main font
|
// show the frequency in the main font
|
||||||
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
||||||
UI_PrintString(String, 32, 0, line, 8);
|
#ifdef ENABLE_TRIM_TRAILING_ZEROS
|
||||||
|
NUMBER_trim_trailing_zeros(String);
|
||||||
|
#endif
|
||||||
|
UI_PrintString(String, x, 0, line, 8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -677,7 +682,7 @@ void UI_DisplayMain(void)
|
|||||||
case MDF_CHANNEL: // just channel number
|
case MDF_CHANNEL: // just channel number
|
||||||
|
|
||||||
sprintf(String, "CH-%03u", g_eeprom.screen_channel[vfo_num] + 1);
|
sprintf(String, "CH-%03u", g_eeprom.screen_channel[vfo_num] + 1);
|
||||||
UI_PrintString(String, 32, 0, line, 8);
|
UI_PrintString(String, x, 0, line, 8);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -688,26 +693,29 @@ void UI_DisplayMain(void)
|
|||||||
|
|
||||||
if (String[0] == 0)
|
if (String[0] == 0)
|
||||||
{ // no channel name available, channel number instead
|
{ // no channel name available, channel number instead
|
||||||
sprintf(String, "CH-%03u", g_eeprom.screen_channel[vfo_num] + 1);
|
sprintf(String, "CH-%03u", 1 + g_eeprom.screen_channel[vfo_num]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_eeprom.channel_display_mode == MDF_NAME)
|
if (g_eeprom.channel_display_mode == MDF_NAME)
|
||||||
{ // just the name
|
{ // just the name
|
||||||
UI_PrintString(String, 32, 0, line, 8);
|
UI_PrintString(String, x, 0, line, 8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // name & frequency
|
{ // name & frequency
|
||||||
|
|
||||||
// name
|
// name
|
||||||
#ifdef ENABLE_SMALL_BOLD
|
#ifdef ENABLE_SMALL_BOLD
|
||||||
UI_PrintStringSmallBold(String, 32 + 4, 0, line);
|
UI_PrintStringSmallBold(String, x, 0, line);
|
||||||
#else
|
#else
|
||||||
UI_PrintStringSmall(String, 32 + 4, 0, line);
|
UI_PrintStringSmall(String, x, 0, line);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// frequency
|
// frequency
|
||||||
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
||||||
UI_PrintStringSmall(String, 32 + 4, 0, line + 1);
|
#ifdef ENABLE_TRIM_TRAILING_ZEROS
|
||||||
|
NUMBER_trim_trailing_zeros(String);
|
||||||
|
#endif
|
||||||
|
UI_PrintStringSmall(String, x, 0, line + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -719,15 +727,24 @@ void UI_DisplayMain(void)
|
|||||||
// if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]))
|
// if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]))
|
||||||
{ // frequency mode
|
{ // frequency mode
|
||||||
#ifdef ENABLE_BIG_FREQ
|
#ifdef ENABLE_BIG_FREQ
|
||||||
|
|
||||||
NUMBER_ToDigits(frequency, String); // 8 digits
|
NUMBER_ToDigits(frequency, String); // 8 digits
|
||||||
|
|
||||||
// show the main large frequency digits
|
// show the main large frequency digits
|
||||||
UI_DisplayFrequency(String, 32, line, false, false);
|
UI_DisplayFrequency(String, x, line, false, false);
|
||||||
|
|
||||||
// show the remaining 2 small frequency digits
|
// show the remaining 2 small frequency digits
|
||||||
UI_Displaysmall_digits(2, String + 6, 113, line + 1, true);
|
UI_Displaysmall_digits(2, String + 6, x + 81, line + 1, true);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// show the frequency in the main font
|
// show the frequency in the main font
|
||||||
|
|
||||||
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
||||||
UI_PrintString(String, 32, 0, line, 8);
|
#ifdef ENABLE_TRIM_TRAILING_ZEROS
|
||||||
|
NUMBER_trim_trailing_zeros(String);
|
||||||
|
#endif
|
||||||
|
UI_PrintString(String, x, 0, line, 8);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,11 +574,8 @@ void UI_DisplayMenu(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // kHz
|
{ // kHz
|
||||||
int i;
|
|
||||||
sprintf(String, "%u.%03u", step / 1000, step % 1000);
|
sprintf(String, "%u.%03u", step / 1000, step % 1000);
|
||||||
i = strlen(String) - 1;
|
NUMBER_trim_trailing_zeros(String);
|
||||||
while (i > 0 && String[i] == '0' && String[i - 1] != '.')
|
|
||||||
String[i--] = 0; // trim trailing zeros away
|
|
||||||
strcat(String, "kHz");
|
strcat(String, "kHz");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user