Set of routines to access 16*32character LCD display on WattBob I board.

Dependents:   Assignment_2_herpe Final_V1 ass2 ass2 ... more

Files at this revision

API Documentation at this revision

Comitter:
jimherd
Date:
Sun Dec 11 00:14:10 2011 +0000
Parent:
8:5a1c4254e4a6
Commit message:

Changed in this revision

WattBob_TextLCD.cpp Show annotated file Show diff for this revision Revisions of this file
WattBob_TextLCD.h Show annotated file Show diff for this revision Revisions of this file
--- 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);
 }
 
--- a/WattBob_TextLCD.h	Thu Dec 08 16:22:17 2011 +0000
+++ b/WattBob_TextLCD.h	Sun Dec 11 00:14:10 2011 +0000
@@ -17,6 +17,8 @@
 //
 // Registers and bit definitions for 2*16 character display chip
 //
+#define     CMD_NULL                0x00
+
 #define     CMD_CLEAR_DISPLAY       0x01
 
 #define     CMD_RETURN_HOME         0x02
@@ -69,7 +71,8 @@
 //
 // Misc 2*16 character display constants
 //
-#define     DISPLAY_INIT_DELAY_SECS    0.025f       // 25mS
+#define     DISPLAY_INIT_DELAY_SECS    0.5f       // 500mS
+#define     DISPLAY_CLEAR_DELAY        0.01f      // 10 mS (spec is 6.2mS)
 
 /** Class to access 16*2 LCD display connected to an MCP23017 I/O extender chip
  *