Check frequency limits against hwInfo_t, not hardcoded defines

This commit is contained in:
Federico Amedeo Izzo 2021-06-05 10:47:52 +02:00
parent 5b3f2b7e23
commit f5c9d97e49
2 changed files with 23 additions and 10 deletions

View File

@ -436,14 +436,21 @@ void _ui_timedate_add_digit(curTime_t *timedate, uint8_t pos, uint8_t number)
bool _ui_freq_check_limits(freq_t freq)
{
bool valid = false;
#ifdef BAND_VHF
if(freq >= FREQ_LIMIT_VHF_LO && freq <= FREQ_LIMIT_VHF_HI)
valid = true;
#endif
#ifdef BAND_UHF
if(freq >= FREQ_LIMIT_UHF_LO && freq <= FREQ_LIMIT_UHF_HI)
valid = true;
#endif
const hwInfo_t* hwinfo = platform_getHwInfo();
if(hwinfo->vhf_band)
{
// hwInfo_t frequencies are in MHz
if(freq >= (hwinfo->vhf_minFreq * 1000000) &&
freq <= (hwinfo->vhf_maxFreq * 1000000))
valid = true;
}
if(hwinfo->uhf_band)
{
// hwInfo_t frequencies are in MHz
if(freq >= (hwinfo->uhf_minFreq * 1000000) &&
freq <= (hwinfo->uhf_maxFreq * 1000000))
valid = true;
}
return valid;
}

View File

@ -26,9 +26,15 @@ void platform_init()
{
//printf("Platform init\n");
// Fill hwinfo struct
memset(&hwInfo, 0x00, sizeof(hwInfo));
snprintf(hwInfo.name, 10, "Linux");
hwInfo.vhf_band = 1;
hwInfo.uhf_band = 1;
// Frequencies are in MHz
hwInfo.vhf_maxFreq = 174;
hwInfo.vhf_minFreq = 136;
hwInfo.vhf_band = 1;
hwInfo.uhf_maxFreq = 480;
hwInfo.uhf_minFreq = 400;
hwInfo.uhf_band = 1;
emulator_start();
}