Custom "Installer Assistant" software. Modified Single Sweep Mode. Goes right into single sweep mode upon power-up and displays signal strength. Works with mbed-os 5.1.2 and mdot lib 5.1.5

Dependencies:   DOGS102 GpsParser ISL29011 MMA845x MPL3115A2 MTS-Serial NCP5623B libmDot-dev-mbed5-deprecated

Fork of MTDOT-BOX-EVB-Factory-Firmware by MultiTech

Committer:
ScottHoppeMultitech
Date:
Thu Dec 28 21:35:48 2017 +0000
Revision:
12:671b15182260
Parent:
1:71125aa00e33
Custom mDotBox software -modified single sweep mode - goes straight into a single sweep mode and display signal strength. Works With mbed-os 5.1.2 and mdot lib 5.1.5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 1:71125aa00e33 1 /* Copyright (c) <2016> <MultiTech Systems>, MIT License
Mike Fiore 1:71125aa00e33 2 *
Mike Fiore 1:71125aa00e33 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Mike Fiore 1:71125aa00e33 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
Mike Fiore 1:71125aa00e33 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
Mike Fiore 1:71125aa00e33 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Mike Fiore 1:71125aa00e33 7 * furnished to do so, subject to the following conditions:
Mike Fiore 1:71125aa00e33 8 *
Mike Fiore 1:71125aa00e33 9 * The above copyright notice and this permission notice shall be included in all copies or
Mike Fiore 1:71125aa00e33 10 * substantial portions of the Software.
Mike Fiore 1:71125aa00e33 11 *
Mike Fiore 1:71125aa00e33 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Mike Fiore 1:71125aa00e33 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Mike Fiore 1:71125aa00e33 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Mike Fiore 1:71125aa00e33 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Mike Fiore 1:71125aa00e33 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Mike Fiore 1:71125aa00e33 17 */
Mike Fiore 1:71125aa00e33 18
Mike Fiore 1:71125aa00e33 19 #include "Layout.h"
Mike Fiore 1:71125aa00e33 20 #include "font_6x8.h"
Mike Fiore 1:71125aa00e33 21
Mike Fiore 1:71125aa00e33 22 Label::Label(uint8_t col, uint8_t row, std::string value)
Mike Fiore 1:71125aa00e33 23 : _col(col),
Mike Fiore 1:71125aa00e33 24 _row(row),
Mike Fiore 1:71125aa00e33 25 _value(value)
Mike Fiore 1:71125aa00e33 26 {}
Mike Fiore 1:71125aa00e33 27
Mike Fiore 1:71125aa00e33 28 Field::Field(uint8_t col, uint8_t row, uint8_t maxSize)
Mike Fiore 1:71125aa00e33 29 : _col(col),
Mike Fiore 1:71125aa00e33 30 _row(row),
Mike Fiore 1:71125aa00e33 31 _maxSize(maxSize)
Mike Fiore 1:71125aa00e33 32 {}
Mike Fiore 1:71125aa00e33 33
Mike Fiore 1:71125aa00e33 34 Image::Image(uint8_t col, uint8_t row, const uint8_t* bmp)
Mike Fiore 1:71125aa00e33 35 : _col(col),
Mike Fiore 1:71125aa00e33 36 _row(row),
Mike Fiore 1:71125aa00e33 37 _bmp(bmp)
Mike Fiore 1:71125aa00e33 38 {}
Mike Fiore 1:71125aa00e33 39
Mike Fiore 1:71125aa00e33 40 Layout::Layout(DOGS102* lcd) : _lcd(lcd) {}
Mike Fiore 1:71125aa00e33 41
Mike Fiore 1:71125aa00e33 42 Layout::~Layout() {}
Mike Fiore 1:71125aa00e33 43
Mike Fiore 1:71125aa00e33 44 void Layout::clear() {
Mike Fiore 1:71125aa00e33 45 _lcd->clearBuffer();
Mike Fiore 1:71125aa00e33 46 }
Mike Fiore 1:71125aa00e33 47
Mike Fiore 1:71125aa00e33 48 void Layout::startUpdate() {
Mike Fiore 1:71125aa00e33 49 _lcd->startUpdate();
Mike Fiore 1:71125aa00e33 50 }
Mike Fiore 1:71125aa00e33 51
Mike Fiore 1:71125aa00e33 52 void Layout::endUpdate() {
Mike Fiore 1:71125aa00e33 53 _lcd->endUpdate();
Mike Fiore 1:71125aa00e33 54 }
Mike Fiore 1:71125aa00e33 55
Mike Fiore 1:71125aa00e33 56 bool Layout::writeLabel(const Label& label) {
Mike Fiore 1:71125aa00e33 57 return writeText(label._col, label._row, label._value.c_str(), label._value.size());
Mike Fiore 1:71125aa00e33 58 }
Mike Fiore 1:71125aa00e33 59
Mike Fiore 1:71125aa00e33 60 bool Layout::writeField(const Field& field, const std::string& value, bool apply) {
Mike Fiore 1:71125aa00e33 61 bool ret;
Mike Fiore 1:71125aa00e33 62 std::string v = value;
Mike Fiore 1:71125aa00e33 63
Mike Fiore 1:71125aa00e33 64 if (apply)
Mike Fiore 1:71125aa00e33 65 startUpdate();
Mike Fiore 1:71125aa00e33 66
Mike Fiore 1:71125aa00e33 67 // fill the whole length with blank space in case the previous value was longer than this one
Mike Fiore 1:71125aa00e33 68 while (v.size() < field._maxSize)
Mike Fiore 1:71125aa00e33 69 v += " ";
Mike Fiore 1:71125aa00e33 70
Mike Fiore 1:71125aa00e33 71 ret = writeText(field._col, field._row, v.c_str(), field._maxSize);
Mike Fiore 1:71125aa00e33 72
Mike Fiore 1:71125aa00e33 73 if (apply)
Mike Fiore 1:71125aa00e33 74 endUpdate();
Mike Fiore 1:71125aa00e33 75
Mike Fiore 1:71125aa00e33 76 return true;
Mike Fiore 1:71125aa00e33 77 }
Mike Fiore 1:71125aa00e33 78
Mike Fiore 1:71125aa00e33 79 bool Layout::writeField(const Field& field, const char* value, size_t size, bool apply) {
Mike Fiore 1:71125aa00e33 80 bool ret;
Mike Fiore 1:71125aa00e33 81 char buf[32];
Mike Fiore 1:71125aa00e33 82 // fill the whole length with blank space in case the previous value was longer than this one
Mike Fiore 1:71125aa00e33 83 memset(buf, ' ', sizeof(buf));
Mike Fiore 1:71125aa00e33 84
Mike Fiore 1:71125aa00e33 85 if (apply)
Mike Fiore 1:71125aa00e33 86 startUpdate();
Mike Fiore 1:71125aa00e33 87
Mike Fiore 1:71125aa00e33 88 snprintf(buf, sizeof(buf), "%s", value);
Mike Fiore 1:71125aa00e33 89 // wipe out the null character - the LCD driver will just skip that character otherwise
Mike Fiore 1:71125aa00e33 90 buf[size] = ' ';
Mike Fiore 1:71125aa00e33 91
Mike Fiore 1:71125aa00e33 92 ret = writeText(field._col, field._row, buf, field._maxSize);
Mike Fiore 1:71125aa00e33 93
Mike Fiore 1:71125aa00e33 94 if (apply)
Mike Fiore 1:71125aa00e33 95 endUpdate();
Mike Fiore 1:71125aa00e33 96
Mike Fiore 1:71125aa00e33 97 return true;
Mike Fiore 1:71125aa00e33 98 }
Mike Fiore 1:71125aa00e33 99
Mike Fiore 1:71125aa00e33 100 bool Layout::writeImage(const Image& image, bool apply) {
Mike Fiore 1:71125aa00e33 101 bool ret;
Mike Fiore 1:71125aa00e33 102
Mike Fiore 1:71125aa00e33 103 if (apply)
Mike Fiore 1:71125aa00e33 104 startUpdate();
Mike Fiore 1:71125aa00e33 105
Mike Fiore 1:71125aa00e33 106 ret = writeBmp(image._row, image._col, image._bmp);
Mike Fiore 1:71125aa00e33 107
Mike Fiore 1:71125aa00e33 108 if (apply)
Mike Fiore 1:71125aa00e33 109 endUpdate();
Mike Fiore 1:71125aa00e33 110
Mike Fiore 1:71125aa00e33 111 return ret;
Mike Fiore 1:71125aa00e33 112 }
Mike Fiore 1:71125aa00e33 113
Mike Fiore 1:71125aa00e33 114 void Layout::removeField(const Field& field) {
Mike Fiore 1:71125aa00e33 115 startUpdate();
Mike Fiore 1:71125aa00e33 116 std::string s(' ', field._maxSize);
Mike Fiore 1:71125aa00e33 117 writeText(field._row, field._col, s.c_str(), s.size());
Mike Fiore 1:71125aa00e33 118 endUpdate();
Mike Fiore 1:71125aa00e33 119 }
Mike Fiore 1:71125aa00e33 120
Mike Fiore 1:71125aa00e33 121 bool Layout::writeText(uint8_t col, uint8_t row, const char* value, size_t size) {
Mike Fiore 1:71125aa00e33 122 _lcd->writeText(col*6, row, font_6x8, value, size);
Mike Fiore 1:71125aa00e33 123
Mike Fiore 1:71125aa00e33 124 return true;
Mike Fiore 1:71125aa00e33 125 }
Mike Fiore 1:71125aa00e33 126
Mike Fiore 1:71125aa00e33 127 bool Layout::writeBmp(uint8_t col, uint8_t row, const uint8_t* bmp) {
Mike Fiore 1:71125aa00e33 128 _lcd->writeBitmap(col*6, row, bmp);
Mike Fiore 1:71125aa00e33 129
Mike Fiore 1:71125aa00e33 130 return true;
Mike Fiore 1:71125aa00e33 131 }
Mike Fiore 1:71125aa00e33 132