diff --git a/lcdLib.c b/lcdLib.c index 6c4dd16..36f9b08 100644 --- a/lcdLib.c +++ b/lcdLib.c @@ -163,7 +163,8 @@ void initLCD (void) { softwareLCDInitPulse(); // Function set (2 lines with 5x7 dot character font) - writeLCDInstr_(0x38); // RS=RW=0, 0b00111000, 0x38 + // RS=RW=0, DBUS=b00111000,0x38 + writeLCDInstr_(INSTR_FUNC_SET | (1 << INSTR_FUNC_SET_DL) | (1 << INSTR_FUNC_SET_N)); /* BF now can be checked */ @@ -171,13 +172,16 @@ void initLCD (void) { writeLCDInstr_(INSTR_DISPLAY); // Display off _delay_us(LCD_GENERIC_INSTR_DELAY); - writeLCDInstr_(CMD_CLEAR_DISPLAY); // Clear display + // Clear display + writeLCDInstr_(CMD_CLEAR_DISPLAY); _delay_us(LCD_CLEAR_DISPLAY_DELAY); - writeLCDInstr_(0x06); // Increment mode, no shift + // Increment mode, no shift + writeLCDInstr_(INSTR_ENTRY_SET | (1 << INSTR_ENTRY_SET_ID)); _delay_us(LCD_GENERIC_INSTR_DELAY); - writeLCDInstr_(0x0E); // Display on, cursor on, blink off + // Display on, cursor on, blink off + writeLCDInstr_(INSTR_DISPLAY | (1 << INSTR_DISPLAY_D) | (1 << INSTR_DISPLAY_C)); _delay_us(LCD_GENERIC_INSTR_DELAY); flashLED(5); // DEBUG diff --git a/lcdLib.h b/lcdLib.h index 9dc983e..4184fcb 100644 --- a/lcdLib.h +++ b/lcdLib.h @@ -50,8 +50,8 @@ //#define FOUR_BIT_MODE // LCD delays (in microseconds when unspecified) -#define LCD_DELAY 1 -#define LCD_INIT_DELAY0 30 // milliseconds +#define LCD_DELAY 25 +#define LCD_INIT_DELAY0 15 // milliseconds #define LCD_INIT_DELAY1 8200 #define LCD_INIT_DELAY2 200 @@ -68,14 +68,14 @@ // Entry Set instruction and associated options #define INSTR_ENTRY_SET 0x04 -#define INSTR_ENTRY_SET_ID 0x02 -#define INSTR_ENTRY_SET_S 0x01 +#define INSTR_ENTRY_SET_ID 1 +#define INSTR_ENTRY_SET_S 0 // Display control instruction and associated options #define INSTR_DISPLAY 0x08 -#define INSTR_DISPLAY_D 0x04 -#define INSTR_DISPLAY_C 0x02 -#define INSTR_DISPLAY_B 0x01 +#define INSTR_DISPLAY_D 2 +#define INSTR_DISPLAY_C 1 +#define INSTR_DISPLAY_B 0 // Cursor or display shift instruction and associated options #define INSTR_MOV_SHIFT 0x10