Platform: Add frequency limit check
This commit is contained in:
parent
c2f331467c
commit
7a9135d746
|
|
@ -552,6 +552,20 @@ freq_t _ui_freq_add_digit(freq_t freq, uint8_t pos, uint8_t number)
|
||||||
return freq += number * coefficient;
|
return freq += number * coefficient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
void ui_updateFSM(event_t event, bool *sync_rtx)
|
void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
{
|
{
|
||||||
// Check if battery has enough charge to operate
|
// Check if battery has enough charge to operate
|
||||||
|
|
@ -577,18 +591,26 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
case VFO_MAIN:
|
case VFO_MAIN:
|
||||||
if(msg.keys & KEY_UP)
|
if(msg.keys & KEY_UP)
|
||||||
{
|
{
|
||||||
// Advance TX and RX frequency of 12.5KHz
|
// Increment TX and RX frequency of 12.5KHz
|
||||||
|
if(_ui_freq_check_limits(state.channel.rx_frequency + 12500) &&
|
||||||
|
_ui_freq_check_limits(state.channel.tx_frequency + 12500))
|
||||||
|
{
|
||||||
state.channel.rx_frequency += 12500;
|
state.channel.rx_frequency += 12500;
|
||||||
state.channel.tx_frequency += 12500;
|
state.channel.tx_frequency += 12500;
|
||||||
*sync_rtx = true;
|
*sync_rtx = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(msg.keys & KEY_DOWN)
|
else if(msg.keys & KEY_DOWN)
|
||||||
{
|
{
|
||||||
// Advance TX and RX frequency of 12.5KHz
|
// Decrement TX and RX frequency of 12.5KHz
|
||||||
|
if(_ui_freq_check_limits(state.channel.rx_frequency - 12500) &&
|
||||||
|
_ui_freq_check_limits(state.channel.tx_frequency - 12500))
|
||||||
|
{
|
||||||
state.channel.rx_frequency -= 12500;
|
state.channel.rx_frequency -= 12500;
|
||||||
state.channel.tx_frequency -= 12500;
|
state.channel.tx_frequency -= 12500;
|
||||||
*sync_rtx = true;
|
*sync_rtx = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(msg.keys & KEY_ENTER)
|
else if(msg.keys & KEY_ENTER)
|
||||||
// Open Menu
|
// Open Menu
|
||||||
state.ui_screen = MENU_TOP;
|
state.ui_screen = MENU_TOP;
|
||||||
|
|
@ -622,16 +644,23 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
// Save new frequency setting
|
// Save new frequency setting
|
||||||
// If TX frequency was not set, TX = RX
|
// If TX frequency was not set, TX = RX
|
||||||
if(new_tx_frequency == 0)
|
if(new_tx_frequency == 0)
|
||||||
|
{
|
||||||
|
if(_ui_freq_check_limits(new_rx_frequency))
|
||||||
{
|
{
|
||||||
state.channel.rx_frequency = new_rx_frequency;
|
state.channel.rx_frequency = new_rx_frequency;
|
||||||
state.channel.tx_frequency = new_rx_frequency;
|
state.channel.tx_frequency = new_rx_frequency;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Otherwise set both frequencies
|
// Otherwise set both frequencies
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if(_ui_freq_check_limits(new_rx_frequency) &&
|
||||||
|
_ui_freq_check_limits(new_tx_frequency))
|
||||||
{
|
{
|
||||||
state.channel.rx_frequency = new_rx_frequency;
|
state.channel.rx_frequency = new_rx_frequency;
|
||||||
state.channel.tx_frequency = new_tx_frequency;
|
state.channel.tx_frequency = new_tx_frequency;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
state.ui_screen = VFO_MAIN;
|
state.ui_screen = VFO_MAIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -679,8 +708,12 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
||||||
if(input_position >= (FREQ_DIGITS))
|
if(input_position >= (FREQ_DIGITS))
|
||||||
{
|
{
|
||||||
// Save both inserted frequencies
|
// Save both inserted frequencies
|
||||||
|
if(_ui_freq_check_limits(new_rx_frequency) &&
|
||||||
|
_ui_freq_check_limits(new_tx_frequency))
|
||||||
|
{
|
||||||
state.channel.rx_frequency = new_rx_frequency;
|
state.channel.rx_frequency = new_rx_frequency;
|
||||||
state.channel.tx_frequency = new_tx_frequency;
|
state.channel.tx_frequency = new_tx_frequency;
|
||||||
|
}
|
||||||
state.ui_screen = VFO_MAIN;
|
state.ui_screen = VFO_MAIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,16 @@
|
||||||
|
|
||||||
#include "MK22F51212.h"
|
#include "MK22F51212.h"
|
||||||
|
|
||||||
|
/* Supported radio bands */
|
||||||
|
#define BAND_VHF
|
||||||
|
#define BAND_UHF
|
||||||
|
|
||||||
|
/* Band limits in Hz */
|
||||||
|
#define FREQ_LIMIT_VHF_LO 136000000
|
||||||
|
#define FREQ_LIMIT_VHF_HI 136000000
|
||||||
|
#define FREQ_LIMIT_UHF_LO 400000000
|
||||||
|
#define FREQ_LIMIT_UHF_HI 470000000
|
||||||
|
|
||||||
/* Screen dimensions */
|
/* Screen dimensions */
|
||||||
#define SCREEN_WIDTH 128
|
#define SCREEN_WIDTH 128
|
||||||
#define SCREEN_HEIGHT 64
|
#define SCREEN_HEIGHT 64
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,16 @@
|
||||||
|
|
||||||
#include "MK22F51212.h"
|
#include "MK22F51212.h"
|
||||||
|
|
||||||
|
/* Supported radio bands */
|
||||||
|
#define BAND_VHF
|
||||||
|
#define BAND_UHF
|
||||||
|
|
||||||
|
/* Band limits in Hz */
|
||||||
|
#define FREQ_LIMIT_VHF_LO 136000000
|
||||||
|
#define FREQ_LIMIT_VHF_HI 136000000
|
||||||
|
#define FREQ_LIMIT_UHF_LO 400000000
|
||||||
|
#define FREQ_LIMIT_UHF_HI 470000000
|
||||||
|
|
||||||
/* Screen dimensions */
|
/* Screen dimensions */
|
||||||
#define SCREEN_WIDTH 128
|
#define SCREEN_WIDTH 128
|
||||||
#define SCREEN_HEIGHT 64
|
#define SCREEN_HEIGHT 64
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,16 @@
|
||||||
|
|
||||||
#include <stm32f4xx.h>
|
#include <stm32f4xx.h>
|
||||||
|
|
||||||
|
/* Supported radio bands */
|
||||||
|
#define BAND_VHF
|
||||||
|
#define BAND_UHF
|
||||||
|
|
||||||
|
/* Band limits in Hz */
|
||||||
|
#define FREQ_LIMIT_VHF_LO 136000000
|
||||||
|
#define FREQ_LIMIT_VHF_HI 136000000
|
||||||
|
#define FREQ_LIMIT_UHF_LO 400000000
|
||||||
|
#define FREQ_LIMIT_UHF_HI 480000000
|
||||||
|
|
||||||
/* Screen dimensions */
|
/* Screen dimensions */
|
||||||
#define SCREEN_WIDTH 160
|
#define SCREEN_WIDTH 160
|
||||||
#define SCREEN_HEIGHT 128
|
#define SCREEN_HEIGHT 128
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,16 @@
|
||||||
|
|
||||||
#include <stm32f4xx.h>
|
#include <stm32f4xx.h>
|
||||||
|
|
||||||
|
/* Supported radio bands */
|
||||||
|
#define BAND_VHF
|
||||||
|
#define BAND_UHF
|
||||||
|
|
||||||
|
/* Band limits in Hz */
|
||||||
|
#define FREQ_LIMIT_VHF_LO 136000000
|
||||||
|
#define FREQ_LIMIT_VHF_HI 136000000
|
||||||
|
#define FREQ_LIMIT_UHF_LO 400000000
|
||||||
|
#define FREQ_LIMIT_UHF_HI 480000000
|
||||||
|
|
||||||
/* Screen dimensions */
|
/* Screen dimensions */
|
||||||
#define SCREEN_WIDTH 160
|
#define SCREEN_WIDTH 160
|
||||||
#define SCREEN_HEIGHT 128
|
#define SCREEN_HEIGHT 128
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,16 @@
|
||||||
|
|
||||||
#include <stm32f4xx.h>
|
#include <stm32f4xx.h>
|
||||||
|
|
||||||
|
/* Supported radio bands */
|
||||||
|
#define BAND_VHF
|
||||||
|
#define BAND_UHF
|
||||||
|
|
||||||
|
/* Band limits in Hz */
|
||||||
|
#define FREQ_LIMIT_VHF_LO 136000000
|
||||||
|
#define FREQ_LIMIT_VHF_HI 136000000
|
||||||
|
#define FREQ_LIMIT_UHF_LO 400000000
|
||||||
|
#define FREQ_LIMIT_UHF_HI 480000000
|
||||||
|
|
||||||
/* Screen dimensions */
|
/* Screen dimensions */
|
||||||
#define SCREEN_WIDTH 160
|
#define SCREEN_WIDTH 160
|
||||||
#define SCREEN_HEIGHT 128
|
#define SCREEN_HEIGHT 128
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,16 @@
|
||||||
|
|
||||||
#define PLATFORM_LINUX
|
#define PLATFORM_LINUX
|
||||||
|
|
||||||
|
/* Supported radio bands */
|
||||||
|
#define BAND_VHF
|
||||||
|
#define BAND_UHF
|
||||||
|
|
||||||
|
/* Band limits in Hz */
|
||||||
|
#define FREQ_LIMIT_VHF_LO 136000000
|
||||||
|
#define FREQ_LIMIT_VHF_HI 136000000
|
||||||
|
#define FREQ_LIMIT_UHF_LO 400000000
|
||||||
|
#define FREQ_LIMIT_UHF_HI 480000000
|
||||||
|
|
||||||
/* Battery type */
|
/* Battery type */
|
||||||
#define BAT_LIPO_2S
|
#define BAT_LIPO_2S
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue