Make zero suppression optional
This commit is contained in:
@@ -74,7 +74,7 @@ public:
|
|||||||
drawArea(x, 0, width, 16, buffer);
|
drawArea(x, 0, width, 16, buffer);
|
||||||
}
|
}
|
||||||
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
|
// 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
|
// Draws a number at the current cursor location
|
||||||
// Clears the buffer
|
// Clears the buffer
|
||||||
static void clearScreen() {
|
static void clearScreen() {
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ inline void stripLeaderZeros(char *buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// maximum places is 5
|
// 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 };
|
char buffer[7] = { 0 };
|
||||||
|
|
||||||
if (places >= 5) {
|
if (places >= 5) {
|
||||||
@@ -203,7 +203,8 @@ void OLED::printNumber(uint16_t number, uint8_t places) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buffer[0] = 2 + number % 10;
|
buffer[0] = 2 + number % 10;
|
||||||
stripLeaderZeros(buffer);
|
if (noLeaderZeros)
|
||||||
|
stripLeaderZeros(buffer);
|
||||||
print(buffer);
|
print(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user