Tested operational 4-bit mode
Cleaned up a few comments and tested and verified operation of 4-bit mode. Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
This commit is contained in:
parent
0a36d6cf77
commit
04be2b85da
24
lcdLib.c
24
lcdLib.c
|
@ -269,24 +269,22 @@ static inline void softwareLCDInitPulse(void) {
|
|||
void initLCD (void) {
|
||||
enableLCDOutput();
|
||||
|
||||
// Wait minimum 15ms as per datasheet
|
||||
_delay_us(LCD_INIT_DELAY0);
|
||||
|
||||
_delay_us(LCD_INIT_DELAY0); // Wait minimum 15ms as per datasheet
|
||||
softwareLCDInitPulse();
|
||||
|
||||
// Wait minimum 4.1ms as per datasheet
|
||||
_delay_us(LCD_INIT_DELAY1);
|
||||
|
||||
_delay_us(LCD_INIT_DELAY1); // Wait minimum 4.1ms as per datasheet
|
||||
softwareLCDInitPulse();
|
||||
_delay_us(LCD_INIT_DELAY2); // Wait minimum 100us as per datasheet
|
||||
softwareLCDInitPulse();
|
||||
|
||||
// Wait minimum 100us as per datasheet
|
||||
_delay_us(LCD_INIT_DELAY2);
|
||||
|
||||
softwareLCDInitPulse();
|
||||
|
||||
// Function set (2 lines with 5x7 dot character font)
|
||||
#if defined (FOUR_BIT_MODE) || defined (EIGHT_BIT_ARBITRARY_PIN_MODE)
|
||||
// Function Set (4-bit interface; 2 liens with 5x7 dot character font)
|
||||
writeLCDNibble_(CMD_INIT_FOUR_BIT);
|
||||
writeLCDInstr_(CMD_INIT_FOUR_BIT | (1 << INSTR_FUNC_SET_N));
|
||||
#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));
|
||||
#endif
|
||||
|
||||
/* BF now can be checked */
|
||||
|
||||
|
|
22
lcdLib.h
22
lcdLib.h
|
@ -46,7 +46,7 @@
|
|||
//#define EIGHT_BIT_ARBITRARY_PIN_MODE
|
||||
|
||||
// LCD in 4-bit mode (default is 8 bit mode)
|
||||
//#define FOUR_BIT_MODE
|
||||
#define FOUR_BIT_MODE
|
||||
|
||||
// Mode sanity check
|
||||
#if defined (EIGHT_BIT_ARBITRARY_PIN_MODE) && defined (FOUR_BIT_MODE)
|
||||
|
@ -68,9 +68,18 @@
|
|||
#define LCD_ENABLE_PORT PORTD
|
||||
#define LCD_ENABLE_DDR DDRD
|
||||
|
||||
/* Mode specific settings */
|
||||
// Screen characteristics (unused) TODO
|
||||
#define LCD_NUMBER_OF_LINES 2
|
||||
#define LCD_CHARACTERS_PER_LINE 20
|
||||
|
||||
#define LCD_CHARACTER_FONT
|
||||
|
||||
/*
|
||||
Mode specific settings
|
||||
*/
|
||||
|
||||
/* Default Mode */
|
||||
|
||||
// Default Mode
|
||||
// LCD data bus PORT, PIN and DDR.
|
||||
#define LCD_DBUS_PORT PORTB
|
||||
|
||||
|
@ -81,7 +90,8 @@
|
|||
#define LCD_BF PB7
|
||||
|
||||
|
||||
// EIGHT_BIT_ARBITRARY_PIN_MODE specific settings
|
||||
/* EIGHT_BIT_ARBITRARY_PIN_MODE specific settings */
|
||||
|
||||
#ifdef EIGHT_BIT_ARBITRARY_PIN_MODE
|
||||
#define LCD_DBUS0 PB0
|
||||
#define LCD_DBUS0_PORT PORTB
|
||||
|
@ -124,7 +134,8 @@
|
|||
#define LCD_DBUS7_PIN PINB
|
||||
#endif
|
||||
|
||||
// FOUR_BIT_MODE specific settings
|
||||
/* FOUR_BIT_MODE specific settings */
|
||||
|
||||
#ifdef FOUR_BIT_MODE
|
||||
#define LCD_DBUS4 PB4
|
||||
#define LCD_DBUS4_PORT PORTB
|
||||
|
@ -170,6 +181,7 @@
|
|||
|
||||
// Simple commands with no options
|
||||
#define CMD_INIT 0x30
|
||||
#define CMD_INIT_FOUR_BIT 0x20
|
||||
#define CMD_CLEAR_DISPLAY 0x01
|
||||
#define CMD_RETURN_HOME 0x02
|
||||
|
||||
|
|
Loading…
Reference in New Issue