mirror of
https://codeberg.org/mclemens/ubitxv6.git
synced 2024-11-19 01:16:07 -05:00
Refactor BFO settings menu
This commit is contained in:
parent
315d9348f0
commit
b99e13eff4
55
setup.cpp
55
setup.cpp
@ -78,7 +78,7 @@ struct SettingScreen_t {
|
|||||||
const char* const Title;
|
const char* const Title;
|
||||||
const char* const AdditionalText;
|
const char* const AdditionalText;
|
||||||
const uint16_t KnobDivider;
|
const uint16_t KnobDivider;
|
||||||
const uint16_t StepSize;
|
const int16_t StepSize;//int so that it can be negative
|
||||||
void (*Initialize)(long int* start_value_out);
|
void (*Initialize)(long int* start_value_out);
|
||||||
void (*Validate)(const long int candidate_value_in, long int* validated_value_out);
|
void (*Validate)(const long int candidate_value_in, long int* validated_value_out);
|
||||||
void (*OnValueChange)(const long int new_value, char* buff_out, const size_t buff_out_size);
|
void (*OnValueChange)(const long int new_value, char* buff_out, const size_t buff_out_size);
|
||||||
@ -111,7 +111,7 @@ void runSetting(const SettingScreen_t* const p_screen)
|
|||||||
{
|
{
|
||||||
int knob = enc_read();
|
int knob = enc_read();
|
||||||
if(knob != 0){
|
if(knob != 0){
|
||||||
raw_value += knob * (int32_t)screen.StepSize;
|
raw_value += knob * screen.StepSize;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
continue;
|
continue;
|
||||||
@ -141,6 +141,7 @@ void runSetting(const SettingScreen_t* const p_screen)
|
|||||||
|
|
||||||
#define LIMIT(val,min,max) ((val) < (min)) ? (min) : (((max) < (val)) ? (max) : (val))
|
#define LIMIT(val,min,max) ((val) < (min)) ? (min) : (((max) < (val)) ? (max) : (val))
|
||||||
|
|
||||||
|
//CW Tone
|
||||||
ssCwToneInitialize(long int* start_value_out)
|
ssCwToneInitialize(long int* start_value_out)
|
||||||
{
|
{
|
||||||
*start_value_out = globalSettings.cwSideToneFreq;
|
*start_value_out = globalSettings.cwSideToneFreq;
|
||||||
@ -176,11 +177,11 @@ const SettingScreen_t ssTone PROGMEM = {
|
|||||||
};
|
};
|
||||||
void runToneSetting(){runSetting(&ssTone);}
|
void runToneSetting(){runSetting(&ssTone);}
|
||||||
|
|
||||||
|
//Local Oscillator
|
||||||
void ssLocalOscInitialize(long int* start_value_out){
|
void ssLocalOscInitialize(long int* start_value_out){
|
||||||
//round off the current frequency the nearest kHz
|
|
||||||
{
|
{
|
||||||
uint32_t freq = GetActiveVfoFreq();
|
uint32_t freq = GetActiveVfoFreq();
|
||||||
freq = (freq/1000L) * 1000L;
|
freq = (freq/1000L) * 1000L;//round off the current frequency the nearest kHz
|
||||||
setFrequency(freq);
|
setFrequency(freq);
|
||||||
si5351bx_setfreq(0, globalSettings.usbCarrierFreq); //set back the carrier oscillator, cw tx switches it off
|
si5351bx_setfreq(0, globalSettings.usbCarrierFreq); //set back the carrier oscillator, cw tx switches it off
|
||||||
}
|
}
|
||||||
@ -223,32 +224,42 @@ const SettingScreen_t ssLocalOsc PROGMEM = {
|
|||||||
};
|
};
|
||||||
void runLocalOscSetting(){runSetting(&ssLocalOsc);}
|
void runLocalOscSetting(){runSetting(&ssLocalOsc);}
|
||||||
|
|
||||||
void setupBFO(){
|
//BFO
|
||||||
//displayDialog(F("Set BFO"),F("Press TUNE to Save"));
|
void ssBfoInitialize(long int* start_value_out){
|
||||||
|
|
||||||
si5351bx_setfreq(0, globalSettings.usbCarrierFreq);
|
si5351bx_setfreq(0, globalSettings.usbCarrierFreq);
|
||||||
//printCarrierFreq(globalSettings.usbCarrierFreq);
|
*start_value_out = globalSettings.usbCarrierFreq;
|
||||||
|
|
||||||
while (!btnDown()){
|
|
||||||
int knob = enc_read();
|
|
||||||
if(knob != 0){
|
|
||||||
globalSettings.usbCarrierFreq -= 50 * knob;
|
|
||||||
}
|
}
|
||||||
else{
|
void ssBfoValidate(const long int candidate_value_in, long int* validated_value_out)
|
||||||
continue; //don't update the frequency or the display
|
{
|
||||||
|
*validated_value_out = LIMIT(candidate_value_in,11048000L,11060000L);
|
||||||
}
|
}
|
||||||
|
void ssBfoChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
||||||
si5351bx_setfreq(0, globalSettings.usbCarrierFreq);
|
{
|
||||||
|
si5351bx_setfreq(0, new_value);
|
||||||
setFrequency(GetActiveVfoFreq());
|
setFrequency(GetActiveVfoFreq());
|
||||||
//printCarrierFreq(globalSettings.usbCarrierFreq);
|
formatFreq(new_value,buff_out,buff_out_size);
|
||||||
|
strncat_P(buff_out,(const char*)F("Hz"),buff_out_size - strlen(buff_out));
|
||||||
active_delay(100);
|
|
||||||
}
|
}
|
||||||
|
void ssBfoFinalize(const long int final_value)
|
||||||
|
{
|
||||||
|
globalSettings.usbCarrierFreq = final_value;
|
||||||
SaveSettingsToEeprom();
|
SaveSettingsToEeprom();
|
||||||
si5351bx_setfreq(0, globalSettings.usbCarrierFreq);
|
si5351bx_setfreq(0, globalSettings.usbCarrierFreq);
|
||||||
setFrequency(GetActiveVfoFreq());
|
setFrequency(GetActiveVfoFreq());
|
||||||
}
|
}
|
||||||
|
const char SS_BFO_T [] PROGMEM = "Set BFO Calibration";
|
||||||
|
const char SS_BFO_A [] PROGMEM = "Exit menu, tune to an unused\nfrequency, then tune here\nuntil the audio is between\n300-3000Hz";
|
||||||
|
const SettingScreen_t ssBfo PROGMEM = {
|
||||||
|
SS_BFO_T,
|
||||||
|
SS_BFO_A,
|
||||||
|
1,
|
||||||
|
-50,//Negative to make dial more intuitive: turning clockwise increases the perceived audio frequency
|
||||||
|
ssBfoInitialize,
|
||||||
|
ssBfoValidate,
|
||||||
|
ssBfoChange,
|
||||||
|
ssBfoFinalize
|
||||||
|
};
|
||||||
|
void runBfoSetting(){runSetting(&ssBfo);}
|
||||||
|
|
||||||
void setupCwDelay(){
|
void setupCwDelay(){
|
||||||
int knob = 0;
|
int knob = 0;
|
||||||
@ -436,7 +447,7 @@ const char MI_TOUCH [] PROGMEM = "Touch Screen";
|
|||||||
const MenuItem_t calibrationMenu [] PROGMEM {
|
const MenuItem_t calibrationMenu [] PROGMEM {
|
||||||
{MT_CAL,nullptr},//Title
|
{MT_CAL,nullptr},//Title
|
||||||
{MI_SET_FREQ,runLocalOscSetting},
|
{MI_SET_FREQ,runLocalOscSetting},
|
||||||
{MI_SET_BFO,setupBFO},
|
{MI_SET_BFO,runBfoSetting},
|
||||||
{MI_TOUCH,setupTouch},
|
{MI_TOUCH,setupTouch},
|
||||||
};
|
};
|
||||||
void runCalibrationMenu(){RUN_MENU(calibrationMenu);}
|
void runCalibrationMenu(){RUN_MENU(calibrationMenu);}
|
||||||
|
6
setup.h
Normal file
6
setup.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void doSetup2(); //main setup function, displays the setup menu, calls various dialog boxes
|
||||||
|
void setupTouch();
|
||||||
|
void runLocalOscSetting();
|
||||||
|
void runBfoSetting();
|
@ -481,7 +481,7 @@ void setup()
|
|||||||
runLocalOscSetting();
|
runLocalOscSetting();
|
||||||
SetActiveVfoMode(VfoMode_e::VFO_MODE_LSB);
|
SetActiveVfoMode(VfoMode_e::VFO_MODE_LSB);
|
||||||
setFrequency(7100000L);
|
setFrequency(7100000L);
|
||||||
setupBFO();
|
runBfoSetting();
|
||||||
}
|
}
|
||||||
|
|
||||||
guiUpdate();
|
guiUpdate();
|
||||||
|
Loading…
Reference in New Issue
Block a user