aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen V. Brown <[email protected]>2019-12-31 22:58:52 +1100
committerBen V. Brown <[email protected]>2019-12-31 22:58:52 +1100
commit26bf31ae642a6b1f44f481a65fcb446e7494393b (patch)
tree914c17b2e2fbf5a42e86998d85bd62eaeb81728e
parent7683ad155df03ea6411c4fd197790d68ee534d24 (diff)
downloadIronOS-26bf31ae642a6b1f44f481a65fcb446e7494393b.tar.gz
IronOS-26bf31ae642a6b1f44f481a65fcb446e7494393b.zip
Make zero suppression optional
-rw-r--r--workspace/TS100/Core/Inc/OLED.hpp2
-rw-r--r--workspace/TS100/Core/Src/OLED.cpp5
2 files changed, 4 insertions, 3 deletions
diff --git a/workspace/TS100/Core/Inc/OLED.hpp b/workspace/TS100/Core/Inc/OLED.hpp
index 56f14b2e..2ceacb21 100644
--- a/workspace/TS100/Core/Inc/OLED.hpp
+++ b/workspace/TS100/Core/Inc/OLED.hpp
@@ -74,7 +74,7 @@ public:
drawArea(x, 0, width, 16, buffer);
}
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
- static void printNumber(uint16_t number, uint8_t places);
+ static void printNumber(uint16_t number, uint8_t places,bool noLeaderZeros=true);
// Draws a number at the current cursor location
// Clears the buffer
static void clearScreen() {
diff --git a/workspace/TS100/Core/Src/OLED.cpp b/workspace/TS100/Core/Src/OLED.cpp
index 71c06f16..7506dd50 100644
--- a/workspace/TS100/Core/Src/OLED.cpp
+++ b/workspace/TS100/Core/Src/OLED.cpp
@@ -175,7 +175,7 @@ inline void stripLeaderZeros(char *buffer) {
}
}
// maximum places is 5
-void OLED::printNumber(uint16_t number, uint8_t places) {
+void OLED::printNumber(uint16_t number, uint8_t places, bool noLeaderZeros) {
char buffer[7] = { 0 };
if (places >= 5) {
@@ -203,7 +203,8 @@ void OLED::printNumber(uint16_t number, uint8_t places) {
}
buffer[0] = 2 + number % 10;
- stripLeaderZeros(buffer);
+ if (noLeaderZeros)
+ stripLeaderZeros(buffer);
print(buffer);
}