DrawHex dynamicLength

This commit is contained in:
Ben V. Brown
2022-06-16 22:40:21 +10:00
parent 222c251a98
commit 21811b7ad6
3 changed files with 7 additions and 5 deletions

View File

@@ -423,9 +423,9 @@ inline void stripLeaderZeros(char *buffer, uint8_t places) {
}
}
}
void OLED::drawHex(uint32_t x, FontStyle fontStyle) {
void OLED::drawHex(uint32_t x, FontStyle fontStyle, uint8_t digits) {
// print number to hex
for (uint_fast8_t i = 0; i < 8; i++) {
for (uint_fast8_t i = 0; i < digits; i++) {
uint16_t value = (x >> (4 * (7 - i))) & 0b1111;
drawChar(value + 2, fontStyle);
}

View File

@@ -89,7 +89,7 @@ public:
// Draws a checkbox
static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); }
static void debugNumber(int32_t val, FontStyle fontStyle);
static void drawHex(uint32_t x, FontStyle fontStyle);
static void drawHex(uint32_t x, FontStyle fontStyle, uint8_t digits);
static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width
static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset

View File

@@ -758,8 +758,10 @@ void showDebugMenu(void) {
// Print device ID Numbers
{
uint64_t id = getDeviceID();
OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL);
OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL);
OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL, 2);
OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL, 8);
OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL, 8);
}
break;
case 10: