Skip to content

Commit 0e521e5

Browse files
author
Owen L - SFE
committed
provide non-pgmspace support for default font
1 parent 0a1c473 commit 0e521e5

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

src/hyperdisplay.cpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ wind_info_t hyperdisplayDefaultWindow; // This window is used by default so tha
1111
char_info_t hyperdisplayDefaultCharacter; // The default character to use
1212

1313
#if HYPERDISPLAY_USE_PRINT
14-
#if HYPERDISPLAY_INCLUDE_DEFAULT_FONT
15-
#if __has_include ( <avr/pgmspace.h> )
16-
hd_font_extent_t hyperdisplayDefaultXloc[HYPERDISPLAY_DEFAULT_FONT_WIDTH*HYPERDISPLAY_DEFAULT_FONT_HEIGHT];
17-
hd_font_extent_t hyperdisplayDefaultYloc[HYPERDISPLAY_DEFAULT_FONT_WIDTH*HYPERDISPLAY_DEFAULT_FONT_HEIGHT];
18-
#endif /* __has_include( <avr/pgmspace.h> ) */
14+
#if HYPERDISPLAY_INCLUDE_DEFAULT_FONT
15+
hd_font_extent_t hyperdisplayDefaultXloc[HYPERDISPLAY_DEFAULT_FONT_WIDTH*HYPERDISPLAY_DEFAULT_FONT_HEIGHT];
16+
hd_font_extent_t hyperdisplayDefaultYloc[HYPERDISPLAY_DEFAULT_FONT_WIDTH*HYPERDISPLAY_DEFAULT_FONT_HEIGHT];
1917
#endif
2018
#endif
2119

@@ -783,8 +781,7 @@ void hyperdisplay::show( wind_info_t * wind ){ // Outputs the current w
783781
return numWritten;
784782
}
785783

786-
#if HYPERDISPLAY_INCLUDE_DEFAULT_FONT
787-
#if __has_include ( <avr/pgmspace.h> )
784+
#if HYPERDISPLAY_INCLUDE_DEFAULT_FONT
788785
void hyperdisplay::getCharInfo(uint8_t character, char_info_t * character_info)
789786
{
790787
// This is the most basic font implementation, it only prints a monochrome character using the first color of the current window's current color sequence
@@ -841,13 +838,12 @@ void hyperdisplay::show( wind_info_t * wind ){ // Outputs the current w
841838
}
842839
}
843840
#else
844-
#warning "HyperDisplay Default Font Not Supported. Printing will not work without a custom implementation"
841+
#warning "HyperDisplay Default Font Not Included. Printing will not work without a custom implementation"
845842
void hyperdisplay::getCharInfo(uint8_t character, char_info_t * character_info)
846843
{
847844
// A blank implementation of getCharInfo for when the target does not support <avr/pgmspace.h>
848845
character_info->show = false;
849-
}
850-
#endif /* __has_include( <avr/pgmspace.h> ) */
846+
}
851847
#endif /* HYPERDISPLAY_INCLUDE_DEFAULT_FONT */
852848

853849
#else /* HYPERDISPLAY_USE_PRINT */

src/hyperdisplay.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ Purpose: This library standardizes interfaces to displays of many types.
3636

3737
#if HYPERDISPLAY_USE_PRINT //
3838
#if HYPERDISPLAY_INCLUDE_DEFAULT_FONT
39-
#if __has_include ( <avr/pgmspace.h> )
40-
#include "util/font5x7.h"
41-
#define HYPERDISPLAY_DEFAULT_FONT_WIDTH 5
42-
#define HYPERDISPLAY_DEFAULT_FONT_HEIGHT 8
43-
#endif /* __has_include( "util/font5x7.h" ) */
39+
#include "util/font5x7.h"
40+
#define HYPERDISPLAY_DEFAULT_FONT_WIDTH 5
41+
#define HYPERDISPLAY_DEFAULT_FONT_HEIGHT 8
4442
#endif
4543
#endif
4644

src/util/font5x7.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
#ifndef FONT5X7_H
2020
#define FONT5X7_H
2121

22+
#if __has_include ( <avr/pgmspace.h> )
2223
#include <avr/pgmspace.h>
24+
#endif /* __has_include( "util/font5x7.h" ) */
2325

2426
// Standard ASCII 5x7 font
25-
static const unsigned char font5x7[] PROGMEM = {
27+
static const unsigned char font5x7[]
28+
29+
#if __has_include ( <avr/pgmspace.h> )
30+
PROGMEM
31+
#endif /* __has_include( "util/font5x7.h" ) */
32+
33+
= {
2634
// first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256)
2735
5,8,0,255,12,75,
2836
0x00, 0x00, 0x00, 0x00, 0x00,

0 commit comments

Comments
 (0)