From e6eb3e34bc7904e2c21cdaadcd5e84286401d9a5 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 16 Mar 2021 20:34:47 +1100 Subject: [PATCH] Expand drawChar for larger offset --- source/Core/Drivers/OLED.cpp | 9 +++++---- source/Core/Drivers/OLED.hpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 18b9d0fe..df06b3b1 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -117,15 +117,16 @@ void OLED::setFramebuffer(uint8_t *buffer) { * UTF font handling is done using the two input chars. * Precursor is the command char that is used to select the table. */ -void OLED::drawChar(char c) { - if (c == '\x01' && cursor_y == 0) { // 0x01 is used as new line char +void OLED::drawChar(const uint16_t charCode) { + if (charCode == '\x01' && cursor_y == 0) { // 0x01 is used as new line char cursor_x = 0; cursor_y = 8; return; - } else if (c == 0) { + } else if (charCode <=0x01) { return; } - uint16_t index = static_cast(c) - 2; // First index is \x02 + // First index is \x02 + uint16_t index = charCode-2; uint8_t *charPointer; charPointer = ((uint8_t *)currentFont) + ((fontWidth * (fontHeight / 8)) * index); drawArea(cursor_x, cursor_y, fontWidth, fontHeight, charPointer); diff --git a/source/Core/Drivers/OLED.hpp b/source/Core/Drivers/OLED.hpp index 4e7af19f..cacf4230 100644 --- a/source/Core/Drivers/OLED.hpp +++ b/source/Core/Drivers/OLED.hpp @@ -83,7 +83,7 @@ public: static void useSecondaryFramebuffer(bool useSecondary); private: - static void drawChar(char c); // Draw a character to a specific location + static void drawChar(const uint16_t charCode); // Draw a character to the current cursor location static void setFramebuffer(uint8_t *buffer); static const uint8_t *currentFont; // Pointer to the current font used for rendering to the buffer static uint8_t * firstStripPtr; // Pointers to the strips to allow for buffer having extra content