Support for >1GHz frequencies input

This commit is contained in:
Krzysiek Egzmont 2023-10-20 00:15:11 +02:00
parent a5fa0b1e4b
commit d132969c91
8 changed files with 65 additions and 46 deletions

View File

@ -131,8 +131,7 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
gInputBoxIndex = 0; gInputBoxIndex = 0;
Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
NUMBER_Get(gInputBox, &Frequency);
for (i = 0; i < ARRAY_SIZE(frequencyBandTable); i++) for (i = 0; i < ARRAY_SIZE(frequencyBandTable); i++)
{ {

View File

@ -277,8 +277,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
uint32_t Frequency; uint32_t Frequency;
gInputBoxIndex = 0; gInputBoxIndex = 0;
NUMBER_Get(gInputBox, &Frequency); Frequency = StrToUL(INPUTBOX_GetAscii());
Frequency /= 10000;
if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency)
{ {

View File

@ -18,15 +18,19 @@
#include "app/action.h" #include "app/action.h"
#include "app/app.h" #include "app/app.h"
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/generic.h" #include "app/generic.h"
#include "app/main.h" #include "app/main.h"
#include "app/scanner.h" #include "app/scanner.h"
#ifdef ENABLE_SPECTRUM #ifdef ENABLE_SPECTRUM
#include "app/spectrum.h" #include "app/spectrum.h"
#endif #endif
#include "audio.h" #include "audio.h"
#include "board.h" #include "board.h"
#include "driver/bk4819.h" #include "driver/bk4819.h"
@ -37,9 +41,7 @@
#include "settings.h" #include "settings.h"
#include "ui/inputbox.h" #include "ui/inputbox.h"
#include "ui/ui.h" #include "ui/ui.h"
#ifdef ENABLE_SPECTRUM #include <stdlib.h>
// #include "app/spectrum.h"
#endif
void toggle_chan_scanlist(void) void toggle_chan_scanlist(void)
{ // toggle the selected channels scanlist setting { // toggle the selected channels scanlist setting
@ -98,26 +100,31 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break; break;
case KEY_1: case KEY_1:
if (!IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (!IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
{
gWasFKeyPressed = false; gWasFKeyPressed = false;
gUpdateStatus = true; gUpdateStatus = true;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return; return;
} }
if(gTxVfo->Band == 6 && gTxVfo->pRX->Frequency < 100000000) {
gTxVfo->pRX->Frequency = 100000000;
return;
}
else {
Band = gTxVfo->Band + 1; Band = gTxVfo->Band + 1;
if (gSetting_350EN || Band != BAND5_350MHz) if (gSetting_350EN || Band != BAND5_350MHz) {
{
if (Band > BAND7_470MHz) if (Band > BAND7_470MHz)
Band = BAND1_50MHz; Band = BAND1_50MHz;
} }
else else
Band = BAND6_400MHz; Band = BAND6_400MHz;
gTxVfo->Band = Band; gTxVfo->Band = Band;
gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + Band; gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + Band; gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
}
gRequestSaveVFO = true; gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
@ -361,8 +368,8 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ // user is entering a frequency { // user is entering a frequency
uint32_t Frequency; uint32_t Frequency;
bool isGigaF = gTxVfo->pRX->Frequency >= 100000000;
if (gInputBoxIndex < 6) if (gInputBoxIndex < 6 + isGigaF)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; gAnotherVoiceID = (VOICE_ID_t)Key;
@ -372,8 +379,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
gInputBoxIndex = 0; gInputBoxIndex = 0;
Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
NUMBER_Get(gInputBox, &Frequency);
// clamp the frequency entered to some valid value // clamp the frequency entered to some valid value
if (Frequency < frequencyBandTable[0].lower) if (Frequency < frequencyBandTable[0].lower)

View File

@ -1262,7 +1262,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gAnotherVoiceID = (VOICE_ID_t)Key; gAnotherVoiceID = (VOICE_ID_t)Key;
#endif #endif
NUMBER_Get(gInputBox, &Frequency); Frequency = StrToUL(INPUTBOX_GetAscii());
gSubMenuSelection = FREQUENCY_FloorToStep(Frequency + 75, gTxVfo->StepFrequency, 0); gSubMenuSelection = FREQUENCY_FloorToStep(Frequency + 75, gTxVfo->StepFrequency, 0);
gInputBoxIndex = 0; gInputBoxIndex = 0;

27
misc.c
View File

@ -254,20 +254,7 @@ int16_t gCurrentRSSI[2] = {0, 0}; // now one per VFO
uint8_t gIsLocked = 0xFF; uint8_t gIsLocked = 0xFF;
void NUMBER_Get(char *pDigits, uint32_t *pInteger)
{
unsigned int i;
uint32_t Multiplier = 10000000;
uint32_t Value = 0;
for (i = 0; i < 8; i++)
{
if (pDigits[i] > 9)
break;
Value += pDigits[i] * Multiplier;
Multiplier /= 10U;
}
*pInteger = Value;
}
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)
{ {
@ -281,3 +268,15 @@ int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit,
return Base; return Base;
} }
unsigned long StrToUL(const char * str)
{
unsigned long ul = 0;
for(uint8_t i = 0; i < strlen(str); i++){
char c = str[i];
if(c < '0' || c > '9')
break;
ul = ul * 10 + (uint8_t)(c-'0');
}
return ul;
}

2
misc.h
View File

@ -324,8 +324,8 @@ extern int16_t gCurrentRSSI[2]; // now one per VFO
extern uint8_t gIsLocked; 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);
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);
unsigned long StrToUL(const char * str);
#endif #endif

View File

@ -102,10 +102,9 @@ void UI_DisplayLock(void)
uint32_t Password; uint32_t Password;
gInputBoxIndex = 0; gInputBoxIndex = 0;
Password = StrToUL(INPUTBOX_GetAscii());
NUMBER_Get(gInputBox, &Password); if ((gEeprom.POWER_ON_PASSWORD) == Password)
if ((gEeprom.POWER_ON_PASSWORD * 100) == Password)
{ {
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL); AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
return; return;

View File

@ -433,6 +433,8 @@ void UI_DisplayMain(void)
} }
#endif #endif
uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
if (state != VFO_STATE_NORMAL) if (state != VFO_STATE_NORMAL)
{ {
const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALARM", "VOLT HIGH"}; const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALARM", "VOLT HIGH"};
@ -442,12 +444,27 @@ void UI_DisplayMain(void)
else if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num) else if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
{ // user entering a frequency { // user entering a frequency
const char * ascii = INPUTBOX_GetAscii(); const char * ascii = INPUTBOX_GetAscii();
sprintf(String, "%.3s.%.3s", ascii, ascii + 3); bool isGigaF = frequency>=100000000;
sprintf(String, "%.*s.%.3s", 3 + isGigaF, ascii, ascii + 3 + isGigaF);
#ifdef ENABLE_BIG_FREQ
if(!isGigaF) {
// show the remaining 2 small frequency digits
UI_PrintStringSmall(String + 7, 113, 0, line + 1);
String[7] = 0;
// show the main large frequency digits
UI_DisplayFrequency(String, 32, line, false); UI_DisplayFrequency(String, 32, line, false);
} }
else else
#endif
{
// show the frequency in the main font
UI_PrintString(String, 32, 0, line, 8);
}
break;
}
else
{ {
uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting { // transmitting
if (activeTxVFO == vfo_num) if (activeTxVFO == vfo_num)