mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 22:31:25 +03:00
Frequency enter tidy up
This commit is contained in:
parent
f55a2b6a6d
commit
86525941bc
66
app/main.c
66
app/main.c
@ -351,9 +351,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (Frequency >= bx_stop1_Hz && Frequency < bx_start2_Hz)
|
if (Frequency >= bx_stop1_Hz && Frequency < bx_start2_Hz)
|
||||||
{ // move the frequency to the closest limit
|
{
|
||||||
const uint32_t center = (bx_stop1_Hz + bx_start2_Hz) / 2;
|
const uint32_t center = (bx_stop1_Hz + bx_start2_Hz) / 2;
|
||||||
Frequency = (Frequency < center) ? bx_stop1_Hz - 10 : bx_start2_Hz;
|
Frequency = (Frequency < center) ? bx_stop1_Hz : bx_start2_Hz;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (Frequency > UpperLimitFrequencyBandTable[6])
|
if (Frequency > UpperLimitFrequencyBandTable[6])
|
||||||
@ -362,46 +362,38 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);
|
||||||
for (i = 0; i < 7; i++)
|
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (gTxVfo->Band != band)
|
||||||
{
|
{
|
||||||
if (Frequency >= LowerLimitFrequencyBandTable[i] && Frequency <= UpperLimitFrequencyBandTable[i])
|
gTxVfo->Band = band;
|
||||||
{
|
gEeprom.ScreenChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||||
#ifdef ENABLE_VOICE
|
gEeprom.FreqChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gTxVfo->Band != i)
|
SETTINGS_SaveVfoIndices();
|
||||||
{
|
|
||||||
gTxVfo->Band = i;
|
|
||||||
gEeprom.ScreenChannel[Vfo] = i + FREQ_CHANNEL_FIRST;
|
|
||||||
gEeprom.FreqChannel[Vfo] = i + FREQ_CHANNEL_FIRST;
|
|
||||||
|
|
||||||
SETTINGS_SaveVfoIndices();
|
RADIO_ConfigureChannel(Vfo, 2);
|
||||||
|
|
||||||
RADIO_ConfigureChannel(Vfo, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Frequency += 75; // is this for rounding
|
|
||||||
Frequency += gTxVfo->StepFrequency / 2; // this is though
|
|
||||||
|
|
||||||
Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, LowerLimitFrequencyBandTable[gTxVfo->Band]);
|
|
||||||
|
|
||||||
// clamp the frequency entered to some valid value
|
|
||||||
|
|
||||||
if (Frequency >= bx_stop1_Hz && Frequency < bx_start2_Hz)
|
|
||||||
{ // use the step size to properly limit the frequency
|
|
||||||
const uint32_t center = (bx_stop1_Hz + bx_start2_Hz) / 2;
|
|
||||||
Frequency = (Frequency < center) ? bx_stop1_Hz - gTxVfo->StepFrequency : bx_start2_Hz;
|
|
||||||
}
|
|
||||||
|
|
||||||
gTxVfo->freq_config_RX.Frequency = Frequency;
|
|
||||||
|
|
||||||
gRequestSaveChannel = 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Frequency += 75; // is this meant to be rounding to step size?
|
||||||
|
Frequency += gTxVfo->StepFrequency / 2; // no idea, but this is
|
||||||
|
|
||||||
|
Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, LowerLimitFrequencyBandTable[gTxVfo->Band]);
|
||||||
|
|
||||||
|
if (Frequency >= bx_stop1_Hz && Frequency < bx_start2_Hz)
|
||||||
|
{ // 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
gTxVfo->freq_config_RX.Frequency = Frequency;
|
||||||
|
|
||||||
|
gRequestSaveChannel = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
@ -110,27 +110,11 @@ const uint32_t UpperLimitFrequencyBandTable[7] =
|
|||||||
|
|
||||||
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
|
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
|
||||||
{
|
{
|
||||||
// if (Frequency >= 60000000 && Frequency <= bx_max_Hz)
|
int band;
|
||||||
// return BAND7_470MHz;
|
for (band = BAND7_470MHz; band >= BAND1_50MHz; band--)
|
||||||
if (Frequency >= 47000000)
|
if (Frequency >= LowerLimitFrequencyBandTable[band])
|
||||||
return BAND7_470MHz;
|
return band;
|
||||||
if (Frequency >= 40000000)
|
return BAND1_50MHz;
|
||||||
return BAND6_400MHz;
|
|
||||||
if (Frequency >= 35000000)
|
|
||||||
return BAND5_350MHz;
|
|
||||||
if (Frequency >= 17400000)
|
|
||||||
return BAND4_174MHz;
|
|
||||||
if (Frequency >= 13600000)
|
|
||||||
return BAND3_136MHz;
|
|
||||||
if (Frequency >= 10800000)
|
|
||||||
return BAND2_108MHz;
|
|
||||||
if (Frequency >= 5000000)
|
|
||||||
return BAND1_50MHz;
|
|
||||||
// if (Frequency >= bx_min_Hz)
|
|
||||||
return BAND1_50MHz;
|
|
||||||
|
|
||||||
// TODO: Double check the assembly
|
|
||||||
// return BAND6_400MHz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency)
|
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency)
|
||||||
|
@ -29,7 +29,8 @@ extern const uint32_t bx_stop2_Hz;
|
|||||||
|
|
||||||
enum FREQUENCY_Band_t
|
enum FREQUENCY_Band_t
|
||||||
{
|
{
|
||||||
BAND1_50MHz = 0,
|
BAND1_NONE = -1,
|
||||||
|
BAND1_50MHz = 0,
|
||||||
BAND2_108MHz,
|
BAND2_108MHz,
|
||||||
BAND3_136MHz,
|
BAND3_136MHz,
|
||||||
BAND4_174MHz,
|
BAND4_174MHz,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user