Support both 5x8 and 5x10 fonts

Added LCD_FONT in lcdLib.h which is the bitmask to enable 5x8 or 5x10
font when doing the function set instruction (in the definition of
initLCD).

LCD_FONT_5x8 or LCD_FONT_5x10 should be defined to enable the intended
font. One always needs to be defined.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
This commit is contained in:
Collin J. Doering 2015-10-26 22:30:44 -04:00
parent 7678470c3e
commit c52292c802
3 changed files with 18 additions and 2 deletions

View File

@ -320,11 +320,11 @@ void initLCD(void) {
#if defined (FOUR_BIT_MODE)
// Function Set (4-bit interface; 2 lines with 5x7 dot character font)
writeLCDDBusNibble_(CMD_INIT_FOUR_BIT);
writeLCDInstr_(CMD_INIT_FOUR_BIT | (1 << INSTR_FUNC_SET_N));
writeLCDInstr_(CMD_INIT_FOUR_BIT | (1 << INSTR_FUNC_SET_N) | LCD_FONT);
#else
// Function set (8-bit interface; 2 lines with 5x7 dot character font)
// RS=RW=0, DBUS=b00111000,0x38
writeLCDInstr_(INSTR_FUNC_SET | (1 << INSTR_FUNC_SET_DL) | (1 << INSTR_FUNC_SET_N));
writeLCDInstr_(INSTR_FUNC_SET | (1 << INSTR_FUNC_SET_DL) | (1 << INSTR_FUNC_SET_N) | LCD_FONT);
#endif
/* BF now can be checked */

View File

@ -214,6 +214,18 @@ void initLCDByInternalReset(void);
#define LCD_CHARACTERS_PER_SCREEN (LCD_CHARACTERS_PER_LINE * LCD_NUMBER_OF_LINES)
#endif
#if !defined(LCD_FONT_5x8) &&\
!defined(LCD_FONT_5x10)
#error "All modes require LCD_FONT_5x8 or LCD_FONT_5x10 to be defined."
#elif defined(LCD_FONT_5x8) && \
defined(LCD_FONT_5x10)
#error "LCD_FONT_5x8 and LCD_FONT_5x10 are mutually exclusive. Choose one."
#elif defined(LCD_FONT_5x8)
#define LCD_FONT 0
#elif defined(LCD_FONT_5x10)
#define LCD_FONT (1 << INSTR_FUNC_SET_F)
#endif
#if !defined (LCD_RS) || \
!defined (LCD_RS_PORT) || \
!defined (LCD_RS_DDR) || \

View File

@ -52,6 +52,10 @@
0x14, \
0x54 ///< Memory locations for each physical line ordered 1 to LCD_NUMBER_OF_LINES
/* Which font to use (can only leave one uncommented) */
#define LCD_FONT_5x8
//#define LCD_FONT_5x10
/* Support ANSI escapes; comment to disable */
#define LCD_ANSI_ESCAPE_ENABLE