mirror of
https://codeberg.org/mclemens/ubitxv6.git
synced 2024-09-10 16:34:19 -04:00
Refactor keyer setting into new menu style
This commit is contained in:
parent
dc1da20b13
commit
9af0c1c965
69
setup.cpp
69
setup.cpp
@ -294,50 +294,45 @@ const SettingScreen_t ssCwSwitchDelay PROGMEM = {
|
|||||||
};
|
};
|
||||||
void runCwSwitchDelaySetting(){runSetting(&ssCwSwitchDelay);}
|
void runCwSwitchDelaySetting(){runSetting(&ssCwSwitchDelay);}
|
||||||
|
|
||||||
void formatKeyerEnum(char* output, const KeyerMode_e mode)
|
//CW Keyer
|
||||||
|
void ssKeyerInitialize(long int* start_value_out)
|
||||||
{
|
{
|
||||||
if(KeyerMode_e::KEYER_STRAIGHT == mode){
|
*start_value_out = globalSettings.keyerMode;
|
||||||
strcpy_P(output,(const char*)F("< Hand Key >"));
|
}
|
||||||
|
void ssKeyerValidate(const long int candidate_value_in, long int* validated_value_out)
|
||||||
|
{
|
||||||
|
*validated_value_out = LIMIT(candidate_value_in,KeyerMode_e::KEYER_STRAIGHT,KeyerMode_e::KEYER_IAMBIC_B);
|
||||||
|
}
|
||||||
|
void ssKeyerChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
||||||
|
{
|
||||||
|
if(KeyerMode_e::KEYER_STRAIGHT == new_value){
|
||||||
|
strncpy_P(buff_out,(const char*)F("< Hand Key >"),buff_out_size);
|
||||||
}
|
}
|
||||||
else if(KeyerMode_e::KEYER_IAMBIC_A == mode){
|
else if(KeyerMode_e::KEYER_IAMBIC_A == new_value){
|
||||||
strcpy_P(output,(const char*)F("< Iambic A >"));
|
strncpy_P(buff_out,(const char*)F("< Iambic A >"),buff_out_size);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
strcpy_P(output,(const char*)F("< Iambic B >"));
|
strncpy_P(buff_out,(const char*)F("< Iambic B >"),buff_out_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void ssKeyerFinalize(const long int final_value)
|
||||||
void setupKeyer(){
|
{
|
||||||
//displayDialog(F("Set CW Keyer"),F("Press tune to Save"));
|
globalSettings.keyerMode = final_value;
|
||||||
|
|
||||||
int knob = 0;
|
|
||||||
uint32_t tmp_mode = globalSettings.keyerMode;
|
|
||||||
formatKeyerEnum(c, tmp_mode);
|
|
||||||
displayText(c, LAYOUT_SETTING_VALUE_X, LAYOUT_SETTING_VALUE_Y, LAYOUT_SETTING_VALUE_WIDTH, LAYOUT_SETTING_VALUE_HEIGHT, COLOR_TEXT, COLOR_SETTING_BACKGROUND, COLOR_BACKGROUND);
|
|
||||||
|
|
||||||
while (!btnDown())
|
|
||||||
{
|
|
||||||
knob = enc_read();
|
|
||||||
if(knob == 0){
|
|
||||||
active_delay(50);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(knob < 0 && tmp_mode > KeyerMode_e::KEYER_STRAIGHT){
|
|
||||||
tmp_mode--;
|
|
||||||
}
|
|
||||||
if(knob > 0 && tmp_mode < KeyerMode_e::KEYER_IAMBIC_B){
|
|
||||||
tmp_mode++;
|
|
||||||
}
|
|
||||||
|
|
||||||
formatKeyerEnum(c,tmp_mode);
|
|
||||||
displayText(c, LAYOUT_SETTING_VALUE_X, LAYOUT_SETTING_VALUE_Y, LAYOUT_SETTING_VALUE_WIDTH, LAYOUT_SETTING_VALUE_HEIGHT, COLOR_TEXT, COLOR_SETTING_BACKGROUND, COLOR_BACKGROUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
active_delay(500);
|
|
||||||
|
|
||||||
globalSettings.keyerMode = tmp_mode;
|
|
||||||
SaveSettingsToEeprom();
|
SaveSettingsToEeprom();
|
||||||
}
|
}
|
||||||
|
const char SS_KEYER_T [] PROGMEM = "Set CW Keyer Type";
|
||||||
|
const char SS_KEYER_A [] PROGMEM = "Select which type of\nkeyer/paddle is being used";
|
||||||
|
const SettingScreen_t ssKeyer PROGMEM = {
|
||||||
|
SS_KEYER_T,
|
||||||
|
SS_KEYER_A,
|
||||||
|
10,
|
||||||
|
1,
|
||||||
|
ssKeyerInitialize,
|
||||||
|
ssKeyerValidate,
|
||||||
|
ssKeyerChange,
|
||||||
|
ssKeyerFinalize
|
||||||
|
};
|
||||||
|
void runKeyerSetting(){runSetting(&ssKeyer);}
|
||||||
|
|
||||||
void setupCwSpeed()
|
void setupCwSpeed()
|
||||||
{
|
{
|
||||||
@ -464,7 +459,7 @@ const MenuItem_t cwMenu [] PROGMEM {
|
|||||||
{MI_CW_SPEED,setupCwSpeed},
|
{MI_CW_SPEED,setupCwSpeed},
|
||||||
{MI_CW_TONE,runToneSetting},
|
{MI_CW_TONE,runToneSetting},
|
||||||
{MI_CW_DELAY,runCwSwitchDelaySetting},
|
{MI_CW_DELAY,runCwSwitchDelaySetting},
|
||||||
{MI_CW_KEYER,setupKeyer},
|
{MI_CW_KEYER,runKeyerSetting},
|
||||||
};
|
};
|
||||||
void runCwMenu(){RUN_MENU(cwMenu);}
|
void runCwMenu(){RUN_MENU(cwMenu);}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user