mirror of
https://github.com/kamilsss655/uv-k5-firmware-custom
synced 2024-11-22 02:08:48 +00:00
Display frequencies >=1GHz
This commit is contained in:
parent
13b41abce6
commit
2f7042056a
12
misc.c
12
misc.c
@ -272,18 +272,6 @@ void NUMBER_Get(char *pDigits, uint32_t *pInteger)
|
||||
*pInteger = Value;
|
||||
}
|
||||
|
||||
void NUMBER_ToDigits(uint32_t Value, char *pDigits)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
const uint32_t Result = Value / 10U;
|
||||
pDigits[7 - i] = Value - (Result * 10U);
|
||||
Value = Result;
|
||||
}
|
||||
pDigits[8] = 0;
|
||||
}
|
||||
|
||||
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit)
|
||||
{
|
||||
Base += Add;
|
||||
|
1
misc.h
1
misc.h
@ -324,7 +324,6 @@ extern uint8_t gIsLocked;
|
||||
extern volatile uint8_t boot_counter_10ms;
|
||||
|
||||
void NUMBER_Get(char *pDigits, uint32_t *pInteger);
|
||||
void NUMBER_ToDigits(uint32_t Value, char *pDigits);
|
||||
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
|
||||
|
||||
#endif
|
||||
|
17
ui/aircopy.c
17
ui/aircopy.c
@ -44,12 +44,19 @@ void UI_DisplayAircopy(void)
|
||||
|
||||
if (gInputBoxIndex == 0)
|
||||
{
|
||||
NUMBER_ToDigits(gRxVfo->freq_config_RX.Frequency, String);
|
||||
UI_DisplayFrequency(String, 16, 2, 0, 0);
|
||||
UI_DisplaySmallDigits(2, String + 6, 97, 3, true);
|
||||
uint32_t frequency = gRxVfo->freq_config_RX.Frequency;
|
||||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||
// show the remaining 2 small frequency digits
|
||||
UI_PrintStringSmall(String + 7, 97, 0, 3);
|
||||
String[7] = 0;
|
||||
// show the main large frequency digits
|
||||
UI_DisplayFrequency(String, 16, 2, false);
|
||||
}
|
||||
else {
|
||||
const char * ascii = INPUTBOX_GetAscii();
|
||||
sprintf(String, "%.3s.%.3s",ascii, ascii + 3);
|
||||
UI_DisplayFrequency(String, 16, 2, false);
|
||||
}
|
||||
else
|
||||
UI_DisplayFrequency(gInputBox, 16, 2, 1, 0);
|
||||
|
||||
memset(String, 0, sizeof(String));
|
||||
if (gAirCopyIsSendMode == 0)
|
||||
|
11
ui/fmradio.c
11
ui/fmradio.c
@ -90,11 +90,14 @@ void UI_DisplayFM(void)
|
||||
{
|
||||
if (gInputBoxIndex == 0)
|
||||
{
|
||||
NUMBER_ToDigits(gEeprom.FM_FrequencyPlaying * 10000, String);
|
||||
UI_DisplayFrequency(String, 23, 4, false, true);
|
||||
sprintf(String, "%3d.%d", gEeprom.FM_FrequencyPlaying / 10, gEeprom.FM_FrequencyPlaying % 10);
|
||||
UI_DisplayFrequency(String, 32, 4, true);
|
||||
}
|
||||
else {
|
||||
const char * ascii = INPUTBOX_GetAscii();
|
||||
sprintf(String, "%.3s.%.1s",ascii, ascii + 3);
|
||||
UI_DisplayFrequency(String, 32, 4, false);
|
||||
}
|
||||
else
|
||||
UI_DisplayFrequency(gInputBox, 23, 4, true, false);
|
||||
|
||||
ST7565_BlitFullScreen();
|
||||
return;
|
||||
|
119
ui/helper.c
119
ui/helper.c
@ -144,117 +144,40 @@ void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag)
|
||||
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center)
|
||||
{
|
||||
const unsigned int char_width = 13;
|
||||
uint8_t *pFb0 = gFrameBuffer[Y] + X;
|
||||
uint8_t *pFb1 = pFb0 + 128;
|
||||
bool bCanDisplay = false;
|
||||
unsigned int i = 0;
|
||||
|
||||
// MHz
|
||||
while (i < 3)
|
||||
{
|
||||
const unsigned int Digit = pDigits[i++];
|
||||
if (bDisplayLeadingZero || bCanDisplay || Digit > 0)
|
||||
uint8_t len = strlen(string);
|
||||
for(int i = 0; i < len; i++) {
|
||||
const char c = string[i];
|
||||
if (bCanDisplay || c != ' ')
|
||||
{
|
||||
bCanDisplay = true;
|
||||
memmove(pFb0, gFontBigDigits[Digit], char_width);
|
||||
memmove(pFb1, gFontBigDigits[Digit] + char_width, char_width);
|
||||
if(c>='0' && c<='9') {
|
||||
memmove(pFb0, gFontBigDigits[c-'0'], char_width);
|
||||
memmove(pFb1, gFontBigDigits[c-'0'] + char_width, char_width);
|
||||
}
|
||||
else
|
||||
if (bFlag)
|
||||
{
|
||||
else if(c=='-') {
|
||||
memmove(pFb0, gFontBigDigits[10], char_width);
|
||||
memmove(pFb1, gFontBigDigits[10] + char_width, char_width);
|
||||
}
|
||||
else if(c=='.') {
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
else if (center) {
|
||||
pFb0 -= 6;
|
||||
pFb1 -= 6;
|
||||
}
|
||||
pFb0 += char_width;
|
||||
pFb1 += char_width;
|
||||
}
|
||||
|
||||
// decimal point
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
*pFb1 = 0x60; pFb0++; pFb1++;
|
||||
|
||||
// kHz
|
||||
while (i < 6)
|
||||
{
|
||||
const unsigned int Digit = pDigits[i++];
|
||||
memmove(pFb0, gFontBigDigits[Digit], char_width);
|
||||
memmove(pFb1, gFontBigDigits[Digit] + char_width, char_width);
|
||||
pFb0 += char_width;
|
||||
pFb1 += char_width;
|
||||
}
|
||||
}
|
||||
|
||||
void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero)
|
||||
{
|
||||
const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]);
|
||||
const unsigned int spacing = 1 + char_width;
|
||||
uint8_t *pFb = gFrameBuffer[Y] + X;
|
||||
bool bCanDisplay = false;
|
||||
unsigned int i = 0;
|
||||
|
||||
// MHz
|
||||
while (i < 3)
|
||||
{
|
||||
const unsigned int c = pDigits[i++];
|
||||
if (bDisplayLeadingZero || bCanDisplay || c > 0)
|
||||
{
|
||||
#if 0
|
||||
memmove(pFb + 1, gFontSmallDigits[c], char_width);
|
||||
#else
|
||||
const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32;
|
||||
memmove(pFb + 1, gFontSmall[index], char_width);
|
||||
#endif
|
||||
pFb += spacing;
|
||||
bCanDisplay = true;
|
||||
}
|
||||
}
|
||||
|
||||
// decimal point
|
||||
pFb++;
|
||||
pFb++;
|
||||
*pFb++ = 0x60;
|
||||
*pFb++ = 0x60;
|
||||
pFb++;
|
||||
|
||||
// kHz
|
||||
while (i < 8)
|
||||
{
|
||||
const unsigned int c = pDigits[i++];
|
||||
#if 0
|
||||
memmove(pFb + 1, gFontSmallDigits[c], char_width);
|
||||
#else
|
||||
const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32;
|
||||
memmove(pFb + 1, gFontSmall[index], char_width);
|
||||
#endif
|
||||
pFb += spacing;
|
||||
}
|
||||
}
|
||||
|
||||
void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros)
|
||||
{
|
||||
const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]);
|
||||
const unsigned int spacing = 1 + char_width;
|
||||
bool display = display_leading_zeros;
|
||||
unsigned int xx;
|
||||
unsigned int i;
|
||||
for (i = 0, xx = x; i < size; i++)
|
||||
{
|
||||
const unsigned int c = (unsigned int)str[i];
|
||||
if (c > 0)
|
||||
display = true; // non '0'
|
||||
if (display && c < 11)
|
||||
{
|
||||
#if 0
|
||||
memmove(gFrameBuffer[y] + xx, gFontSmallDigits[c], char_width);
|
||||
#else
|
||||
const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32;
|
||||
memmove(gFrameBuffer[y] + xx + 1, gFontSmall[index], char_width);
|
||||
#endif
|
||||
xx += spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,7 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_
|
||||
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||
#endif
|
||||
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer);
|
||||
void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag);
|
||||
void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero);
|
||||
void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros);
|
||||
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ui/inputbox.h"
|
||||
|
||||
char gInputBox[8];
|
||||
char inputBoxAscii[9];
|
||||
uint8_t gInputBoxIndex;
|
||||
|
||||
void INPUTBOX_Append(const KEY_Code_t Digit)
|
||||
@ -33,3 +34,11 @@ void INPUTBOX_Append(const KEY_Code_t Digit)
|
||||
gInputBox[gInputBoxIndex++] = (char)(Digit - KEY_0);
|
||||
}
|
||||
|
||||
const char* INPUTBOX_GetAscii()
|
||||
{
|
||||
for(int i = 0; i < 8; i++) {
|
||||
char c = gInputBox[i];
|
||||
inputBoxAscii[i] = (c==10)? '-' : '0' + c;
|
||||
}
|
||||
return inputBoxAscii;
|
||||
}
|
@ -25,6 +25,7 @@ extern char gInputBox[8];
|
||||
extern uint8_t gInputBoxIndex;
|
||||
|
||||
void INPUTBOX_Append(const KEY_Code_t Digit);
|
||||
const char* INPUTBOX_GetAscii();
|
||||
|
||||
#endif
|
||||
|
||||
|
58
ui/main.c
58
ui/main.c
@ -408,19 +408,17 @@ void UI_DisplayMain(void)
|
||||
const unsigned int x = 2;
|
||||
const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) ? false : true;
|
||||
if (!inputting)
|
||||
NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); // show the memory channel number
|
||||
sprintf(String, "M%u", gEeprom.ScreenChannel[vfo_num] + 1);
|
||||
else
|
||||
memmove(String + 5, gInputBox, 3); // show the input text
|
||||
UI_PrintStringSmall("M", x, 0, line + 1);
|
||||
UI_DisplaySmallDigits(3, String + 5, x + 7, line + 1, inputting);
|
||||
sprintf(String, "M%.3s", INPUTBOX_GetAscii()); // show the input text
|
||||
UI_PrintStringSmall(String, x, 0, line + 1);
|
||||
}
|
||||
else
|
||||
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
||||
{ // frequency mode
|
||||
// show the frequency band number
|
||||
const unsigned int x = 2; // was 14
|
||||
// sprintf(String, "FB%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST);
|
||||
sprintf(String, "VFO%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST);
|
||||
const unsigned int x = 2;
|
||||
sprintf(String, "FB%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST);
|
||||
UI_PrintStringSmall(String, x, 0, line + 1);
|
||||
}
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -460,7 +458,9 @@ void UI_DisplayMain(void)
|
||||
else
|
||||
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
|
||||
{ // user entering a frequency
|
||||
UI_DisplayFrequency(gInputBox, 32, line, true, false);
|
||||
const char * ascii = INPUTBOX_GetAscii();
|
||||
sprintf(String, "%.3s.%.3s", ascii, ascii + 3);
|
||||
UI_DisplayFrequency(String, 32, line, false);
|
||||
|
||||
// center_line = CENTER_LINE_IN_USE;
|
||||
}
|
||||
@ -496,17 +496,22 @@ void UI_DisplayMain(void)
|
||||
switch (gEeprom.CHANNEL_DISPLAY_MODE)
|
||||
{
|
||||
case MDF_FREQUENCY: // show the channel frequency
|
||||
#ifdef ENABLE_BIG_FREQ
|
||||
NUMBER_ToDigits(frequency, String);
|
||||
// show the main large frequency digits
|
||||
UI_DisplayFrequency(String, 32, line, false, false);
|
||||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||
#ifdef ENABLE_BIG_FREQ
|
||||
if(frequency < 100000000) {
|
||||
// show the remaining 2 small frequency digits
|
||||
UI_DisplaySmallDigits(2, String + 6, 113, line + 1, true);
|
||||
#else
|
||||
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
||||
String[7] = 0;
|
||||
// show the main large frequency digits
|
||||
UI_DisplayFrequency(String, 32, line, false);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// show the frequency in the main font
|
||||
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
||||
UI_PrintString(String, 32, 0, line, 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MDF_CHANNEL: // show the channel number
|
||||
@ -545,17 +550,22 @@ void UI_DisplayMain(void)
|
||||
}
|
||||
else
|
||||
{ // frequency mode
|
||||
#ifdef ENABLE_BIG_FREQ
|
||||
NUMBER_ToDigits(frequency, String); // 8 digits
|
||||
// show the main large frequency digits
|
||||
UI_DisplayFrequency(String, 32, line, false, false);
|
||||
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||
|
||||
#ifdef ENABLE_BIG_FREQ
|
||||
if(frequency < 100000000) {
|
||||
// show the remaining 2 small frequency digits
|
||||
UI_DisplaySmallDigits(2, String + 6, 113, line + 1, true);
|
||||
#else
|
||||
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
||||
String[7] = 0;
|
||||
// show the main large frequency digits
|
||||
UI_DisplayFrequency(String, 32, line, false);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// show the frequency in the main font
|
||||
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
||||
UI_PrintString(String, 32, 0, line, 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
// show the channel symbols
|
||||
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
||||
|
@ -974,10 +974,8 @@ void UI_DisplayMenu(void)
|
||||
GetCurrentMenuId() == MENU_T_DCS ||
|
||||
GetCurrentMenuId() == MENU_D_LIST)
|
||||
{
|
||||
unsigned int Offset;
|
||||
NUMBER_ToDigits(gSubMenuSelection, String);
|
||||
Offset = (GetCurrentMenuId() == MENU_D_LIST) ? 2 : 3;
|
||||
UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false);
|
||||
sprintf(String, "%2d", gSubMenuSelection);
|
||||
UI_PrintStringSmall(String, 105, 0, 0);
|
||||
}
|
||||
|
||||
if ((GetCurrentMenuId() == MENU_RESET ||
|
||||
|
Loading…
Reference in New Issue
Block a user