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;
|
*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)
|
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit)
|
||||||
{
|
{
|
||||||
Base += Add;
|
Base += Add;
|
||||||
|
1
misc.h
1
misc.h
@ -324,7 +324,6 @@ extern uint8_t gIsLocked;
|
|||||||
extern volatile uint8_t boot_counter_10ms;
|
extern volatile uint8_t boot_counter_10ms;
|
||||||
|
|
||||||
void NUMBER_Get(char *pDigits, uint32_t *pInteger);
|
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);
|
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
17
ui/aircopy.c
17
ui/aircopy.c
@ -44,12 +44,19 @@ void UI_DisplayAircopy(void)
|
|||||||
|
|
||||||
if (gInputBoxIndex == 0)
|
if (gInputBoxIndex == 0)
|
||||||
{
|
{
|
||||||
NUMBER_ToDigits(gRxVfo->freq_config_RX.Frequency, String);
|
uint32_t frequency = gRxVfo->freq_config_RX.Frequency;
|
||||||
UI_DisplayFrequency(String, 16, 2, 0, 0);
|
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||||
UI_DisplaySmallDigits(2, String + 6, 97, 3, true);
|
// 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));
|
memset(String, 0, sizeof(String));
|
||||||
if (gAirCopyIsSendMode == 0)
|
if (gAirCopyIsSendMode == 0)
|
||||||
|
11
ui/fmradio.c
11
ui/fmradio.c
@ -90,11 +90,14 @@ void UI_DisplayFM(void)
|
|||||||
{
|
{
|
||||||
if (gInputBoxIndex == 0)
|
if (gInputBoxIndex == 0)
|
||||||
{
|
{
|
||||||
NUMBER_ToDigits(gEeprom.FM_FrequencyPlaying * 10000, String);
|
sprintf(String, "%3d.%d", gEeprom.FM_FrequencyPlaying / 10, gEeprom.FM_FrequencyPlaying % 10);
|
||||||
UI_DisplayFrequency(String, 23, 4, false, true);
|
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();
|
ST7565_BlitFullScreen();
|
||||||
return;
|
return;
|
||||||
|
121
ui/helper.c
121
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;
|
const unsigned int char_width = 13;
|
||||||
uint8_t *pFb0 = gFrameBuffer[Y] + X;
|
uint8_t *pFb0 = gFrameBuffer[Y] + X;
|
||||||
uint8_t *pFb1 = pFb0 + 128;
|
uint8_t *pFb1 = pFb0 + 128;
|
||||||
bool bCanDisplay = false;
|
bool bCanDisplay = false;
|
||||||
unsigned int i = 0;
|
|
||||||
|
uint8_t len = strlen(string);
|
||||||
// MHz
|
for(int i = 0; i < len; i++) {
|
||||||
while (i < 3)
|
const char c = string[i];
|
||||||
{
|
if (bCanDisplay || c != ' ')
|
||||||
const unsigned int Digit = pDigits[i++];
|
|
||||||
if (bDisplayLeadingZero || bCanDisplay || Digit > 0)
|
|
||||||
{
|
{
|
||||||
bCanDisplay = true;
|
bCanDisplay = true;
|
||||||
memmove(pFb0, gFontBigDigits[Digit], char_width);
|
if(c>='0' && c<='9') {
|
||||||
memmove(pFb1, gFontBigDigits[Digit] + char_width, char_width);
|
memmove(pFb0, gFontBigDigits[c-'0'], char_width);
|
||||||
|
memmove(pFb1, gFontBigDigits[c-'0'] + char_width, char_width);
|
||||||
|
}
|
||||||
|
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
|
else if (center) {
|
||||||
if (bFlag)
|
|
||||||
{
|
|
||||||
pFb0 -= 6;
|
pFb0 -= 6;
|
||||||
pFb1 -= 6;
|
pFb1 -= 6;
|
||||||
}
|
}
|
||||||
pFb0 += char_width;
|
pFb0 += char_width;
|
||||||
pFb1 += 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);
|
void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||||
#endif
|
#endif
|
||||||
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 bFlag);
|
void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center);
|
||||||
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);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "ui/inputbox.h"
|
#include "ui/inputbox.h"
|
||||||
|
|
||||||
char gInputBox[8];
|
char gInputBox[8];
|
||||||
|
char inputBoxAscii[9];
|
||||||
uint8_t gInputBoxIndex;
|
uint8_t gInputBoxIndex;
|
||||||
|
|
||||||
void INPUTBOX_Append(const KEY_Code_t Digit)
|
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);
|
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;
|
extern uint8_t gInputBoxIndex;
|
||||||
|
|
||||||
void INPUTBOX_Append(const KEY_Code_t Digit);
|
void INPUTBOX_Append(const KEY_Code_t Digit);
|
||||||
|
const char* INPUTBOX_GetAscii();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
58
ui/main.c
58
ui/main.c
@ -408,19 +408,17 @@ void UI_DisplayMain(void)
|
|||||||
const unsigned int x = 2;
|
const unsigned int x = 2;
|
||||||
const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) ? false : true;
|
const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) ? false : true;
|
||||||
if (!inputting)
|
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
|
else
|
||||||
memmove(String + 5, gInputBox, 3); // show the input text
|
sprintf(String, "M%.3s", INPUTBOX_GetAscii()); // show the input text
|
||||||
UI_PrintStringSmall("M", x, 0, line + 1);
|
UI_PrintStringSmall(String, x, 0, line + 1);
|
||||||
UI_DisplaySmallDigits(3, String + 5, x + 7, line + 1, inputting);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
||||||
{ // frequency mode
|
{ // frequency mode
|
||||||
// show the frequency band number
|
// show the frequency band number
|
||||||
const unsigned int x = 2; // was 14
|
const unsigned int x = 2;
|
||||||
// sprintf(String, "FB%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST);
|
sprintf(String, "FB%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST);
|
||||||
sprintf(String, "VFO%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST);
|
|
||||||
UI_PrintStringSmall(String, x, 0, line + 1);
|
UI_PrintStringSmall(String, x, 0, line + 1);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
@ -460,7 +458,9 @@ void UI_DisplayMain(void)
|
|||||||
else
|
else
|
||||||
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
|
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
|
||||||
{ // user entering a frequency
|
{ // 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;
|
// center_line = CENTER_LINE_IN_USE;
|
||||||
}
|
}
|
||||||
@ -496,17 +496,22 @@ void UI_DisplayMain(void)
|
|||||||
switch (gEeprom.CHANNEL_DISPLAY_MODE)
|
switch (gEeprom.CHANNEL_DISPLAY_MODE)
|
||||||
{
|
{
|
||||||
case MDF_FREQUENCY: // show the channel frequency
|
case MDF_FREQUENCY: // show the channel frequency
|
||||||
#ifdef ENABLE_BIG_FREQ
|
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||||
NUMBER_ToDigits(frequency, String);
|
#ifdef ENABLE_BIG_FREQ
|
||||||
// show the main large frequency digits
|
if(frequency < 100000000) {
|
||||||
UI_DisplayFrequency(String, 32, line, false, false);
|
|
||||||
// show the remaining 2 small frequency digits
|
// show the remaining 2 small frequency digits
|
||||||
UI_DisplaySmallDigits(2, String + 6, 113, line + 1, true);
|
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
||||||
#else
|
String[7] = 0;
|
||||||
|
// show the main large frequency digits
|
||||||
|
UI_DisplayFrequency(String, 32, line, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
// show the frequency in the main font
|
// show the frequency in the main font
|
||||||
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
|
||||||
UI_PrintString(String, 32, 0, line, 8);
|
UI_PrintString(String, 32, 0, line, 8);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MDF_CHANNEL: // show the channel number
|
case MDF_CHANNEL: // show the channel number
|
||||||
@ -545,17 +550,22 @@ void UI_DisplayMain(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // frequency mode
|
{ // frequency mode
|
||||||
#ifdef ENABLE_BIG_FREQ
|
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
|
||||||
NUMBER_ToDigits(frequency, String); // 8 digits
|
|
||||||
// show the main large frequency digits
|
#ifdef ENABLE_BIG_FREQ
|
||||||
UI_DisplayFrequency(String, 32, line, false, false);
|
if(frequency < 100000000) {
|
||||||
// show the remaining 2 small frequency digits
|
// show the remaining 2 small frequency digits
|
||||||
UI_DisplaySmallDigits(2, String + 6, 113, line + 1, true);
|
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
|
||||||
#else
|
String[7] = 0;
|
||||||
|
// show the main large frequency digits
|
||||||
|
UI_DisplayFrequency(String, 32, line, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
// show the frequency in the main font
|
// show the frequency in the main font
|
||||||
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
|
|
||||||
UI_PrintString(String, 32, 0, line, 8);
|
UI_PrintString(String, 32, 0, line, 8);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// show the channel symbols
|
// show the channel symbols
|
||||||
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
|
||||||
|
@ -974,10 +974,8 @@ void UI_DisplayMenu(void)
|
|||||||
GetCurrentMenuId() == MENU_T_DCS ||
|
GetCurrentMenuId() == MENU_T_DCS ||
|
||||||
GetCurrentMenuId() == MENU_D_LIST)
|
GetCurrentMenuId() == MENU_D_LIST)
|
||||||
{
|
{
|
||||||
unsigned int Offset;
|
sprintf(String, "%2d", gSubMenuSelection);
|
||||||
NUMBER_ToDigits(gSubMenuSelection, String);
|
UI_PrintStringSmall(String, 105, 0, 0);
|
||||||
Offset = (GetCurrentMenuId() == MENU_D_LIST) ? 2 : 3;
|
|
||||||
UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((GetCurrentMenuId() == MENU_RESET ||
|
if ((GetCurrentMenuId() == MENU_RESET ||
|
||||||
|
Loading…
Reference in New Issue
Block a user