@@ -47,53 +47,50 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
47
47
#define _BV (x ) (1 << x)
48
48
#endif
49
49
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
-
54
50
// This fixed ugly GCC warning "only initialized variables can be placed into program memory area"
55
51
#if defined(__AVR__)
56
52
#undef PROGMEM
57
53
#define PROGMEM __attribute__ ((section(" .progmem.data" )))
58
54
#endif
59
55
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:
65
63
#include " util/fontlargeletter31x48.h"
66
64
67
- // Change the total fonts included
68
- #define TOTALFONTS 5
65
+ #define MAXFONTS 5 // Do not change this line
69
66
70
67
// Add the font name as declared in the header file. Remove as many
71
68
// as possible to conserve FLASH memory.
72
69
const unsigned char *MicroOLED::fontsPointer[] = {
73
- #if INCLUDE_FONT0
70
+ #ifdef FONT5X7_H
74
71
font5x7,
75
72
#else
76
- 0x0 ,
73
+ 0x0 ,
77
74
#endif
78
- #if INCLUDE_FONT1
75
+ #ifdef FONT8X16_H
79
76
font8x16,
80
77
#else
81
- 0x0 ,
78
+ 0x0 ,
82
79
#endif
83
- #if INCLUDE_FONT2
80
+ #ifdef FONT7SEGMENT_H
84
81
sevensegment,
85
82
#else
86
- 0x0 ,
83
+ 0x0 ,
87
84
#endif
88
- #if INCLUDE_FONT3
89
- fontlargenumber,
85
+ #ifdef FONTLARGENUMBER_H
86
+ fontlargenumber,
90
87
#else
91
- 0x0 ,
88
+ 0x0 ,
92
89
#endif
93
- #ifdef INCLUDE_LARGE_LETTER_FONT
90
+ #ifdef FONTLARGELETTER31X48_H
94
91
fontlargeletter31x48
95
92
#else
96
- 0x0
93
+ 0x0
97
94
#endif
98
95
};
99
96
@@ -1016,7 +1013,13 @@ uint8_t MicroOLED::getFontTotalChar(void)
1016
1013
*/
1017
1014
uint8_t MicroOLED::getTotalFonts (void )
1018
1015
{
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);
1020
1023
}
1021
1024
1022
1025
/* * \brief Get font type.
@@ -1034,7 +1037,7 @@ uint8_t MicroOLED::getFontType(void)
1034
1037
*/
1035
1038
uint8_t MicroOLED::setFontType (uint8_t type)
1036
1039
{
1037
- if ((type >= TOTALFONTS ) || !fontsPointer[type])
1040
+ if ((type >= MAXFONTS ) || !fontsPointer[type])
1038
1041
return false ;
1039
1042
1040
1043
fontType = type;
0 commit comments