summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Layout/Layout.cpp9
-rw-r--r--Layout/LayoutDemoSampling.cpp18
-rw-r--r--Layout/LayoutHelp.cpp4
-rw-r--r--Layout/LayoutHelp.h1
-rw-r--r--Layout/LayoutJoin.cpp15
-rw-r--r--Layout/LayoutStartup.cpp1
-rw-r--r--Layout/LayoutSurveyFailure.cpp4
-rw-r--r--Layout/LayoutSurveyProgress.cpp5
-rw-r--r--Layout/LayoutSurveySuccess.cpp9
-rw-r--r--Layout/LayoutSweepProgress.cpp6
-rw-r--r--Mode/Mode.cpp8
-rw-r--r--Mode/ModeSingle.cpp1
12 files changed, 16 insertions, 65 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 aea80ac..1d1c92b 100644
--- a/Layout/LayoutDemoSampling.cpp
+++ b/Layout/LayoutDemoSampling.cpp
@@ -54,11 +54,8 @@ 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(_fInfo, "No Free Channel", true);
+ size = snprintf(buf, sizeof(buf), "%lu s", seconds);
writeField(_fSw2, buf, size, true);
}
@@ -66,10 +63,6 @@ void LayoutDemoSampling::updateInterval(uint32_t seconds) {
char buf[32];
size_t size;
- memset(buf, ' ', sizeof(buf));
- writeField(_fInfo, buf, sizeof(buf), true);
-
- memset(buf, 0, sizeof(buf));
if (seconds < 60)
size = snprintf(buf, sizeof(buf), "Interval %lu s", seconds);
else if (seconds < 60 * 60)
@@ -83,7 +76,6 @@ void LayoutDemoSampling::updateInterval(uint32_t seconds) {
void LayoutDemoSampling::updateAccelerationX(int16_t x) {
char buf[16];
size_t size;
- memset(buf, ' ', sizeof(buf));
size = snprintf(buf, sizeof(buf), "%d", x);
writeField(_fAccx, buf, size, true);
}
@@ -91,7 +83,6 @@ void LayoutDemoSampling::updateAccelerationX(int16_t x) {
void LayoutDemoSampling::updateAccelerationY(int16_t y) {
char buf[16];
size_t size;
- memset(buf, ' ', sizeof(buf));
size = snprintf(buf, sizeof(buf), "%d", y);
writeField(_fAccy, buf, size, true);
}
@@ -99,7 +90,6 @@ void LayoutDemoSampling::updateAccelerationY(int16_t y) {
void LayoutDemoSampling::updateAccelerationZ(int16_t z) {
char buf[16];
size_t size;
- memset(buf, ' ', sizeof(buf));
size = snprintf(buf, sizeof(buf), "%d", z);
writeField(_fAccz, buf, size, true);
}
@@ -107,7 +97,6 @@ void LayoutDemoSampling::updateAccelerationZ(int16_t z) {
void LayoutDemoSampling::updatePressure(float pressure) {
char buf[16];
size_t size;
- memset(buf, ' ', sizeof(buf));
size = snprintf(buf, sizeof(buf), "%3.2f KPa", pressure/1000);
writeField(_fPres, buf, size, true);
}
@@ -115,7 +104,6 @@ void LayoutDemoSampling::updatePressure(float pressure) {
void LayoutDemoSampling::updateAltitude(float altitude) {
char buf[16];
size_t size;
- memset(buf, ' ', sizeof(buf));
size = snprintf(buf, sizeof(buf), "%5.2f m", altitude);
writeField(_fAlt, buf, size, true);
}
@@ -123,7 +111,6 @@ void LayoutDemoSampling::updateAltitude(float altitude) {
void LayoutDemoSampling::updateTemperature(float temperature) {
char buf[16];
size_t size;
- memset(buf, ' ', sizeof(buf));
size = snprintf(buf, sizeof(buf), "%3.2f C", temperature);
writeField(_fTemp, buf, size, true);
}
@@ -131,7 +118,6 @@ void LayoutDemoSampling::updateTemperature(float temperature) {
void LayoutDemoSampling::updateLight(float light) {
char buf[16];
size_t size;
- memset(buf, ' ', sizeof(buf));
size = snprintf(buf, sizeof(buf), "%4.2f lux", light);
writeField(_fLight, buf, size, true);
}
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..487f04b 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,18 @@ 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);
+ writeField(_fCountdownLabel, "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..42f238b 100644
--- a/Layout/LayoutSurveyProgress.cpp
+++ b/Layout/LayoutSurveyProgress.cpp
@@ -26,10 +26,7 @@ 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);
+ writeField(_fCountdownLabel, "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 2f6a732..6d0fa27 100644
--- a/Layout/LayoutSurveySuccess.cpp
+++ b/Layout/LayoutSurveySuccess.cpp
@@ -86,7 +86,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,
@@ -104,7 +103,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,
@@ -118,7 +116,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,
@@ -144,10 +141,7 @@ 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);
+ writeField(_fInfo, "No Free Channel", true);
size = snprintf(buf, sizeof(buf), "%lu s", seconds);
writeField(_fSw2, buf, size, true);
}
@@ -156,7 +150,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..36debef 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,7 @@ 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);
+ writeField(_fCountdownLabel, "No Free Channel", true);
size = snprintf(buf, sizeof(buf), "%lu s", seconds);
writeField(_fCountdown, buf, size, true);
}
diff --git a/Mode/Mode.cpp b/Mode/Mode.cpp
index d05f4b0..4d5af8a 100644
--- a/Mode/Mode.cpp
+++ b/Mode/Mode.cpp
@@ -66,14 +66,6 @@ bool Mode::appendDataFile(const DataItem& data) {
char stats_buf[32];
size_t size;
- memset(main_buf, 0, sizeof(main_buf));
- memset(id_buf, 0, sizeof(id_buf));
- memset(lat_buf, 0, sizeof(lat_buf));
- memset(lon_buf, 0, sizeof(lon_buf));
- memset(alt_buf, 0, sizeof(alt_buf));
- memset(time_buf, 0, sizeof(time_buf));
- memset(stats_buf, 0, sizeof(stats_buf));
-
snprintf(id_buf, sizeof(id_buf), "%c%ld", (data.type == single) ? 'P' : 'S', data.index);
// if we had GPS lock, format GPS data
diff --git a/Mode/ModeSingle.cpp b/Mode/ModeSingle.cpp
index 52eb64a..105fa16 100644
--- a/Mode/ModeSingle.cpp
+++ b/Mode/ModeSingle.cpp
@@ -295,7 +295,6 @@ std::string ModeSingle::formatRatePower() {
char buf[8];
size_t size;
- memset(buf, 0, sizeof(buf));
msg += "DR=";
msg += _dot->DataRateStr(_data_rate).substr(3);
msg += " P=";