diff --git a/Software/src/Version 4/MorseMenu.cpp b/Software/src/Version 4/MorseMenu.cpp index 4170b17..0f3ff66 100644 --- a/Software/src/Version 4/MorseMenu.cpp +++ b/Software/src/Version 4/MorseMenu.cpp @@ -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] = { "", @@ -73,7 +73,8 @@ const String menuText [menuN] = { "Wifi Select", //40 - "Go To Sleep" } ; // 41 + "Go To Sleep", // 41 + "Auto Selection" } ; // 42 Koch enum navi {naviLevel, naviLeft, naviRight, naviUp, naviDown }; @@ -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 @@ -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 }; //boolean quickStart; // should we execute menu item immediately? @@ -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); diff --git a/Software/src/Version 4/MorsePreferences.cpp b/Software/src/Version 4/MorsePreferences.cpp index 99def67..07d0007 100644 --- a/Software/src/Version 4/MorsePreferences.cpp +++ b/Software/src/Version 4/MorsePreferences.cpp @@ -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 //////// end of variables stored in preferences //// temporary buffer for conversions, local to this file @@ -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, @@ -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: "); @@ -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() @@ -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 " ); @@ -800,6 +802,7 @@ boolean MorsePreferences::adjustKeyerPreference(prefPos pos) { /// rotati return true; } } + if ((t=checkEncoder())) { MorseOutput::pwmClick(MorsePreferences::sidetoneVolume); /// click switch (pos) { @@ -855,6 +858,10 @@ boolean MorsePreferences::adjustKeyerPreference(prefPos pos) { /// rotati internal::displayKochFilter(); break; + case posKochAutoSel: MorsePreferences::okKeyingMaxCount = constrain(MorsePreferences::okKeyingMaxCount + t, 0, 100); + internal::displayKochAutoSel(); + break; + case posRandomOption : MorsePreferences::randomOption = (MorsePreferences::randomOption + t + 10) % 10; // which char set for random chars? internal::displayRandomOption(); break; @@ -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); @@ -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); +} diff --git a/Software/src/Version 4/MorsePreferences.h b/Software/src/Version 4/MorsePreferences.h index 587861a..b6a1e7f 100644 --- a/Software/src/Version 4/MorsePreferences.h +++ b/Software/src/Version 4/MorsePreferences.h @@ -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 @@ -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[]; @@ -239,6 +240,7 @@ namespace internal { void displaySnapRecall(); void displaySnapStore(); void displayHwConf(); + void displayKochAutoSel(); } class Koch { @@ -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); @@ -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; diff --git a/Software/src/Version 4/m32_v4.ino b/Software/src/Version 4/m32_v4.ino index 1cd0ee5..94105fc 100644 --- a/Software/src/Version 4/m32_v4.ino +++ b/Software/src/Version 4/m32_v4.ino @@ -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 = ""; @@ -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(); } @@ -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(); } @@ -2242,8 +2268,6 @@ void audioLevelAdjust() { //keyTx = true; } - - String getWord() { String result = ""; byte c; diff --git a/Software/src/Version 4/morsedefs.h b/Software/src/Version 4/morsedefs.h index 7f6496f..0e89d6e 100644 --- a/Software/src/Version 4/morsedefs.h +++ b/Software/src/Version 4/morsedefs.h @@ -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