mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-19 06:39:49 +03:00
Simplified the frequency band table(s)
This commit is contained in:
@ -134,9 +134,9 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
|
||||
NUMBER_Get(gInputBox, &Frequency);
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
for (i = 0; i < ARRAY_SIZE(frequencyBandTable); i++)
|
||||
{
|
||||
if (Frequency >= LowerLimitFrequencyBandTable[i] && Frequency <= UpperLimitFrequencyBandTable[i])
|
||||
if (Frequency >= frequencyBandTable[i].lower && Frequency < frequencyBandTable[i].upper)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
|
10
app/app.c
10
app/app.c
@ -613,7 +613,7 @@ uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step)
|
||||
|
||||
if (pInfo->StepFrequency == 833)
|
||||
{
|
||||
const uint32_t Lower = LowerLimitFrequencyBandTable[pInfo->Band];
|
||||
const uint32_t Lower = frequencyBandTable[pInfo->Band].lower;
|
||||
const uint32_t Delta = Frequency - Lower;
|
||||
uint32_t Base = (Delta / 2500) * 2500;
|
||||
const uint32_t Index = ((Delta - Base) % 2500) / 833;
|
||||
@ -624,11 +624,11 @@ uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step)
|
||||
Frequency = Lower + Base + (Index * 833);
|
||||
}
|
||||
|
||||
if (Frequency > UpperLimitFrequencyBandTable[pInfo->Band])
|
||||
Frequency = LowerLimitFrequencyBandTable[pInfo->Band];
|
||||
if (Frequency >= frequencyBandTable[pInfo->Band].upper)
|
||||
Frequency = frequencyBandTable[pInfo->Band].lower;
|
||||
else
|
||||
if (Frequency < LowerLimitFrequencyBandTable[pInfo->Band])
|
||||
Frequency = FREQUENCY_FloorToStep(UpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, LowerLimitFrequencyBandTable[pInfo->Band]);
|
||||
if (Frequency < frequencyBandTable[pInfo->Band].lower)
|
||||
Frequency = FREQUENCY_FloorToStep(frequencyBandTable[pInfo->Band].upper, pInfo->StepFrequency, frequencyBandTable[pInfo->Band].lower);
|
||||
|
||||
return Frequency;
|
||||
}
|
||||
|
22
app/main.c
22
app/main.c
@ -352,20 +352,20 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
NUMBER_Get(gInputBox, &Frequency);
|
||||
|
||||
// clamp the frequency entered to some valid value
|
||||
if (Frequency < LowerLimitFrequencyBandTable[0])
|
||||
if (Frequency < frequencyBandTable[0].lower)
|
||||
{
|
||||
Frequency = LowerLimitFrequencyBandTable[0];
|
||||
Frequency = frequencyBandTable[0].lower;
|
||||
}
|
||||
else
|
||||
if (Frequency >= bx_stop1_Hz && Frequency < bx_start2_Hz)
|
||||
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
|
||||
{
|
||||
const uint32_t center = (bx_stop1_Hz + bx_start2_Hz) / 2;
|
||||
Frequency = (Frequency < center) ? bx_stop1_Hz : bx_start2_Hz;
|
||||
const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2;
|
||||
Frequency = (Frequency < center) ? BX4819_band1.upper : BX4819_band2.lower;
|
||||
}
|
||||
else
|
||||
if (Frequency > UpperLimitFrequencyBandTable[6])
|
||||
if (Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper)
|
||||
{
|
||||
Frequency = UpperLimitFrequencyBandTable[6];
|
||||
Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper;
|
||||
}
|
||||
|
||||
{
|
||||
@ -389,12 +389,12 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
// Frequency += 75; // is this meant to be rounding ?
|
||||
Frequency += gTxVfo->StepFrequency / 2; // no idea, but this is
|
||||
|
||||
Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, LowerLimitFrequencyBandTable[gTxVfo->Band]);
|
||||
Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, frequencyBandTable[gTxVfo->Band].lower);
|
||||
|
||||
if (Frequency >= bx_stop1_Hz && Frequency < bx_start2_Hz)
|
||||
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
|
||||
{ // clamp the frequency to the limit
|
||||
const uint32_t center = (bx_stop1_Hz + bx_start2_Hz) / 2;
|
||||
Frequency = (Frequency < center) ? bx_stop1_Hz - gTxVfo->StepFrequency : bx_start2_Hz;
|
||||
const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2;
|
||||
Frequency = (Frequency < center) ? BX4819_band1.upper - gTxVfo->StepFrequency : BX4819_band2.lower;
|
||||
}
|
||||
|
||||
gTxVfo->freq_config_RX.Frequency = Frequency;
|
||||
|
Reference in New Issue
Block a user