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:
- 8:5a1c4254e4a6
- Parent:
- 7:020722c18a8b
- Child:
- 9:3b26cd028e85
--- a/WattBob_TextLCD.cpp Thu Mar 24 13:46:06 2011 +0000 +++ b/WattBob_TextLCD.cpp Thu Dec 08 16:22:17 2011 +0000 @@ -57,20 +57,23 @@ _e(0); _rs(0); // command mode - // Should theoretically wait 15ms, but most things will be powered up pre-reset - // so i'll disable that for the minute. If implemented, could wait 15ms post reset - // instead - // wait(0.015); - - // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus) + // + // 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 + // for(int i=0; i<3; i++) { - writeNibble(0x3); + writeNibble(CMD4_SET_8_BIT_INTERFACE); wait(0.00164); // this command takes 1.64ms, so wait for it } - writeNibble(0x2); // 4-bit mode - writeCommand(0x28); // Function set 001 BW N F - - - writeCommand(0x0C); - writeCommand(0x6); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes + + writeNibble(CMD4_SET_4_BIT_INTERFACE); // now force into 4-bit mode + 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 + writeCommand(CMD_ENTRY_MODE | CURSOR_STEP_RIGHT | DISPLAY_SHIFT_OFF ); // 0x06 cls(); } @@ -110,9 +113,9 @@ } void WattBob_TextLCD::cls() { - writeCommand(0x01); // Clear Display - wait(0.00164f); // This command takes 1.64 ms - locate(0, 0); + writeCommand(CMD_CLEAR_DISPLAY); // 0x01 + wait(0.00164f); // This command takes 1.64 ms + locate(0, 0); } void WattBob_TextLCD::reset() {