![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
Diff: xDotBridge/src/SerialTermMgr.cpp
- Revision:
- 98:3609f600c2f5
- Parent:
- 94:8028c07f71fa
- Child:
- 99:83b54c851187
--- a/xDotBridge/src/SerialTermMgr.cpp Tue Nov 28 16:19:57 2017 +0000 +++ b/xDotBridge/src/SerialTermMgr.cpp Tue Nov 28 14:31:54 2017 -0700 @@ -22,7 +22,6 @@ mCurrScreen = mainScreenId; mBbio = bbio; mFlash = flash; - } void SerialTermMgr::printScreen() { @@ -34,6 +33,8 @@ printGenInfo(); break; case settingsScreenId: + printSettings(); + break; case statsScreenId: case errorLogScreenId: case liveLogScreenId: @@ -65,6 +66,8 @@ inputGenInfo(c); break; case settingsScreenId: + inputSettings(c); + break; case statsScreenId: case errorLogScreenId: case liveLogScreenId: @@ -88,8 +91,7 @@ mCurrScreen = enterProgModeScreenId; break; case '3': - mPc->printf("\r\nNot implemented yet.\r\n"); -// mCurrScreen = settingsScreenId; + mCurrScreen = settingsScreenId; break; // Future // case '4': @@ -196,6 +198,81 @@ mPc->printf("===============================================\r\n"); } +void SerialTermMgr::inputSettings (char in) { + if (mPc == NULL) { + return; + } + switch (in) { + case 0x1B: // esc + mCurrScreen = mainScreenId; + break; + case 0x13: // ctrl-s + applySaveSettings(); + mPc->printf("Settings saved \r\n"); + mCurrScreen = mainScreenId; + break; + case 'r': + mBbio->sampleUserSwitches(); + mPc->printf("User switches sampled.\r\n"); + break; + case '1': + mSaveIsCCNO = !mSaveIsCCNO; + case '2': + mSaveIsTx = !mSaveIsTx; + case '3': + mSaveRot1 = (++mSaveRot1) % 10; + default: + mPc->printf("Invalid key.\r\n"); + } + printScreen(); +} + +void SerialTermMgr::printSettings() +{ + if (mPc == NULL) { + return; + } + mPc->printf("\r\n\r\n"); + mPc->printf("===============================================\r\n"); + mPc->printf("= Settings (ESC to return to main menu) =\r\n", mFwVersion); + mPc->printf("===============================================\r\n"); + mPc->printf("= Press r to sample user switch values =\r\n"); + mPc->printf("= Press <ctrl>-s to save values =\r\n"); + mPc->printf("===============================================\r\n"); + mPc->printf("===============================================\r\n"); + mPc->printf("= Setting: current value [Modify Key], save value =\r\n", mFwVersion); + mPc->printf("= Contact closure [1]: %s, %s =\r\n", + mBbio->isCCNO() ? "NO" : "NC", + mSaveIsCCNO ? "NO" : "NC"); + mPc->printf("= WB Mode [2]: %s, %s =\r\n", + mBbio->isTx() ? "Transmitter" : "Receiver ", + mSaveIsTx ? "Transmitter" : "Receiver "); + if (mSaveIsTx) { + mPc->printf("= Currently no rotary switches apply for TX =\r\n"); + } + else { + mPc->printf("= Rotary 1 hold setting: %0.1f secs, %0.1f =\r\n", + HoldTimeSetting::rotVal2Sec(mBbio->rotarySwitch1()), + HoldTimeSetting::rotVal2Sec(mSaveRot1)); + mPc->printf("= Rotary 2 currently does not apply for RX =\r\n"); + } + mPc->printf("===============================================\r\n"); +} + +void SerialTermMgr::seedSaveSettings() +{ + mSaveIsCCNO = mBbio->isCCNO(); + mSaveIsTx = mBbio->isTx(); + mSaveRot1 = mBbio->rotarySwitch1(); +} + +void SerialTermMgr::applySaveSettings() +{ + mBbio->setIsCCNO(mSaveIsCCNO); + mBbio->setIsTx(mSaveIsTx); + mBbio->setRotarySwitch1(mSaveRot1); +} + void SerialTermMgr::printEnterProgMode() { if (mPc == NULL) {