From 674cdb5c13bad3598381b81d843b5aeee5798d1f Mon Sep 17 00:00:00 2001 From: Mike Fiore Date: Fri, 20 Nov 2015 08:13:35 -0600 Subject: implement basic single survey mode - still needs sending data packet and data survey file --- Layout/LayoutConfirm.cpp | 28 +++++++++++ Layout/LayoutConfirm.h | 22 +++++++++ Layout/LayoutFile.cpp | 30 ++++++++++++ Layout/LayoutFile.h | 23 +++++++++ Layout/LayoutJoin.cpp | 13 +++--- Layout/LayoutJoin.h | 1 - Layout/LayoutSurveyFailure.cpp | 58 +++++++++++++++++++++++ Layout/LayoutSurveyFailure.h | 33 +++++++++++++ Layout/LayoutSurveyProgress.cpp | 34 ++++++++++++++ Layout/LayoutSurveyProgress.h | 24 ++++++++++ Layout/LayoutSurveySuccess.cpp | 101 ++++++++++++++++++++++++++++++++++++++++ Layout/LayoutSurveySuccess.h | 46 ++++++++++++++++++ 12 files changed, 405 insertions(+), 8 deletions(-) create mode 100644 Layout/LayoutConfirm.cpp create mode 100644 Layout/LayoutConfirm.h create mode 100644 Layout/LayoutFile.cpp create mode 100644 Layout/LayoutFile.h create mode 100644 Layout/LayoutSurveyFailure.cpp create mode 100644 Layout/LayoutSurveyFailure.h create mode 100644 Layout/LayoutSurveyProgress.cpp create mode 100644 Layout/LayoutSurveyProgress.h create mode 100644 Layout/LayoutSurveySuccess.cpp create mode 100644 Layout/LayoutSurveySuccess.h (limited to 'Layout') diff --git a/Layout/LayoutConfirm.cpp b/Layout/LayoutConfirm.cpp new file mode 100644 index 0000000..93fe85c --- /dev/null +++ b/Layout/LayoutConfirm.cpp @@ -0,0 +1,28 @@ +#include "LayoutConfirm.h" + +LayoutConfirm::LayoutConfirm(DOGS102* lcd) + : Layout(lcd), + _lMsg1(0, 0, "Are You Sure You"), + _lMsg2(0, 1, "Want to Erase It?"), + _lIns1(0, 4, "Hold SW1 any time"), + _lIns2(0, 5, "for Main Menu"), + _lSw1(14, 7, "No"), + _lSw2(1, 7, "Yes") +{} + +LayoutConfirm::~LayoutConfirm() {} + +void LayoutConfirm::display() { + clear(); + startUpdate(); + + writeLabel(_lMsg1); + writeLabel(_lMsg2); + writeLabel(_lIns1); + writeLabel(_lIns2); + writeLabel(_lSw1); + writeLabel(_lSw2); + + endUpdate(); +} + diff --git a/Layout/LayoutConfirm.h b/Layout/LayoutConfirm.h new file mode 100644 index 0000000..891094e --- /dev/null +++ b/Layout/LayoutConfirm.h @@ -0,0 +1,22 @@ +#ifndef __LAYOUTCONFIRM_H__ +#define __LAYOUTCONFIRM_H__ + +#include "Layout.h" + +class LayoutConfirm : public Layout { + public: + LayoutConfirm(DOGS102* lcd); + ~LayoutConfirm(); + + void display(); + + private: + Label _lMsg1; + Label _lMsg2; + Label _lIns1; + Label _lIns2; + Label _lSw1; + Label _lSw2; +}; + +#endif diff --git a/Layout/LayoutFile.cpp b/Layout/LayoutFile.cpp new file mode 100644 index 0000000..fd54ff1 --- /dev/null +++ b/Layout/LayoutFile.cpp @@ -0,0 +1,30 @@ +#include "LayoutFile.h" + +LayoutFile::LayoutFile(DOGS102* lcd) + : Layout(lcd), + _lMsg1(0, 0, "Erase or Append"), + _lMsg2(0, 1, "to Existing"), + _lMsg3(0, 2, "Survey Data File?"), + _lIns1(0, 4, "Hold SW1 any time"), + _lIns2(0, 5, "for Main Menu"), + _lSw1(11, 7, "Append"), + _lSw2(0, 7, "Erase") +{} + +LayoutFile::~LayoutFile() {} + +void LayoutFile::display() { + clear(); + startUpdate(); + + writeLabel(_lMsg1); + writeLabel(_lMsg2); + writeLabel(_lMsg3); + writeLabel(_lIns1); + writeLabel(_lIns2); + writeLabel(_lSw1); + writeLabel(_lSw2); + + endUpdate(); +} + diff --git a/Layout/LayoutFile.h b/Layout/LayoutFile.h new file mode 100644 index 0000000..640249f --- /dev/null +++ b/Layout/LayoutFile.h @@ -0,0 +1,23 @@ +#ifndef __LAYOUTFILE_H__ +#define __LAYOUTFILE_H__ + +#include "Layout.h" + +class LayoutFile : public Layout { + public: + LayoutFile(DOGS102* lcd); + ~LayoutFile(); + + void display(); + + private: + Label _lMsg1; + Label _lMsg2; + Label _lMsg3; + Label _lIns1; + Label _lIns2; + Label _lSw1; + Label _lSw2; +}; + +#endif diff --git a/Layout/LayoutJoin.cpp b/Layout/LayoutJoin.cpp index 5ff93d7..83e8551 100644 --- a/Layout/LayoutJoin.cpp +++ b/Layout/LayoutJoin.cpp @@ -53,6 +53,7 @@ void LayoutJoin::updateFsb(uint8_t band) { char buf[8]; size_t size; + memset(buf, 0, sizeof(buf)); size = snprintf(buf, sizeof(buf), "%u", band); writeField(_fFsb, buf, size, true); } @@ -65,6 +66,7 @@ void LayoutJoin::updatePower(uint32_t power) { char buf[16]; size_t size; + memset(buf, 0, sizeof(buf)); size = snprintf(buf, sizeof(buf), "%lu", power); writeField(_fPower, buf, size, true); } @@ -73,6 +75,7 @@ void LayoutJoin::updateAttempt(uint32_t attempt) { char buf[16]; size_t size; + memset(buf, 0, sizeof(buf)); size = snprintf(buf, sizeof(buf), "%lu", attempt); writeField(_fAttempt, buf, size, true); } @@ -85,14 +88,10 @@ void LayoutJoin::updateCountdown(uint32_t seconds) { char buf[16]; size_t size; + memset(buf, 0, sizeof(buf)); writeField(_fCountdownLabel, "No Free Channel", true); - size = snprintf(buf, sizeof(buf), "%lu", seconds); - writeField(_fPower, buf, size, true); -} - -void LayoutJoin::removeCountdown() { - removeField(_fCountdownLabel); - removeField(_fCountdown); + size = snprintf(buf, sizeof(buf), "%lu s", seconds); + writeField(_fCountdown, buf, size, true); } void LayoutJoin::displayCancel(bool display) { diff --git a/Layout/LayoutJoin.h b/Layout/LayoutJoin.h index 2f71aec..0f8e4f0 100644 --- a/Layout/LayoutJoin.h +++ b/Layout/LayoutJoin.h @@ -19,7 +19,6 @@ class LayoutJoin : public Layout { void updateAttempt(uint32_t attempt); void updateStatus(std::string status); void updateCountdown(uint32_t seconds); - void removeCountdown(); void displayCancel(bool display = true); private: diff --git a/Layout/LayoutSurveyFailure.cpp b/Layout/LayoutSurveyFailure.cpp new file mode 100644 index 0000000..d443098 --- /dev/null +++ b/Layout/LayoutSurveyFailure.cpp @@ -0,0 +1,58 @@ +#include "LayoutSurveyFailure.h" + +LayoutSurveyFailure::LayoutSurveyFailure(DOGS102* lcd) + : Layout(lcd), + _lTitle(0, 2, "Survey Failed"), + _lId(0, 0, "ID"), + _lDr(8, 0, "DR"), + _lPwr(13, 0, "P"), + _lSw1(12, 7, "Power"), + _lSw2(0, 7, "Survey"), + _fId(2, 0, 5), + _fDr(10, 0, 2), + _fPwr(14, 0, 2), + _fMsg1(0, 4, 17), + _fMsg2(0, 5, 17), + _fInfo(0, 6, 17) +{} + +LayoutSurveyFailure::~LayoutSurveyFailure() {} + +void LayoutSurveyFailure::display() { + clear(); + startUpdate(); + + writeLabel(_lTitle); + writeLabel(_lId); + writeLabel(_lDr); + writeLabel(_lPwr); + writeLabel(_lSw1); + writeLabel(_lSw2); + + endUpdate(); +} + +void LayoutSurveyFailure::updateId(uint32_t id) { + char buf[16]; + size_t size; + + size = snprintf(buf, sizeof(buf), "%lu", id); + writeField(_fId, buf, size, true); +} + +void LayoutSurveyFailure::updateRate(std::string rate) { + writeField(_fDr, rate, true); +} + +void LayoutSurveyFailure::updatePower(uint32_t power) { + char buf[16]; + size_t size; + + size = snprintf(buf, sizeof(buf), "%lu", power); + writeField(_fPwr, buf, size, true); +} + +void LayoutSurveyFailure::updateInfo(std::string info) { + writeField(_fInfo, info, true); +} + diff --git a/Layout/LayoutSurveyFailure.h b/Layout/LayoutSurveyFailure.h new file mode 100644 index 0000000..473fd9f --- /dev/null +++ b/Layout/LayoutSurveyFailure.h @@ -0,0 +1,33 @@ +#ifndef __LAYOUTSURVEYFAILURE_H__ +#define __LAYOUTSURVEYFAILURE_H__ + +#include "Layout.h" + +class LayoutSurveyFailure : public Layout { + public: + LayoutSurveyFailure(DOGS102* lcd); + ~LayoutSurveyFailure(); + + void display(); + void updateId(uint32_t id); + void updateRate(std::string rate); + void updatePower(uint32_t power); + void updateInfo(std::string msg); + + private: + Label _lTitle; + Label _lId; + Label _lDr; + Label _lPwr; + Label _lSw1; + Label _lSw2; + + Field _fId; + Field _fDr; + Field _fPwr; + Field _fMsg1; + Field _fMsg2; + Field _fInfo; +}; + +#endif diff --git a/Layout/LayoutSurveyProgress.cpp b/Layout/LayoutSurveyProgress.cpp new file mode 100644 index 0000000..c0434f7 --- /dev/null +++ b/Layout/LayoutSurveyProgress.cpp @@ -0,0 +1,34 @@ +#include "LayoutSurveyProgress.h" + +LayoutSurveyProgress::LayoutSurveyProgress(DOGS102* lcd) + : Layout(lcd), + _lMsg1(5, 2, "Survey"), + _lMsg2(7, 3, "in"), + _lMsg3(4, 4, "Progress"), + _fCountdownLabel(0, 6, 17), + _fCountdown(0, 7, 9) +{} + +LayoutSurveyProgress::~LayoutSurveyProgress() {} + +void LayoutSurveyProgress::display() { + clear(); + startUpdate(); + + writeLabel(_lMsg1); + writeLabel(_lMsg2); + writeLabel(_lMsg3); + + endUpdate(); +} + +void LayoutSurveyProgress::updateCountdown(uint32_t seconds) { + char buf[16]; + size_t size; + + memset(buf, 0, sizeof(buf)); + writeField(_fCountdownLabel, "No Free Channel", true); + size = snprintf(buf, sizeof(buf), "%lu s", seconds); + writeField(_fCountdown, buf, size, true); +} + diff --git a/Layout/LayoutSurveyProgress.h b/Layout/LayoutSurveyProgress.h new file mode 100644 index 0000000..85a029b --- /dev/null +++ b/Layout/LayoutSurveyProgress.h @@ -0,0 +1,24 @@ +#ifndef __LAYOUTSURVEYPROGRESS_H__ +#define __LAYOUTSURVEYPROGRESS_H__ + +#include "Layout.h" + +class LayoutSurveyProgress : public Layout { + public: + LayoutSurveyProgress(DOGS102* lcd); + ~LayoutSurveyProgress(); + + void display(); + + void updateCountdown(uint32_t seconds); + + private: + Label _lMsg1; + Label _lMsg2; + Label _lMsg3; + + Field _fCountdownLabel; + Field _fCountdown; +}; + +#endif diff --git a/Layout/LayoutSurveySuccess.cpp b/Layout/LayoutSurveySuccess.cpp new file mode 100644 index 0000000..7bcc56b --- /dev/null +++ b/Layout/LayoutSurveySuccess.cpp @@ -0,0 +1,101 @@ +#include "LayoutSurveySuccess.h" + +LayoutSurveySuccess::LayoutSurveySuccess(DOGS102* lcd) + : Layout(lcd), + _lId(0, 0, "ID"), + _lDr(8, 0, "DR"), + _lPwr(13, 0, "P"), + _lUp(0, 1, "UP"), + _lDown(0, 2, "DWN"), + _lSw1(12, 7, "Power"), + _fId(2, 0, 5), + _fDr(10, 0, 2), + _fPwr(14, 0, 2), + _fUpRssi(3, 1, 7), + _fUpSnr(11, 1, 5), + _fDownRssi(4, 2, 7), + _fDownSnr(12, 2, 5), + _fGpsLat(0, 4, 17), + _fGpsLon(0, 3, 17), + _fGpsTime(0, 5, 17), + _fInfo(0, 6, 17), + _fSw2(0, 7, 8) +{} + +LayoutSurveySuccess::~LayoutSurveySuccess() {} + +void LayoutSurveySuccess::display() { + clear(); + startUpdate(); + + writeLabel(_lId); + writeLabel(_lDr); + writeLabel(_lPwr); + writeLabel(_lUp); + writeLabel(_lDown); + writeLabel(_lSw1); + + endUpdate(); +} + +void LayoutSurveySuccess::updateId(uint32_t id) { + char buf[16]; + size_t size; + + size = snprintf(buf, sizeof(buf), "%lu", id); + writeField(_fId, buf, size, true); +} + +void LayoutSurveySuccess::updateRate(std::string rate) { + writeField(_fDr, rate, true); +} + +void LayoutSurveySuccess::updatePower(uint32_t power) { + char buf[16]; + size_t size; + + size = snprintf(buf, sizeof(buf), "%lu", power); + writeField(_fPwr, buf, size, true); +} + +void LayoutSurveySuccess::updateStats(LoRaHandler::LoRaPing ping) { + char buf[16]; + size_t size; + + startUpdate(); + + size = snprintf(buf, sizeof(buf), "%3d dbm", ping.up.rssi); + writeField(_fUpRssi, buf, size); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%2d.%1d", ping.up.snr / 10, abs(ping.up.snr) % 10); + writeField(_fUpSnr, buf, size); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%3d dbm", ping.down.rssi); + writeField(_fDownRssi, buf, size); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%2d.%1d", ping.down.snr / 4, abs(ping.up.snr) % 10 * 25); + writeField(_fDownSnr, buf, size); + + endUpdate(); +} + +void LayoutSurveySuccess::updateGpsLatitude(GPSPARSER::latitude lat) { +} + +void LayoutSurveySuccess::updateGpsLongitude(GPSPARSER::longitude lon) { +} + +void LayoutSurveySuccess::updateGpsTime(struct tm time) { +} + +void LayoutSurveySuccess::updateInfo(std::string info) { + writeField(_fInfo, info, true); +} + +void LayoutSurveySuccess::updateSw2(std::string sw2) { + writeField(_fSw2, sw2, true); +} + diff --git a/Layout/LayoutSurveySuccess.h b/Layout/LayoutSurveySuccess.h new file mode 100644 index 0000000..d5fe1af --- /dev/null +++ b/Layout/LayoutSurveySuccess.h @@ -0,0 +1,46 @@ +#ifndef __LAYOUTSURVEYSUCCESS_H__ +#define __LAYOUTSURVEYSUCCESS_H__ + +#include "Layout.h" +#include "LoRaHandler.h" +#include "GPSPARSER.h" + +class LayoutSurveySuccess : public Layout { + public: + LayoutSurveySuccess(DOGS102* lcd); + ~LayoutSurveySuccess(); + + void display(); + void updateId(uint32_t id); + void updateRate(std::string rate); + void updatePower(uint32_t power); + void updateStats(LoRaHandler::LoRaPing ping); + void updateGpsLatitude(GPSPARSER::latitude lat); + void updateGpsLongitude(GPSPARSER::longitude lon); + void updateGpsTime(struct tm time); + void updateInfo(std::string info); + void updateSw2(std::string sw2); + + private: + Label _lId; + Label _lDr; + Label _lPwr; + Label _lUp; + Label _lDown; + Label _lSw1; + + Field _fId; + Field _fDr; + Field _fPwr; + Field _fUpRssi; + Field _fUpSnr; + Field _fDownRssi; + Field _fDownSnr; + Field _fGpsLat; + Field _fGpsLon; + Field _fGpsTime; + Field _fInfo; + Field _fSw2; +}; + +#endif -- cgit v1.2.3