Skip to content

Commit b98ccb9

Browse files
committed
Modify #32 : commenting the #include disables the font
1 parent edcf45b commit b98ccb9

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

src/SFE_MicroOLED.cpp

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,53 +47,50 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
4747
#define _BV(x) (1 << x)
4848
#endif
4949

50-
// The 31x48 font is handy, but uses a big chunk of flash memory - about 7k.
51-
// If you want to use font 4 in your sketch, uncomment out the line below:
52-
//#define INCLUDE_LARGE_LETTER_FONT
53-
5450
// This fixed ugly GCC warning "only initialized variables can be placed into program memory area"
5551
#if defined(__AVR__)
5652
#undef PROGMEM
5753
#define PROGMEM __attribute__((section(".progmem.data")))
5854
#endif
5955

60-
// Add header of the fonts here. Remove as many as possible to conserve FLASH memory.
61-
#include "util/font5x7.h"
62-
#include "util/font8x16.h"
63-
#include "util/fontlargenumber.h"
64-
#include "util/7segment.h"
56+
// Add header of the fonts here. Comment as many as possible to conserve FLASH memory.
57+
#include "util/font5x7.h" // Comment this line if you do not need the 5x7 font
58+
#include "util/font8x16.h" // Comment this line if you do not need the 8x16 font
59+
#include "util/fontlargenumber.h" // Comment this line if you do not need the large number font
60+
#include "util/7segment.h" // Comment this line if you do not need the 7segment font
61+
// The 31x48 font is handy, but uses a big chunk of flash memory - about 7k.
62+
// If you want to save memory, comment out the line below:
6563
#include "util/fontlargeletter31x48.h"
6664

67-
// Change the total fonts included
68-
#define TOTALFONTS 5
65+
#define MAXFONTS 5 // Do not change this line
6966

7067
// Add the font name as declared in the header file. Remove as many
7168
// as possible to conserve FLASH memory.
7269
const unsigned char *MicroOLED::fontsPointer[] = {
73-
#if INCLUDE_FONT0
70+
#ifdef FONT5X7_H
7471
font5x7,
7572
#else
76-
0x0,
73+
0x0,
7774
#endif
78-
#if INCLUDE_FONT1
75+
#ifdef FONT8X16_H
7976
font8x16,
8077
#else
81-
0x0,
78+
0x0,
8279
#endif
83-
#if INCLUDE_FONT2
80+
#ifdef FONT7SEGMENT_H
8481
sevensegment,
8582
#else
86-
0x0,
83+
0x0,
8784
#endif
88-
#if INCLUDE_FONT3
89-
fontlargenumber,
85+
#ifdef FONTLARGENUMBER_H
86+
fontlargenumber,
9087
#else
91-
0x0,
88+
0x0,
9289
#endif
93-
#ifdef INCLUDE_LARGE_LETTER_FONT
90+
#ifdef FONTLARGELETTER31X48_H
9491
fontlargeletter31x48
9592
#else
96-
0x0
93+
0x0
9794
#endif
9895
};
9996

@@ -1016,7 +1013,13 @@ uint8_t MicroOLED::getFontTotalChar(void)
10161013
*/
10171014
uint8_t MicroOLED::getTotalFonts(void)
10181015
{
1019-
return TOTALFONTS;
1016+
uint8_t totalFonts = 0;
1017+
for (uint8_t thisFont = 0; thisFont < MAXFONTS; thisFont++)
1018+
{
1019+
if (fontsPointer[thisFont] > 0)
1020+
totalFonts++;
1021+
}
1022+
return (totalFonts);
10201023
}
10211024

10221025
/** \brief Get font type.
@@ -1034,7 +1037,7 @@ uint8_t MicroOLED::getFontType(void)
10341037
*/
10351038
uint8_t MicroOLED::setFontType(uint8_t type)
10361039
{
1037-
if ((type >= TOTALFONTS) || !fontsPointer[type])
1040+
if ((type >= MAXFONTS) || !fontsPointer[type])
10381041
return false;
10391042

10401043
fontType = type;

0 commit comments

Comments
 (0)