mirror of
https://codeberg.org/mclemens/ubitxv6.git
synced 2024-08-12 21:44:14 -04:00
Refactor cw play speed setting
This commit is contained in:
parent
ece69fff3a
commit
850cda59e4
53
setup.cpp
53
setup.cpp
@ -334,32 +334,37 @@ const SettingScreen_t ssKeyer PROGMEM = {
|
|||||||
};
|
};
|
||||||
void runKeyerSetting(){runSetting(&ssKeyer);}
|
void runKeyerSetting(){runSetting(&ssKeyer);}
|
||||||
|
|
||||||
void setupCwSpeed()
|
//CW Speed
|
||||||
|
void ssCwSpeedInitialize(long int* start_value_out)
|
||||||
{
|
{
|
||||||
//displayDialog(F("Set CW Speed (WPM)"),F("Press tune to Save"));
|
*start_value_out = 1200L/globalSettings.cwDitDurationMs;
|
||||||
|
}
|
||||||
unsigned int wpm = 1200/globalSettings.cwDitDurationMs;
|
void ssCwSpeedValidate(const long int candidate_value_in, long int* validated_value_out)
|
||||||
|
{
|
||||||
itoa(wpm, b, 10);
|
*validated_value_out = LIMIT(candidate_value_in,1,100);
|
||||||
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);
|
}
|
||||||
|
void ssCwSpeedChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
||||||
while (!btnDown()){
|
{
|
||||||
int knob = enc_read();
|
ltoa(new_value, buff_out, 10);
|
||||||
|
}
|
||||||
if (knob < 0 && wpm > 1)
|
void ssCwSpeedFinalize(const long int final_value)
|
||||||
--wpm;
|
{
|
||||||
else if (knob > 0 && wpm < 100)
|
globalSettings.cwDitDurationMs = 1200L/final_value;
|
||||||
++wpm;
|
|
||||||
else
|
|
||||||
continue;//don't update the frequency or the display
|
|
||||||
|
|
||||||
itoa(wpm, b, 10);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
globalSettings.cwDitDurationMs = 1200/wpm;
|
|
||||||
SaveSettingsToEeprom();
|
SaveSettingsToEeprom();
|
||||||
}
|
}
|
||||||
|
const char SS_CW_SPEED_T [] PROGMEM = "Set CW Speed";
|
||||||
|
const char SS_CW_SPEED_A [] PROGMEM = "Select speed to play CW\ncharacters";
|
||||||
|
const SettingScreen_t ssCwSpeed PROGMEM = {
|
||||||
|
SS_CW_SPEED_T,
|
||||||
|
SS_CW_SPEED_A,
|
||||||
|
5,
|
||||||
|
1,
|
||||||
|
ssCwSpeedInitialize,
|
||||||
|
ssCwSpeedValidate,
|
||||||
|
ssCwSpeedChange,
|
||||||
|
ssCwSpeedFinalize
|
||||||
|
};
|
||||||
|
void runCwSpeedSetting(){runSetting(&ssCwSpeed);}
|
||||||
|
|
||||||
void setupResetAll()
|
void setupResetAll()
|
||||||
{
|
{
|
||||||
@ -430,7 +435,7 @@ const char MI_CW_DELAY [] PROGMEM = "Tx/Rx Switching Delay";
|
|||||||
const char MI_CW_KEYER [] PROGMEM = "Keyer Type";
|
const char MI_CW_KEYER [] PROGMEM = "Keyer Type";
|
||||||
const MenuItem_t cwMenu [] PROGMEM {
|
const MenuItem_t cwMenu [] PROGMEM {
|
||||||
{MT_CW,nullptr},//Title
|
{MT_CW,nullptr},//Title
|
||||||
{MI_CW_SPEED,setupCwSpeed},
|
{MI_CW_SPEED,runCwSpeedSetting},
|
||||||
{MI_CW_TONE,runToneSetting},
|
{MI_CW_TONE,runToneSetting},
|
||||||
{MI_CW_DELAY,runCwSwitchDelaySetting},
|
{MI_CW_DELAY,runCwSwitchDelaySetting},
|
||||||
{MI_CW_KEYER,runKeyerSetting},
|
{MI_CW_KEYER,runKeyerSetting},
|
||||||
|
Loading…
Reference in New Issue
Block a user