From 41a5c0de1343c4a4163c7096ea33bbfd6c3e84cb Mon Sep 17 00:00:00 2001 From: Mike Fiore Date: Fri, 4 Dec 2015 09:53:21 -0600 Subject: implement demo mode logic - still need to add sensor data --- Layout/LayoutDemoSampling.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++ Layout/LayoutDemoSampling.h | 39 ++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 Layout/LayoutDemoSampling.cpp create mode 100644 Layout/LayoutDemoSampling.h (limited to 'Layout') diff --git a/Layout/LayoutDemoSampling.cpp b/Layout/LayoutDemoSampling.cpp new file mode 100644 index 0000000..08d74ff --- /dev/null +++ b/Layout/LayoutDemoSampling.cpp @@ -0,0 +1,82 @@ +#include "LayoutDemoSampling.h" + +LayoutDemoSampling::LayoutDemoSampling(DOGS102* lcd) + : Layout(lcd), + _lAccx(0, 0, "AccX"), + _lAccy(6, 0, "AccY"), + _lAccz(12, 0, "AccZ"), + _lPres(0, 2, "Press="), + _lAlt(0, 3, "Alt="), + _lTemp(0, 4, "Temp="), + _lLight(0, 5, "Light="), + _fAccx(0, 1, 5), + _fAccy(6, 1, 5), + _fAccz(12, 1, 5), + _fPres(6, 2, 11), + _fAlt(4, 3, 13), + _fTemp(5, 4, 12), + _fLight(6, 5, 11), + _fInfo(0, 6, 17), + _fSw1(9, 7, 8), + _fSw2(0, 7, 8) +{} + +LayoutDemoSampling::~LayoutDemoSampling() {} + +void LayoutDemoSampling::display() { + clear(); + startUpdate(); + + writeLabel(_lAccx); + writeLabel(_lAccy); + writeLabel(_lAccz); + writeLabel(_lPres); + writeLabel(_lAlt); + writeLabel(_lTemp); + writeLabel(_lLight); + + endUpdate(); +} + +void LayoutDemoSampling::updateInfo(std::string info) { + writeField(_fInfo, info, true); +} + +void LayoutDemoSampling::updateSw1(std::string sw1) { + writeField(_fSw1, sw1, true); +} + +void LayoutDemoSampling::updateSw2(std::string sw2) { + writeField(_fSw2, sw2, true); +} + +void LayoutDemoSampling::updateCountdown(uint32_t seconds) { + char buf[32]; + size_t size; + + memset(buf, 0, sizeof(buf)); + // for some reason, there's a % character that gets displayed in the last column + // add the extra spaces to wipe it out + writeField(_fInfo, "No Free Channel ", true); + size = snprintf(buf, sizeof(buf), "%lu s", seconds); + writeField(_fSw2, buf, size, true); +} + +void LayoutDemoSampling::updateInterval(uint32_t seconds) { + char buf[32]; + size_t size; + + memset(buf, ' ', sizeof(buf)); + writeField(_fInfo, buf, size, true); + + memset(buf, 0, sizeof(buf)); + if (seconds < 60) + size = snprintf(buf, sizeof(buf), "Interval %lu s", seconds); + else if (seconds < 60 * 60) + size = snprintf(buf, sizeof(buf), "Interval %lu min", seconds / 60); + else + size = snprintf(buf, sizeof(buf), "Interval %lu hr", seconds / (60 * 60)); + + writeField(_fInfo, buf, size, true); +} + diff --git a/Layout/LayoutDemoSampling.h b/Layout/LayoutDemoSampling.h new file mode 100644 index 0000000..9d075b2 --- /dev/null +++ b/Layout/LayoutDemoSampling.h @@ -0,0 +1,39 @@ +#ifndef __LAYOUTDEMOSAMPLING_H__ +#define __LAYOUTDEMOSAMPLING_H__ + +#include "Layout.h" + +class LayoutDemoSampling : public Layout { + public: + LayoutDemoSampling(DOGS102* lcd); + ~LayoutDemoSampling(); + + void display(); + void updateInfo(std::string info); + void updateSw1(std::string sw1); + void updateSw2(std::string sw2); + void updateCountdown(uint32_t seconds); + void updateInterval(uint32_t seconds); + + private: + Label _lAccx; + Label _lAccy; + Label _lAccz; + Label _lPres; + Label _lAlt; + Label _lTemp; + Label _lLight; + + Field _fAccx; + Field _fAccy; + Field _fAccz; + Field _fPres; + Field _fAlt; + Field _fTemp; + Field _fLight; + Field _fInfo; + Field _fSw1; + Field _fSw2; +}; + +#endif -- cgit v1.2.3