Set of routines to access 16*32character LCD display on WattBob I board.
Dependents: Assignment_2_herpe Final_V1 ass2 ass2 ... more
Diff: WattBob_TextLCD.cpp
- Revision:
- 9:3b26cd028e85
- Parent:
- 8:5a1c4254e4a6
--- a/WattBob_TextLCD.cpp Thu Dec 08 16:22:17 2011 +0000 +++ b/WattBob_TextLCD.cpp Sun Dec 11 00:14:10 2011 +0000 @@ -53,14 +53,15 @@ _rows = 2; _columns = 16; + // + // Time to allow unit to initialise + // + wait(DISPLAY_INIT_DELAY_SECS); + _rw(0); _e(0); _rs(0); // command mode - // - // Time to allow unit to initialise - // - wait(DISPLAY_INIT_DELAY_SECS); // // interface defaults to an 8-bit interface. However, we need to ensure that we // are in 8-bit mode @@ -70,12 +71,19 @@ wait(0.00164); // this command takes 1.64ms, so wait for it } - writeNibble(CMD4_SET_4_BIT_INTERFACE); // now force into 4-bit mode + writeNibble(CMD4_SET_4_BIT_INTERFACE); // now force into 4-bit mode + +// writeCommand(CMD_NULL); +// writeCommand(CMD_NULL); +// writeCommand(CMD_NULL); +// writeCommand(CMD_NULL); +// writeCommand(CMD_NULL); + writeCommand(CMD_FUNCTION_SET | INTERFACE_4_BIT | TWO_LINE_DISPLAY | FONT_5x8 | ENGL_JAPAN_FONT_SET); // 0x28 writeCommand(CMD_DISPLAY_CONTROL | DISPLAY_ON | CURSOR_OFF | CURSOR_CHAR_BLINK_OFF); // 0xC0 + cls(); + writeCommand(CMD_RETURN_HOME); writeCommand(CMD_ENTRY_MODE | CURSOR_STEP_RIGHT | DISPLAY_SHIFT_OFF ); // 0x06 - - cls(); } int WattBob_TextLCD::_putc(int value) { @@ -114,7 +122,7 @@ void WattBob_TextLCD::cls() { writeCommand(CMD_CLEAR_DISPLAY); // 0x01 - wait(0.00164f); // This command takes 1.64 ms + wait(DISPLAY_CLEAR_DELAY); // locate(0, 0); }