Skip to content

Commit 0a9a233

Browse files
committed
Each of the fonts can now be included/excluded individually.
1 parent 3a8c239 commit 0a9a233

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/SFE_MicroOLED.cpp

+26-9
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
6363
#include "util/fontlargeletter31x48.h"
6464

6565
// Change the total fonts included
66-
#ifdef INCLUDE_LARGE_LETTER_FONT
6766
#define TOTALFONTS 5
68-
#else
69-
#define TOTALFONTS 4
70-
#endif
7167

72-
// Add the font name as declared in the header file. Remove as many as possible to conserve FLASH memory.
68+
// Add the font name as declared in the header file. Remove as many
69+
// as possible to conserve FLASH memory.
7370
const unsigned char *MicroOLED::fontsPointer[] = {
74-
font5x7, font8x16, sevensegment, fontlargenumber
71+
#if INCLUDE_FONT0
72+
font5x7,
73+
#else
74+
0x0,
75+
#endif
76+
#if INCLUDE_FONT1
77+
font8x16,
78+
#else
79+
0x0,
80+
#endif
81+
#if INCLUDE_FONT2
82+
sevensegment,
83+
#else
84+
0x0,
85+
#endif
86+
#if INCLUDE_FONT3
87+
fontlargenumber,
88+
#else
89+
0x0,
90+
#endif
7591
#ifdef INCLUDE_LARGE_LETTER_FONT
76-
,
7792
fontlargeletter31x48
93+
#else
94+
0x0
7895
#endif
7996
};
8097

@@ -1015,8 +1032,8 @@ uint8_t MicroOLED::getFontType(void)
10151032
*/
10161033
uint8_t MicroOLED::setFontType(uint8_t type)
10171034
{
1018-
if ((type >= TOTALFONTS) || (type < 0))
1019-
return false;
1035+
if ((type >= TOTALFONTS) || !fontsPointer[type])
1036+
return false;
10201037

10211038
fontType = type;
10221039
fontWidth = pgm_read_byte(fontsPointer[fontType] + 0);

0 commit comments

Comments
 (0)