From a8910e1ba27a1ae08e2d16bf874106ae7fc1d292 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sat, 25 Jan 2020 11:57:04 -0800 Subject: [PATCH 1/3] Auto-update sideband mode based on keyed-in frequency --- ubitx_ui.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/ubitx_ui.cpp b/ubitx_ui.cpp index 6f11eb7..0832138 100644 --- a/ubitx_ui.cpp +++ b/ubitx_ui.cpp @@ -415,16 +415,29 @@ void enterFreq(){ switch(button.id){ case KEYS_OK: { - long freq = atol(c); - if((LOWEST_FREQ/1000 <= freq) && (freq <= HIGHEST_FREQ/1000)){ - freq *= 1000L; - setFrequency(freq); + long new_freq = atol(c); + if((LOWEST_FREQ/1000 <= new_freq) && (new_freq <= HIGHEST_FREQ/1000)){ + new_freq *= 1000L; + + long prev_freq = GetActiveVfoFreq(); + //Transition from below to above the traditional threshold for USB + if(prev_freq < THRESHOLD_USB_LSB && new_freq >= THRESHOLD_USB_LSB){ + SetActiveVfoMode(VfoMode_e::VFO_MODE_USB); + } + + //Transition from aboveo to below the traditional threshold for USB + if(prev_freq >= THRESHOLD_USB_LSB && new_freq < THRESHOLD_USB_LSB){ + SetActiveVfoMode(VfoMode_e::VFO_MODE_LSB); + } + if (VFO_A == globalSettings.activeVfo){ - globalSettings.vfoA.frequency = freq; + globalSettings.vfoA.frequency = new_freq; } else{ - globalSettings.vfoB.frequency = freq; + globalSettings.vfoB.frequency = new_freq; } + + setFrequency(new_freq); saveVFOs(); } guiUpdate(); From 54e4d4bf061b624b11136dc569cbe4be90257f67 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sat, 25 Jan 2020 12:02:30 -0800 Subject: [PATCH 2/3] When sideband mode is changed, immediately update tuning --- ubitx_ui.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ubitx_ui.cpp b/ubitx_ui.cpp index 0832138..d553244 100644 --- a/ubitx_ui.cpp +++ b/ubitx_ui.cpp @@ -619,10 +619,13 @@ void cwToggle(struct Button *b){ } void sidebandToggle(Button* button){ - if(BUTTON_LSB == button->id) + if(BUTTON_LSB == button->id){ SetActiveVfoMode(VfoMode_e::VFO_MODE_LSB); - else + } + else{ SetActiveVfoMode(VfoMode_e::VFO_MODE_USB); + } + setFrequency(GetActiveVfoFreq()); struct Button button2; getButton(BUTTON_USB, &button2); From 95ea5b0ee2a99acd6d3bcf461d4bc674d9f7db15 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 11:26:18 -0800 Subject: [PATCH 3/3] Use unsigned ints for frequency --- ubitx_ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ubitx_ui.cpp b/ubitx_ui.cpp index 58828fe..321c1a8 100644 --- a/ubitx_ui.cpp +++ b/ubitx_ui.cpp @@ -416,11 +416,11 @@ void enterFreq(){ switch(button.id){ case KEYS_OK: { - long new_freq = atol(c); + uint32_t new_freq = atol(c); if((LOWEST_FREQ/1000 <= new_freq) && (new_freq <= HIGHEST_FREQ/1000)){ new_freq *= 1000L; - long prev_freq = GetActiveVfoFreq(); + uint32_t prev_freq = GetActiveVfoFreq(); //Transition from below to above the traditional threshold for USB if(prev_freq < THRESHOLD_USB_LSB && new_freq >= THRESHOLD_USB_LSB){ SetActiveVfoMode(VfoMode_e::VFO_MODE_USB);