diff options
author | Mike Fiore <mfiore@multitech.com> | 2015-12-01 10:28:04 -0600 |
---|---|---|
committer | Mike Fiore <mfiore@multitech.com> | 2015-12-01 10:28:04 -0600 |
commit | 7f0ba1ea735a0d1619539ba69724fa8679af64b1 (patch) | |
tree | e38d502452bd51ddba4cdb9255f1f250cb4eaf05 | |
parent | 37260f2ccff2793f54bfd291169d2c8d879bbc15 (diff) | |
download | mtdot-box-evb-factory-firmware-7f0ba1ea735a0d1619539ba69724fa8679af64b1.tar.gz mtdot-box-evb-factory-firmware-7f0ba1ea735a0d1619539ba69724fa8679af64b1.tar.bz2 mtdot-box-evb-factory-firmware-7f0ba1ea735a0d1619539ba69724fa8679af64b1.zip |
got basic sweep implementation working - tested in 915 frequency band
-rw-r--r-- | Layout/LayoutSweepComplete.cpp | 2 | ||||
-rw-r--r-- | Layout/LayoutSweepComplete.h | 1 | ||||
-rw-r--r-- | Mode/ModeSweep.cpp | 91 |
3 files changed, 68 insertions, 26 deletions
diff --git a/Layout/LayoutSweepComplete.cpp b/Layout/LayoutSweepComplete.cpp index ab44b7b..f921b3c 100644 --- a/Layout/LayoutSweepComplete.cpp +++ b/Layout/LayoutSweepComplete.cpp @@ -6,7 +6,6 @@ LayoutSweepComplete::LayoutSweepComplete(DOGS102* lcd) _lInfo(0, 1, "Sweep Finished"), _lPass(0, 5, "Pass"), _lFail(9, 5, "Fail"), - _lSw1(11, 7, "Cancel"), _lSw2(0, 7, "Sweep"), _fId(2, 0, 5), _fPass(5, 5, 2), @@ -23,7 +22,6 @@ void LayoutSweepComplete::display() { writeLabel(_lInfo); writeLabel(_lPass); writeLabel(_lFail); - writeLabel(_lSw1); writeLabel(_lSw2); endUpdate(); diff --git a/Layout/LayoutSweepComplete.h b/Layout/LayoutSweepComplete.h index 82cf008..221201d 100644 --- a/Layout/LayoutSweepComplete.h +++ b/Layout/LayoutSweepComplete.h @@ -18,7 +18,6 @@ class LayoutSweepComplete : public Layout { Label _lInfo; Label _lPass; Label _lFail; - Label _lSw1; Label _lSw2; Field _fId; diff --git a/Mode/ModeSweep.cpp b/Mode/ModeSweep.cpp index 9b51a52..023e461 100644 --- a/Mode/ModeSweep.cpp +++ b/Mode/ModeSweep.cpp @@ -41,9 +41,9 @@ bool ModeSweep::start() { _max_power = _dot->getWakeMode(); // compute the total number of surveys we will do - _survey_current = 1; _points = generatePoints(); _survey_total = _points.size(); + _survey_current = 0; _survey_success = 0; _survey_failure = 0; @@ -51,8 +51,6 @@ bool ModeSweep::start() { for (std::vector<point>::iterator it = _points.begin(); it != _points.end(); it++) logInfo("%s,%lu", _dot->DataRateStr(it->first).substr(3).c_str(), it->second); - return true; - // see if survey data file exists std::vector<mDot::mdot_file> files = _dot->listUserFiles(); for (std::vector<mDot::mdot_file>::iterator it = files.begin(); it != files.end(); it++) { @@ -67,10 +65,12 @@ bool ModeSweep::start() { _file.display(); } else { _state = show_help; - _index = 0; + _index = 1; displayHelp(); } + _display_timer.reset(); + while (true) { osEvent e = Thread::signal_wait(0, 250); if (e.status == osEventSignal) { @@ -82,7 +82,7 @@ bool ModeSweep::start() { switch (_state) { case check_file: _state = show_help; - _index = getIndex(sweep); + _index = getIndex(sweep) + 1; displayHelp(); break; case confirm: @@ -92,13 +92,32 @@ bool ModeSweep::start() { case show_help: break; case in_progress: - // do nothing break; case success: + _state = complete; + _display_timer.stop(); + _display_timer.reset(); + logInfo("sweep finished"); + _complete.display(); + _complete.updateId(_index++); + _complete.updatePass(_survey_success); + _complete.updateFail(_survey_failure); + _survey_success = 0; + _survey_failure = 0; break; case data: break; case failure: + _state = complete; + _display_timer.stop(); + _display_timer.reset(); + logInfo("sweep finished"); + _complete.display(); + _complete.updateId(_index++); + _complete.updatePass(_survey_success); + _complete.updateFail(_survey_failure); + _survey_success = 0; + _survey_failure = 0; break; case complete: break; @@ -115,40 +134,37 @@ bool ModeSweep::start() { _state = show_help; logInfo("deleting survey data file"); _dot->deleteUserFile(_file_name); - _index = 0; + _index = 1; displayHelp(); break; case show_help: _state = in_progress; + _survey_current++; _progress.display(); + _progress.updateProgress(_survey_current, _survey_total); if (_lora->getNextTx() > 0) no_channel_ping = true; - else + else send_ping = true; break; case in_progress: - // do nothing break; case success: - _state = in_progress; - _progress.display(); - if (_lora->getNextTx() > 0) - no_channel_ping = true; - else - send_ping = true; break; case data: break; case failure: + break; + case complete: _state = in_progress; + _survey_current = 1; _progress.display(); + _progress.updateProgress(_survey_current, _survey_total); if (_lora->getNextTx() > 0) no_channel_ping = true; - else + else send_ping = true; break; - case complete: - break; } break; case ButtonHandler::sw1_hold: @@ -167,6 +183,7 @@ bool ModeSweep::start() { case show_help: break; case in_progress: + _survey_success++; _ping_result = _lora->getPingResults(); displaySuccess(); logInfo("ping successful"); @@ -181,7 +198,7 @@ bool ModeSweep::start() { } else { _state = success; _success.updateSw1(" Cancel"); - _success.updateSw2("Survey"); + _display_timer.start(); } break; case success: @@ -204,15 +221,17 @@ bool ModeSweep::start() { case show_help: break; case in_progress: + _survey_failure++; _state = failure; _failure.display(); _failure.updateId(_index); // mDot::DataRateStr returns format SF_XX - we only want to display the XX part _failure.updateRate(_dot->DataRateStr(_data_rate).substr(3)); - updateData(_data, single, false); + updateData(_data, sweep, false); appendDataFile(_data); _failure.updatePower(_power); logInfo("ping failed"); + _display_timer.start(); break; case success: break; @@ -241,8 +260,8 @@ bool ModeSweep::start() { _state = success; _success.updateInfo("Data Send Success"); _success.updateSw1(" Cancel"); - _success.updateSw2("Survey"); logInfo("data send success"); + _display_timer.start(); break; case failure: break; @@ -267,8 +286,8 @@ bool ModeSweep::start() { _state = success; _success.updateInfo("Data Send Failure"); _success.updateSw1(" Cancel"); - _success.updateSw2("Survey"); logInfo("data send failed"); + _display_timer.start(); break; case failure: break; @@ -280,13 +299,37 @@ bool ModeSweep::start() { } } + if (_display_timer.read_ms() > 2000) { + _display_timer.stop(); + _display_timer.reset(); + if (_survey_current == _survey_total) { + logInfo("sweep finished"); + _state = complete; + _complete.display(); + _complete.updateId(_index++); + _complete.updatePass(_survey_success); + _complete.updateFail(_survey_failure); + _survey_success = 0; + _survey_failure = 0; + } else { + logInfo("starting next ping"); + _state = in_progress; + _survey_current++; + _progress.display(); + _progress.updateProgress(_survey_current, _survey_total); + send_ping = true; + } + } + if (no_channel_ping) { uint32_t t = _lora->getNextTx(); if (t > 0) { logInfo("next tx %lu ms", t); _progress.updateCountdown(t / 1000); } else { + _survey_current++; _progress.display(); + _progress.updateProgress(_survey_current, _survey_total); no_channel_ping = false; send_ping = true; } @@ -303,12 +346,14 @@ bool ModeSweep::start() { } } if (send_ping) { + point p = _points[_survey_current - 1]; + _data_rate = p.first; + _power = p.second; logInfo("sending ping %s %d", _dot->DataRateStr(_data_rate).c_str(), _power); send_ping = false; _lora->setDataRate(_data_rate); _lora->setPower(_power); _lora->ping(); - _index++; } if (send_data) { std::vector<uint8_t> s_data; |