summaryrefslogtreecommitdiff
path: root/Layout
diff options
context:
space:
mode:
Diffstat (limited to 'Layout')
-rw-r--r--Layout/Layout.cpp9
-rw-r--r--Layout/LayoutDemoSampling.cpp60
-rw-r--r--Layout/LayoutDemoSampling.h8
-rw-r--r--Layout/LayoutHelp.cpp4
-rw-r--r--Layout/LayoutHelp.h1
-rw-r--r--Layout/LayoutJoin.cpp16
-rw-r--r--Layout/LayoutStartup.cpp1
-rw-r--r--Layout/LayoutSurveyFailure.cpp4
-rw-r--r--Layout/LayoutSurveyProgress.cpp6
-rw-r--r--Layout/LayoutSurveySuccess.cpp12
-rw-r--r--Layout/LayoutSweepProgress.cpp7
11 files changed, 78 insertions, 50 deletions
diff --git a/Layout/Layout.cpp b/Layout/Layout.cpp
index 7b0c375..e9f6aee 100644
--- a/Layout/Layout.cpp
+++ b/Layout/Layout.cpp
@@ -61,17 +61,18 @@ bool Layout::writeField(const Field& field, const std::string& value, bool apply
bool Layout::writeField(const Field& field, const char* value, size_t size, bool apply) {
bool ret;
char buf[32];
- size_t s = (field._maxSize > size) ? size : field._maxSize;
// fill the whole length with blank space in case the previous value was longer than this one
- memset(buf, 0x20, sizeof(buf));
+ memset(buf, ' ', sizeof(buf));
if (apply)
startUpdate();
- snprintf(buf, s, "%s", value);
+ snprintf(buf, sizeof(buf), "%s", value);
+ // wipe out the null character - the LCD driver will just skip that character otherwise
+ buf[size] = ' ';
- ret = writeText(field._col, field._row, value, field._maxSize);
+ ret = writeText(field._col, field._row, buf, field._maxSize);
if (apply)
endUpdate();
diff --git a/Layout/LayoutDemoSampling.cpp b/Layout/LayoutDemoSampling.cpp
index 14a4cf7..990e1e4 100644
--- a/Layout/LayoutDemoSampling.cpp
+++ b/Layout/LayoutDemoSampling.cpp
@@ -54,11 +54,9 @@ 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);
+ // make sure the string version is used
+ writeField(_fInfo, string("No Free Channel"), true);
+ size = snprintf(buf, sizeof(buf), "%lu s", seconds);
writeField(_fSw2, buf, size, true);
}
@@ -66,10 +64,6 @@ 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)
@@ -80,3 +74,51 @@ void LayoutDemoSampling::updateInterval(uint32_t seconds) {
writeField(_fInfo, buf, size, true);
}
+void LayoutDemoSampling::updateAccelerationX(int16_t x) {
+ char buf[16];
+ size_t size;
+ size = snprintf(buf, sizeof(buf), "%d", x);
+ writeField(_fAccx, buf, size, true);
+}
+
+void LayoutDemoSampling::updateAccelerationY(int16_t y) {
+ char buf[16];
+ size_t size;
+ size = snprintf(buf, sizeof(buf), "%d", y);
+ writeField(_fAccy, buf, size, true);
+}
+
+void LayoutDemoSampling::updateAccelerationZ(int16_t z) {
+ char buf[16];
+ size_t size;
+ size = snprintf(buf, sizeof(buf), "%d", z);
+ writeField(_fAccz, buf, size, true);
+}
+
+void LayoutDemoSampling::updatePressure(float pressure) {
+ char buf[16];
+ size_t size;
+ size = snprintf(buf, sizeof(buf), "%3.2f KPa", pressure/1000);
+ writeField(_fPres, buf, size, true);
+}
+
+void LayoutDemoSampling::updateAltitude(float altitude) {
+ char buf[16];
+ size_t size;
+ size = snprintf(buf, sizeof(buf), "%5.2f m", altitude);
+ writeField(_fAlt, buf, size, true);
+}
+
+void LayoutDemoSampling::updateTemperature(float temperature) {
+ char buf[16];
+ size_t size;
+ size = snprintf(buf, sizeof(buf), "%3.2f C", temperature);
+ writeField(_fTemp, buf, size, true);
+}
+
+void LayoutDemoSampling::updateLight(float light) {
+ char buf[16];
+ size_t size;
+ size = snprintf(buf, sizeof(buf), "%4.2f lux", light);
+ writeField(_fLight, buf, size, true);
+}
diff --git a/Layout/LayoutDemoSampling.h b/Layout/LayoutDemoSampling.h
index 9d075b2..a590966 100644
--- a/Layout/LayoutDemoSampling.h
+++ b/Layout/LayoutDemoSampling.h
@@ -2,6 +2,7 @@
#define __LAYOUTDEMOSAMPLING_H__
#include "Layout.h"
+#include "MMA845x.h"
class LayoutDemoSampling : public Layout {
public:
@@ -14,6 +15,13 @@ class LayoutDemoSampling : public Layout {
void updateSw2(std::string sw2);
void updateCountdown(uint32_t seconds);
void updateInterval(uint32_t seconds);
+ void updateAccelerationX(int16_t x);
+ void updateAccelerationY(int16_t y);
+ void updateAccelerationZ(int16_t z);
+ void updatePressure(float pressure);
+ void updateAltitude(float altitude);
+ void updateTemperature(float temperature);
+ void updateLight(float light);
private:
Label _lAccx;
diff --git a/Layout/LayoutHelp.cpp b/Layout/LayoutHelp.cpp
index 7ed3e61..c3c0b70 100644
--- a/Layout/LayoutHelp.cpp
+++ b/Layout/LayoutHelp.cpp
@@ -35,10 +35,6 @@ void LayoutHelp::updateMsg(std::string msg) {
writeField(_fMsg, msg, true);
}
-void LayoutHelp::removeMsg() {
- removeField(_fMsg);
-}
-
void LayoutHelp::updateSw1(std::string s) {
writeField(_fSw1, s, true);
}
diff --git a/Layout/LayoutHelp.h b/Layout/LayoutHelp.h
index 44e70d5..fd4ff02 100644
--- a/Layout/LayoutHelp.h
+++ b/Layout/LayoutHelp.h
@@ -12,7 +12,6 @@ class LayoutHelp : public Layout {
void updateMode(std::string mode);
void updateDescription(std::string description);
void updateMsg(std::string msg);
- void removeMsg();
void updateSw1(std::string s);
void updateSw2(std::string s);
diff --git a/Layout/LayoutJoin.cpp b/Layout/LayoutJoin.cpp
index fea558e..6d58b57 100644
--- a/Layout/LayoutJoin.cpp
+++ b/Layout/LayoutJoin.cpp
@@ -53,7 +53,6 @@ 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);
}
@@ -66,7 +65,6 @@ 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);
}
@@ -75,7 +73,6 @@ 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);
}
@@ -88,18 +85,19 @@ void LayoutJoin::updateCountdown(uint32_t seconds) {
char buf[16];
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(_fCountdownLabel, "No Free Channel ", true);
+ // make sure the string version is used
+ writeField(_fCountdownLabel, string("No Free Channel"), true);
size = snprintf(buf, sizeof(buf), "%lu s", seconds);
writeField(_fCountdown, buf, size, true);
}
void LayoutJoin::displayCancel(bool display) {
+ std::string str;
if (display)
- writeField(_fCancel, "Cancel", true);
+ str = "Cancel";
else
- removeField(_fCancel);
+ str = string(17, ' ');
+
+ writeField(_fCancel, str, true);
}
diff --git a/Layout/LayoutStartup.cpp b/Layout/LayoutStartup.cpp
index 1662155..570761e 100644
--- a/Layout/LayoutStartup.cpp
+++ b/Layout/LayoutStartup.cpp
@@ -38,7 +38,6 @@ void LayoutStartup::updateGPS(bool gps) {
char buf[32];
size_t size;
- memset(buf, 0, sizeof(buf));
size = snprintf(buf, sizeof(buf), "%sGPS Detected", gps ? "" : "No ");
writeField(_fGps, buf, size);
}
diff --git a/Layout/LayoutSurveyFailure.cpp b/Layout/LayoutSurveyFailure.cpp
index 4b313af..1b90fe6 100644
--- a/Layout/LayoutSurveyFailure.cpp
+++ b/Layout/LayoutSurveyFailure.cpp
@@ -55,7 +55,6 @@ void LayoutSurveyFailure::updateGpsLatitude(GPSPARSER::latitude lat) {
char buf[32];
size_t size;
- memset(buf, 0, sizeof(buf));
size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c",
abs(lat.degrees),
lat.minutes,
@@ -73,7 +72,6 @@ void LayoutSurveyFailure::updateGpsLongitude(GPSPARSER::longitude lon) {
char buf[32];
size_t size;
- memset(buf, 0, sizeof(buf));
size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c",
abs(lon.degrees),
lon.minutes,
@@ -87,7 +85,6 @@ void LayoutSurveyFailure::updateGpsTime(struct tm time) {
char buf[32];
size_t size;
- memset(buf, 0, sizeof(buf));
size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d",
time.tm_hour,
time.tm_min,
@@ -113,7 +110,6 @@ void LayoutSurveyFailure::updatePassFail(uint8_t pass, uint8_t fail) {
char buf[32];
size_t size;
- memset(buf, 0, sizeof(buf));
size = snprintf(buf, sizeof(buf), "Pass %u Fail %u", pass, fail);
writeField(_fGpsTime, buf, size, true);
}
diff --git a/Layout/LayoutSurveyProgress.cpp b/Layout/LayoutSurveyProgress.cpp
index 4a50fbb..b3d6338 100644
--- a/Layout/LayoutSurveyProgress.cpp
+++ b/Layout/LayoutSurveyProgress.cpp
@@ -26,10 +26,8 @@ void LayoutSurveyProgress::updateCountdown(uint32_t seconds) {
char buf[16];
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(_fCountdownLabel, "No Free Channel ", true);
+ // make sure the string version is used
+ writeField(_fCountdownLabel, string("No Free Channel"), true);
size = snprintf(buf, sizeof(buf), "%lu s", seconds);
writeField(_fCountdown, buf, size, true);
}
diff --git a/Layout/LayoutSurveySuccess.cpp b/Layout/LayoutSurveySuccess.cpp
index 3ba1008..e59a754 100644
--- a/Layout/LayoutSurveySuccess.cpp
+++ b/Layout/LayoutSurveySuccess.cpp
@@ -71,7 +71,7 @@ void LayoutSurveySuccess::updateStats(LoRaHandler::LoRaLink link) {
writeField(_fDownRssi, buf, size);
memset(buf, 0, sizeof(buf));
- size = snprintf(buf, sizeof(buf), "%2.1f", (float)link.down.snr / 4.0);
+ size = snprintf(buf, sizeof(buf), "%2.1f", (float)link.down.snr / 10.0);
writeField(_fDownSnr, buf, size);
endUpdate();
@@ -81,7 +81,6 @@ void LayoutSurveySuccess::updateGpsLatitude(GPSPARSER::latitude lat) {
char buf[32];
size_t size;
- memset(buf, 0, sizeof(buf));
size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c",
abs(lat.degrees),
lat.minutes,
@@ -99,7 +98,6 @@ void LayoutSurveySuccess::updateGpsLongitude(GPSPARSER::longitude lon) {
char buf[32];
size_t size;
- memset(buf, 0, sizeof(buf));
size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c",
abs(lon.degrees),
lon.minutes,
@@ -113,7 +111,6 @@ void LayoutSurveySuccess::updateGpsTime(struct tm time) {
char buf[32];
size_t size;
- memset(buf, 0, sizeof(buf));
size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d",
time.tm_hour,
time.tm_min,
@@ -139,10 +136,8 @@ void LayoutSurveySuccess::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);
+ // make sure the string version is used
+ writeField(_fInfo, string("No Free Channel"), true);
size = snprintf(buf, sizeof(buf), "%lu s", seconds);
writeField(_fSw2, buf, size, true);
}
@@ -151,7 +146,6 @@ void LayoutSurveySuccess::updatePassFail(uint8_t pass, uint8_t fail) {
char buf[32];
size_t size;
- memset(buf, 0, sizeof(buf));
size = snprintf(buf, sizeof(buf), "Pass %u Fail %u", pass, fail);
writeField(_fGpsTime, buf, size, true);
}
diff --git a/Layout/LayoutSweepProgress.cpp b/Layout/LayoutSweepProgress.cpp
index ec4bbc9..9ddd536 100644
--- a/Layout/LayoutSweepProgress.cpp
+++ b/Layout/LayoutSweepProgress.cpp
@@ -27,7 +27,6 @@ void LayoutSweepProgress::updateProgress(uint8_t complete, uint8_t total) {
char buf[8];
size_t size;
- memset(buf, 0, sizeof(buf));
size = snprintf(buf, sizeof(buf), "%u/%u", complete, total);
writeField(_fProgress, buf, size, true);
}
@@ -36,10 +35,8 @@ void LayoutSweepProgress::updateCountdown(uint32_t seconds) {
char buf[16];
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(_fCountdownLabel, "No Free Channel ", true);
+ // make sure the string version is used
+ writeField(_fCountdownLabel, string("No Free Channel"), true);
size = snprintf(buf, sizeof(buf), "%lu s", seconds);
writeField(_fCountdown, buf, size, true);
}