![](/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
xDotBridge/src/SerialTermMgr.cpp
- Committer:
- Matt Briggs
- Date:
- 2017-05-10
- Revision:
- 75:600cb3a9f126
- Child:
- 76:d1b20a259d8f
File content as of revision 75:600cb3a9f126:
/* * SerialTermMgr.cpp * * Created on: May 8, 2017 * Author: mbriggs */ #include "SerialTermMgr.h" #include "UserInterface.h" SerialTermMgr::SerialTermMgr(BaseboardIO *bbio, float fwVersion) { mPc = NULL; mFwVersion = fwVersion; mCurrScreen = mainScreenId; mBbio = bbio; } void SerialTermMgr::printScreen() { switch (mCurrScreen) { case mainScreenId: printMainScreen(); break; case genInfoScreenId: printGenInfo(); break; case settingsScreenId: case statsScreenId: case errorLogScreenId: case liveLogScreenId: case enterSerialBridgeScreenId: case enterProgModeScreenId: printMainScreen(); } } bool SerialTermMgr::input() { if (mPc == NULL) { return true; } bool quit = false; char c = 10; if (mPc->readable()) { c = mPc->getc(); } else { return false; // Do nothing if there is no input } switch (mCurrScreen) { case mainScreenId: quit = inputMainPage(c); break; case genInfoScreenId: inputGenInfo(c); break; case settingsScreenId: case statsScreenId: case errorLogScreenId: case liveLogScreenId: case enterSerialBridgeScreenId: case enterProgModeScreenId: inputMainPage(c); } return quit; } // private methods bool SerialTermMgr::inputMainPage (char in) { bool quit = false; switch (in) { case '1': mCurrScreen = genInfoScreenId; break; case '2': mPc->printf("\r\nNot implemented yet.\r\n"); // mCurrScreen = settingsScreenId; break; case '3': mPc->printf("\r\nNot implemented yet.\r\n"); // mCurrScreen = statsScreenId; break; case '4': mPc->printf("\r\nNot implemented yet.\r\n"); // mCurrScreen = errorLogScreenId; break; case '5': mPc->printf("\r\nNot implemented yet.\r\n"); // mCurrScreen = liveLogScreenId; break; case '6': mPc->printf("\r\nNot implemented yet.\r\n"); // mCurrScreen = enterSerialBridgeScreenId; break; case '7': mPc->printf("\r\nNot implemented yet.\r\n"); // mCurrScreen = enterProgModeScreenId; break; case 0x11: // ctrl-q quit=true; break; default: mCurrScreen = mainScreenId; } if (!quit) { printScreen(); } return quit; } void SerialTermMgr::printMainScreen() { if (mPc == NULL) { return; } mPc->printf("\r\n\r\n"); mPc->printf("===============================================\r\n"); mPc->printf("= Wireless Bridge Terminal (Firmware: v%0.2f) =\r\n", mFwVersion); mPc->printf("===============================================\r\n"); mPc->printf("===============================================\r\n"); mPc->printf("= Selection Options =\r\n"); mPc->printf("===============================================\r\n"); mPc->printf("= 0: Refresh (Enter and space also work) =\r\n"); mPc->printf("= 1: General information =\r\n"); mPc->printf("= 2: Settings =\r\n"); mPc->printf("= 3: Statistics =\r\n"); mPc->printf("= 4: Error log =\r\n"); mPc->printf("= 5: Live log =\r\n"); mPc->printf("= 6: Enter serial bridge mode =\r\n"); mPc->printf("= 7: Enter programming mode =\r\n"); mPc->printf("= <ctrl>-q: Exit terminal =\r\n"); mPc->printf("===============================================\r\n"); } void SerialTermMgr::inputGenInfo (char in) { if (mPc == NULL) { return; } switch (in) { case 0x1B: mCurrScreen = mainScreenId; break; case 'r': mBbio->sampleUserSwitches(); mPc->printf("User switches sampled.\r\n"); break; default: mPc->printf("Invalid key.\r\n"); } printScreen(); } void SerialTermMgr::printGenInfo() { if (mPc == NULL) { return; } mPc->printf("\r\n\r\n"); mPc->printf("===============================================\r\n"); mPc->printf("= General Info (ESC to return to main menu) =\r\n", mFwVersion); mPc->printf("===============================================\r\n"); mPc->printf("= Press r to sample user switch values =\r\n"); // FIXME mPc->printf("===============================================\r\n"); mPc->printf("===============================================\r\n"); mPc->printf("= Firmware version: v%0.2f =\r\n", mFwVersion); //TODO // mPc->printf("= Radio EUI: %s =\r\n", mts::Text::bin2hexString(dot->getDeviceId()).c_str()); mPc->printf("= Contact closure: %s =\r\n", mBbio->isCCNO() ? "Normally open " : "Normally closed"); mPc->printf("= WB Mode: %s =\r\n", mBbio->isTx() ? "Transmitter" : "Receiver "); mPc->printf("= Comm Mode: %s =\r\n", mBbio->isLoRaWANMode() ? "LoRaWAN " : "Peer-to-peer"); mPc->printf("= Serial Mode: %s =\r\n", mBbio->isSerialEnabled() ? "Enabled " : "Disabled"); if (mBbio->isTx()) { mPc->printf("= Currently no rotary switches apply for TX =\r\n"); } else { mPc->printf("= Rotary 1 hold setting is %0.1f seconds =\r\n", HoldTimeSetting::rotVal2Sec(mBbio->rotarySwitch1())); mPc->printf("= Rotary 2 currently does not apply for RX =\r\n"); } mPc->printf("===============================================\r\n"); }