mirror of
https://codeberg.org/mclemens/ubitxv6.git
synced 2024-09-10 14:24:22 -04:00
Refactor cw switch delay
This commit is contained in:
parent
58bfe55620
commit
dc1da20b13
68
setup.cpp
68
setup.cpp
@ -226,22 +226,22 @@ const SettingScreen_t ssBfo PROGMEM = {
|
|||||||
void runBfoSetting(){runSetting(&ssBfo);}
|
void runBfoSetting(){runSetting(&ssBfo);}
|
||||||
|
|
||||||
//CW Tone
|
//CW Tone
|
||||||
ssCwToneInitialize(long int* start_value_out)
|
void ssCwToneInitialize(long int* start_value_out)
|
||||||
{
|
{
|
||||||
*start_value_out = globalSettings.cwSideToneFreq;
|
*start_value_out = globalSettings.cwSideToneFreq;
|
||||||
}
|
}
|
||||||
ssCwToneValidate(const long int candidate_value_in, long int* validated_value_out)
|
void ssCwToneValidate(const long int candidate_value_in, long int* validated_value_out)
|
||||||
{
|
{
|
||||||
*validated_value_out = LIMIT(candidate_value_in,100,2000);
|
*validated_value_out = LIMIT(candidate_value_in,100,2000);
|
||||||
}
|
}
|
||||||
ssCwToneChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
void ssCwToneChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
||||||
{
|
{
|
||||||
globalSettings.cwSideToneFreq = new_value;
|
globalSettings.cwSideToneFreq = new_value;
|
||||||
tone(CW_TONE, globalSettings.cwSideToneFreq);
|
tone(CW_TONE, globalSettings.cwSideToneFreq);
|
||||||
ltoa(globalSettings.cwSideToneFreq,buff_out,10);
|
ltoa(globalSettings.cwSideToneFreq,buff_out,10);
|
||||||
strncat_P(buff_out,(const char*)F("Hz"),buff_out_size - strlen(buff_out));
|
strncat_P(buff_out,(const char*)F("Hz"),buff_out_size - strlen(buff_out));
|
||||||
}
|
}
|
||||||
ssCwToneFinalize(const long int final_value)
|
void ssCwToneFinalize(const long int final_value)
|
||||||
{
|
{
|
||||||
noTone(CW_TONE);
|
noTone(CW_TONE);
|
||||||
globalSettings.cwSideToneFreq = final_value;
|
globalSettings.cwSideToneFreq = final_value;
|
||||||
@ -261,36 +261,38 @@ const SettingScreen_t ssTone PROGMEM = {
|
|||||||
};
|
};
|
||||||
void runToneSetting(){runSetting(&ssTone);}
|
void runToneSetting(){runSetting(&ssTone);}
|
||||||
|
|
||||||
void setupCwDelay(){
|
//CW Switch Delay
|
||||||
int knob = 0;
|
void ssCwSwitchDelayInitialize(long int* start_value_out)
|
||||||
int prev_cw_delay;
|
{
|
||||||
|
*start_value_out = globalSettings.cwActiveTimeoutMs;
|
||||||
//displayDialog(F("Set CW T/R Delay"),F("Press tune to Save"));
|
}
|
||||||
|
void ssCwSwitchDelayValidate(const long int candidate_value_in, long int* validated_value_out)
|
||||||
prev_cw_delay = globalSettings.cwActiveTimeoutMs;
|
{
|
||||||
|
*validated_value_out = LIMIT(candidate_value_in,100,1000);
|
||||||
ltoa(globalSettings.cwActiveTimeoutMs, b, 10);
|
}
|
||||||
strncat_P(b,(const char*)F(" msec"),sizeof(b) - strlen(b));
|
void ssCwSwitchDelayChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
||||||
displayText(b, LAYOUT_SETTING_VALUE_X, LAYOUT_SETTING_VALUE_Y, LAYOUT_SETTING_VALUE_WIDTH, LAYOUT_SETTING_VALUE_HEIGHT, COLOR_TEXT, COLOR_SETTING_BACKGROUND, COLOR_BACKGROUND);
|
{
|
||||||
|
ltoa(new_value,buff_out,10);
|
||||||
while (!btnDown()){
|
strncat_P(buff_out,(const char*)F("ms"),buff_out_size - strlen(buff_out));
|
||||||
knob = enc_read();
|
}
|
||||||
|
void ssCwSwitchDelayFinalize(const long int final_value)
|
||||||
if (knob < 0 && globalSettings.cwActiveTimeoutMs > 100)
|
{
|
||||||
globalSettings.cwActiveTimeoutMs -= 100;
|
globalSettings.cwActiveTimeoutMs = final_value;
|
||||||
else if (knob > 0 && globalSettings.cwActiveTimeoutMs < 1000)
|
|
||||||
globalSettings.cwActiveTimeoutMs += 100;
|
|
||||||
else
|
|
||||||
continue; //don't update the frequency or the display
|
|
||||||
|
|
||||||
ltoa(globalSettings.cwActiveTimeoutMs, b, 10);
|
|
||||||
strncat_P(b,(const char*)F(" msec"),sizeof(b) - strlen(b));
|
|
||||||
displayText(b, LAYOUT_SETTING_VALUE_X, LAYOUT_SETTING_VALUE_Y, LAYOUT_SETTING_VALUE_WIDTH, LAYOUT_SETTING_VALUE_HEIGHT, COLOR_TEXT, COLOR_SETTING_BACKGROUND, COLOR_BACKGROUND);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveSettingsToEeprom();
|
SaveSettingsToEeprom();
|
||||||
}
|
}
|
||||||
|
const char SS_CW_SWITCH_T [] PROGMEM = "Set CW Tx/Rx Switch Delay";
|
||||||
|
const char SS_CW_SWITCH_A [] PROGMEM = "Select how long the radio\nshould wait before switching\nbetween TX and RX when in\nCW mode";
|
||||||
|
const SettingScreen_t ssCwSwitchDelay PROGMEM = {
|
||||||
|
SS_CW_SWITCH_T,
|
||||||
|
SS_CW_SWITCH_A,
|
||||||
|
1,
|
||||||
|
100,
|
||||||
|
ssCwSwitchDelayInitialize,
|
||||||
|
ssCwSwitchDelayValidate,
|
||||||
|
ssCwSwitchDelayChange,
|
||||||
|
ssCwSwitchDelayFinalize
|
||||||
|
};
|
||||||
|
void runCwSwitchDelaySetting(){runSetting(&ssCwSwitchDelay);}
|
||||||
|
|
||||||
void formatKeyerEnum(char* output, const KeyerMode_e mode)
|
void formatKeyerEnum(char* output, const KeyerMode_e mode)
|
||||||
{
|
{
|
||||||
@ -461,7 +463,7 @@ const MenuItem_t cwMenu [] PROGMEM {
|
|||||||
{MT_CW,nullptr},//Title
|
{MT_CW,nullptr},//Title
|
||||||
{MI_CW_SPEED,setupCwSpeed},
|
{MI_CW_SPEED,setupCwSpeed},
|
||||||
{MI_CW_TONE,runToneSetting},
|
{MI_CW_TONE,runToneSetting},
|
||||||
{MI_CW_DELAY,setupCwDelay},
|
{MI_CW_DELAY,runCwSwitchDelaySetting},
|
||||||
{MI_CW_KEYER,setupKeyer},
|
{MI_CW_KEYER,setupKeyer},
|
||||||
};
|
};
|
||||||
void runCwMenu(){RUN_MENU(cwMenu);}
|
void runCwMenu(){RUN_MENU(cwMenu);}
|
||||||
|
Loading…
Reference in New Issue
Block a user