From 0a9a233b01bb8ae7906c749addc44d76ab57fb02 Mon Sep 17 00:00:00 2001 From: Patrik Jonsson Date: Tue, 16 Mar 2021 19:16:03 -1000 Subject: [PATCH] Each of the fonts can now be included/excluded individually. --- src/SFE_MicroOLED.cpp | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/SFE_MicroOLED.cpp b/src/SFE_MicroOLED.cpp index 6583771..a1addac 100644 --- a/src/SFE_MicroOLED.cpp +++ b/src/SFE_MicroOLED.cpp @@ -63,18 +63,35 @@ along with this program. If not, see . #include "util/fontlargeletter31x48.h" // Change the total fonts included -#ifdef INCLUDE_LARGE_LETTER_FONT #define TOTALFONTS 5 -#else -#define TOTALFONTS 4 -#endif -// Add the font name as declared in the header file. Remove as many as possible to conserve FLASH memory. +// Add the font name as declared in the header file. Remove as many +// as possible to conserve FLASH memory. const unsigned char *MicroOLED::fontsPointer[] = { - font5x7, font8x16, sevensegment, fontlargenumber +#if INCLUDE_FONT0 + font5x7, +#else + 0x0, +#endif +#if INCLUDE_FONT1 + font8x16, +#else + 0x0, +#endif +#if INCLUDE_FONT2 + sevensegment, +#else + 0x0, +#endif +#if INCLUDE_FONT3 + fontlargenumber, +#else + 0x0, +#endif #ifdef INCLUDE_LARGE_LETTER_FONT - , fontlargeletter31x48 +#else + 0x0 #endif }; @@ -1015,8 +1032,8 @@ uint8_t MicroOLED::getFontType(void) */ uint8_t MicroOLED::setFontType(uint8_t type) { - if ((type >= TOTALFONTS) || (type < 0)) - return false; + if ((type >= TOTALFONTS) || !fontsPointer[type]) + return false; fontType = type; fontWidth = pgm_read_byte(fontsPointer[fontType] + 0);