Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to auto-select Koch lesson after symbol is keyed correctly multiple times in a row #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions Software/src/Version 4/MorseMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using namespace MorseMenu;
//////// variables and constants for the modus menu


const uint8_t menuN = 42; // no of menu items +1
const uint8_t menuN = 43; // no of menu items +1

const String menuText [menuN] = {
"",
Expand Down Expand Up @@ -73,7 +73,8 @@ const String menuText [menuN] = {
"Wifi Select", //40


"Go To Sleep" } ; // 41
"Go To Sleep", // 41
"Auto Selection" } ; // 42 Koch
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New menu string to select max number of times a symbol should be keyed correctly before moving to next lesson.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put new menu and strings at the end to avoid shifting everything


enum navi {naviLevel, naviLeft, naviRight, naviUp, naviDown };

Expand All @@ -95,15 +96,15 @@ const uint8_t menuNav [menuN] [5] = { // { level, left, right,
{1,_echoWords,_echoMixed,_echo,0}, // 13 echo calls
{1,_echoCalls,_echoPlayer,_echo,0}, // 14 echo mixed
{1,_echoMixed,_echoRand,_echo,0}, // 15 echo player
{0,_echo,_trx,_dummy,_kochSel}, // 16 koch
{1,_kochEcho,_kochLearn,_koch,0}, // 17 koch select
{0,_echo,_trx,_dummy,_kochSel}, // 16 koch
{1,_kochAutoSel,_kochLearn,_koch,0}, // 17 koch select
{1,_kochSel,_kochGen,_koch,0}, // 18 koch learn new
{1,_kochLearn,_kochEcho,_koch,_kochGenRand}, // 19 koch gen
{2,_kochGenMixed,_kochGenAbb,_kochGen,0}, // 20 koch gen random
{2,_kochGenRand,_kochGenWords,_kochGen,0}, // 21 koch gen abb
{2,_kochGenAbb,_kochGenMixed,_kochGen,0}, // 22 koch gen words
{2,_kochGenWords,_kochGenRand,_kochGen,0}, // 23 koch gen mixed
{1,_kochGen,_kochSel,_koch,_kochEchoRand}, // 24 koch echo
{1,_kochGen,_kochAutoSel,_koch,_kochEchoRand}, // 24 koch echo
{2,_kochEchoMixed,_kochEchoAbb,_kochEcho,0}, // 25 koch echo random
{2,_kochEchoRand,_kochEchoWords,_kochEcho,0}, // 26 koch echo abb
{2,_kochEchoAbb,_kochEchoMixed,_kochEcho,0}, // 27 koch echo words
Expand All @@ -120,7 +121,8 @@ const uint8_t menuNav [menuN] [5] = { // { level, left, right,
{1,_wifi_check,_wifi_update,_wifi,0}, // 38 Upload File
{1,_wifi_upload,_wifi_select,_wifi,0}, // 39 Update Firmware
{1,_wifi_update,_wifi_mac,_wifi,0}, // 40 Select network
{0,_wifi,_keyer,_dummy,0} // 41 goto sleep
{0,_wifi,_keyer,_dummy,0}, // 41 goto sleep
{1,_kochEcho,_kochSel,_koch,0}, // 42 koch Auto select check 16
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New menu between Echo and Select Lesson

};

//boolean quickStart; // should we execute menu item immediately?
Expand Down Expand Up @@ -321,6 +323,12 @@ boolean MorseMenu::menuExec() { // retu
MorsePreferences::writePreferences("morserino");
return false;
break;
case _kochAutoSel: // Koch Auto Select
MorsePreferences::displayKeyerPreferencesMenu(MorsePreferences::posKochAutoSel);
MorsePreferences::adjustKeyerPreference(MorsePreferences::posKochAutoSel);
MorsePreferences::writePreferences("morserino");
return false;
break;
case _kochLearn: // Koch Learn New . /// just a new generatormode....
generatorMode = KOCH_LEARN;
MorsePreferences::setCurrentOptions(MorsePreferences::kochEchoOptions, MorsePreferences::kochEchoOptionsSize);
Expand Down
47 changes: 42 additions & 5 deletions Software/src/Version 4/MorsePreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ Preferences pref; // use the Preferences library for storing and r
uint8_t MorsePreferences::snapShots = 0; // keep track which snapshots are being used ( 0 .. 7, called 1 to 8)

uint8_t MorsePreferences::boardVersion = 0; // which Morserino board version? v3 uses heltec Wifi Lora V2, V4 uses V2.1


uint8_t MorsePreferences::okKeyingMaxCount = 0; // Max number of correct keying before moving to next lesson
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default to disable.

//////// end of variables stored in preferences

//// temporary buffer for conversions, local to this file
Expand All @@ -131,7 +132,7 @@ const String MorsePreferences::prefOption[] = { "Encoder Click", "Tone Pitch Hz"
"Koch Sequence", "Koch ", "Latency ", "Randomize File",
"Time Out ", "Quick Start ", "Stop/Next/Rep", "Max # of Words","LoRa Channel ", "Serial Output",
"LoRa Band ", "LoRa Frequ ", "RECALLSnapshot", "STORE Snapshot",
"Calibrate Batt", "Hardware Conf"};
"Calibrate Batt", "Hardware Conf", "Koch Auto Sel"};
prefPos MorsePreferences::keyerOptions[] = {posClicks, posPitch, posExtPaddles, posPolarity, posLatency, posCurtisMode, posCurtisBDahTiming, posCurtisBDotTiming, posACS,
posKeyTrainerMode, posTimeOut, posQuickStart, posSerialOut };
prefPos MorsePreferences::generatorOptions[] = {posClicks, posPitch, posExtPaddles, posInterWordSpace, posInterCharSpace, posRandomOption,
Expand Down Expand Up @@ -278,7 +279,7 @@ boolean MorsePreferences::setupPreferences(uint8_t atMenu) {

void MorsePreferences::displayKeyerPreferencesMenu(int pos) {
MorseOutput::clearDisplay();
if (pos < posLoraBand)
if (pos < posLoraBand || (pos == posKochAutoSel))
MorseOutput::printOnStatusLine( true, 0, "Set Preferences: ");
else if (pos < posSnapRecall)
MorseOutput::printOnStatusLine( true, 0, "Config LoRa: ");
Expand Down Expand Up @@ -372,7 +373,9 @@ void MorsePreferences::displayKeyerPreferencesMenu(int pos) {
case posVAdjust: internal::displayVAdjust();
break;
case posHwConf: internal::displayHwConf();
break;
break;
case posKochAutoSel:internal::displayKochAutoSel();
break;
} /// switch (pos)
Heltec.display -> display();
} // displayKeyerPreferences()
Expand Down Expand Up @@ -618,7 +621,6 @@ void internal::displayKochFilter() { // const String ko
MorseOutput::printOnScroll(2, REGULAR, 1, numBuffer);
}


void internal::displayWordDoubler() {
MorseOutput::printOnScroll(2, REGULAR, 1, MorsePreferences::wordDoubler ? "On " :
"Off " );
Expand Down Expand Up @@ -800,6 +802,7 @@ boolean MorsePreferences::adjustKeyerPreference(prefPos pos) { /// rotati
return true;
}
}

if ((t=checkEncoder())) {
MorseOutput::pwmClick(MorsePreferences::sidetoneVolume); /// click
switch (pos) {
Expand Down Expand Up @@ -855,6 +858,10 @@ boolean MorsePreferences::adjustKeyerPreference(prefPos pos) { /// rotati
internal::displayKochFilter();
break;

case posKochAutoSel: MorsePreferences::okKeyingMaxCount = constrain(MorsePreferences::okKeyingMaxCount + t, 0, 100);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Range form 0 to 100.

internal::displayKochAutoSel();
break;

case posRandomOption : MorsePreferences::randomOption = (MorsePreferences::randomOption + t + 10) % 10; // which char set for random chars?
internal::displayRandomOption();
break;
Expand Down Expand Up @@ -1343,6 +1350,10 @@ void MorsePreferences::writePreferences(String repository) {
koch.setup();
}
}

if (MorsePreferences::okKeyingMaxCount != pref.getUChar("okKeyingMaxCount")) {
pref.putUChar("okKeyingMaxCount", MorsePreferences::okKeyingMaxCount);
}

if (MorsePreferences::lcwoKochSeq != pref.getBool("lcwoKochSeq")) {
pref.putBool("lcwoKochSeq", MorsePreferences::lcwoKochSeq);
Expand Down Expand Up @@ -1768,3 +1779,29 @@ String Koch::getRandomAbbrev() {
uint16_t index = abbrIndices[random(numberOfAbbr)];
return Abbrev::abbreviations[index];
}

void Koch::moveToNextKochLesson() {
MorsePreferences::kochFilter = constrain(MorsePreferences::kochFilter + 1, 1, kochCharsLength);
}

uint8_t Koch::getOkKeyingCount(void)
{
return this->okKeyingCount;
}

void Koch::setOkKeyingCount(uint8_t count)
{
this->okKeyingCount = count;
}

void internal::displayKochAutoSel() {
if(MorsePreferences::okKeyingMaxCount)
{
sprintf(numBuffer, " %2i ", MorsePreferences::okKeyingMaxCount);
}
else
{
sprintf(numBuffer, "%s", " None ");
}
MorseOutput::printOnScroll(2, REGULAR, 1, numBuffer);
}
9 changes: 7 additions & 2 deletions Software/src/Version 4/MorsePreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ namespace MorsePreferences
extern uint32_t loraQRG;
extern uint8_t snapShots;
extern uint8_t boardVersion;
extern uint8_t okKeyingMaxCount;

////// end of variables stored in preferences

Expand All @@ -124,7 +125,7 @@ namespace MorsePreferences
posTrainerDisplay, posWordDoubler, posEchoDisplay, posEchoRepeats, posEchoConf,
posKeyTrainerMode, posLoraTrainerMode, posGoertzelBandwidth, posSpeedAdapt,
posKochSeq, posKochFilter, posLatency, posRandomFile, posTimeOut, posQuickStart, posAutoStop,posMaxSequence, posLoraSyncW, posSerialOut,
posLoraBand, posLoraQRG, posSnapRecall, posSnapStore, posVAdjust, posHwConf
posLoraBand, posLoraQRG, posSnapRecall, posSnapStore, posVAdjust, posHwConf, posKochAutoSel
};

extern const String prefOption[];
Expand Down Expand Up @@ -239,6 +240,7 @@ namespace internal {
void displaySnapRecall();
void displaySnapStore();
void displayHwConf();
void displayKochAutoSel();
}

class Koch {
Expand All @@ -249,6 +251,7 @@ class Koch {
uint16_t numberOfAbbr;
String kochCharSet;
const String lcwoKochChars = "kmuresnaptlwi.jz=foy,vg5/q92h38b?47c1d60x-K+ASNV@:";
uint8_t okKeyingCount;

void createWords(uint8_t, uint8_t);
void createAbbr(uint8_t, uint8_t);
Expand All @@ -265,7 +268,9 @@ class Koch {
String getRandomAbbrev();
void setKochChars(boolean);
void setCustomChars(String chars);

void moveToNextKochLesson();
uint8_t getOkKeyingCount(void);
void setOkKeyingCount(uint8_t count);
};

extern Koch koch;
Expand Down
32 changes: 28 additions & 4 deletions Software/src/Version 4/m32_v4.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,9 @@ String getKeyerModeSymbol() { /// symbol to be displayed on status l
///////// evaluate the response in Echo Trainer Mode
void echoTrainerEval() {
int i;
uint8_t okKeyingCount;
String okMessage = "OK";

delay(interCharacterSpace / 2);
if (echoResponse.endsWith("R")) {
echoResponse = "";
Expand All @@ -1755,8 +1758,30 @@ void echoTrainerEval() {
}
if (echoResponse == echoTrainerWord) {
echoTrainerState = SEND_WORD;
//printToScroll(BOLD, "OK");
printOnDisplay(BOLD, "OK");

// Check feature is enabled
if((MorsePreferences::okKeyingMaxCount > 0) && (generatorMode = KOCH_LEARN))
{
okKeyingCount = koch.getOkKeyingCount();
okKeyingCount++;

if(okKeyingCount < MorsePreferences::okKeyingMaxCount)
{
koch.setOkKeyingCount(okKeyingCount);
}
else
{
koch.setOkKeyingCount(0);
koch.moveToNextKochLesson();
MorsePreferences::writePreferences("morserino");
}

okMessage = okMessage + " " + String(okKeyingCount);
}

//printToScroll(BOLD, okMessage);
printOnDisplay(BOLD, okMessage);

if (MorsePreferences::echoConf) {
MorseOutput::soundSignalOK();
}
Expand All @@ -1767,6 +1792,7 @@ void echoTrainerEval() {
echoTrainerState = REPEAT_WORD;
if (generatorMode != KOCH_LEARN || echoResponse != "") {
printOnDisplay(BOLD, "ERR");
koch.setOkKeyingCount(0);
if (MorsePreferences::echoConf) {
MorseOutput::soundSignalERR();
}
Expand Down Expand Up @@ -2242,8 +2268,6 @@ void audioLevelAdjust() {
//keyTx = true;
}



String getWord() {
String result = "";
byte c;
Expand Down
2 changes: 1 addition & 1 deletion Software/src/Version 4/morsedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ enum menuNo
_echo, _echoRand, _echoAbb, _echoWords, _echoCalls, _echoMixed, _echoPlayer,
_koch, _kochSel, _kochLearn, _kochGen, _kochGenRand, _kochGenAbb, _kochGenWords,
_kochGenMixed, _kochEcho, _kochEchoRand, _kochEchoAbb, _kochEchoWords, _kochEchoMixed,
_trx, _trxLora, _trxWifi, _trxIcw, _decode, _wifi, _wifi_mac, _wifi_config, _wifi_check, _wifi_upload, _wifi_update, _wifi_select, _goToSleep
_trx, _trxLora, _trxWifi, _trxIcw, _decode, _wifi, _wifi_mac, _wifi_config, _wifi_check, _wifi_upload, _wifi_update, _wifi_select, _goToSleep, _kochAutoSel
};

enum echoStates
Expand Down