Fix auto-selection of sideband mode when tuning

This commit is contained in:
Reed Nightingale 2020-04-25 12:35:59 -07:00
parent 0f45a2fc43
commit fdd2afce98
4 changed files with 29 additions and 17 deletions

View File

@ -56,19 +56,12 @@ void mainMenuTune(int16_t knob)
current_freq = GetActiveVfoFreq();
const uint32_t new_freq = current_freq + (50 * knob);
//Transition from below to above the traditional threshold for USB
if(current_freq < THRESHOLD_USB_LSB && new_freq >= THRESHOLD_USB_LSB){
SetActiveVfoMode(VfoMode_e::VFO_MODE_USB);
updateSidebandButtons();
}
//Transition from above to below the traditional threshold for USB
if(current_freq >= THRESHOLD_USB_LSB && new_freq < THRESHOLD_USB_LSB){
SetActiveVfoMode(VfoMode_e::VFO_MODE_LSB);
setFrequency(new_freq);
if(autoSelectSidebandChanged(current_freq)){
updateSidebandButtons();
}
setFrequency(new_freq);
const uint32_t old_freq = current_freq;
current_freq = new_freq;

View File

@ -514,6 +514,9 @@ ButtonStatus_e bsBand(const uint8_t band){
void osBand(const uint8_t band){
const uint32_t old_freq = GetActiveVfoFreq();
SetActiveVfoFreq(getFreqInBand(old_freq,band));
if(autoSelectSidebandChanged(old_freq)){
updateSidebandButtons();
}
Button button;
if(Vfo_e::VFO_A == globalSettings.activeVfo){

View File

@ -5,10 +5,7 @@
#include "nano_gui.h"
#include "pin_definitions.h"
/**
* Below are the basic functions that control the uBitx. Understanding the functions before
* you start hacking around
*/
static const uint32_t THRESHOLD_USB_LSB = 10000000L;
void saveVFOs()
{
@ -198,4 +195,24 @@ void ritDisable(){
setFrequency(globalSettings.ritFrequency);
updateDisplay();
}
}
}
bool autoSelectSidebandChanged(const uint32_t old_frequency)
{
const uint32_t new_freq = GetActiveVfoFreq();
//Transition from below to above the traditional threshold for USB
if(old_frequency < THRESHOLD_USB_LSB && new_freq >= THRESHOLD_USB_LSB){
SetActiveVfoMode(VfoMode_e::VFO_MODE_USB);
setFrequency(new_freq);//Refresh tuning to activate the new sideband mode
return true;
}
//Transition from above to below the traditional threshold for USB
if(old_frequency >= THRESHOLD_USB_LSB && new_freq < THRESHOLD_USB_LSB){
SetActiveVfoMode(VfoMode_e::VFO_MODE_LSB);
setFrequency(new_freq);//Refresh tuning to activate the new sideband mode
return true;
}
return false;
}

View File

@ -18,5 +18,4 @@ void si5351bx_setfreq(uint8_t clknum, uint32_t fout);
void initOscillators();
void si5351_set_calibration(int32_t cal); //calibration is a small value that is nudged to make up for the inaccuracies of the reference 25 MHz crystal frequency
// limits the tuning and working range of the ubitx between 3 MHz and 30 MHz
static const uint32_t THRESHOLD_USB_LSB = 10000000L;
bool autoSelectSidebandChanged(const uint32_t old_frequency); //if the current frequency defaults to a different sideband mode, updates to that sideband mode and returns true. Else, returns false