Files at this revision

API Documentation at this revision

Comitter:
Wimpie
Date:
Sun Apr 17 17:26:10 2011 +0000
Parent:
2:1c5dea5d8783
Commit message:

Changed in this revision

I2CTextLCD.cpp Show annotated file Show diff for this revision Revisions of this file
I2CTextLCD.h Show annotated file Show diff for this revision Revisions of this file
--- a/I2CTextLCD.cpp	Thu Dec 23 12:42:37 2010 +0000
+++ b/I2CTextLCD.cpp	Sun Apr 17 17:26:10 2011 +0000
@@ -53,10 +53,10 @@
     // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus)
 
     for (int i=0; i<3; i++) {
-        writeNibble(0x3,false);
+        writeNibble(EIGHT_BITMODE,false);
         wait(0.00164);      // this command takes 1.64ms, so wait for it
     }
-    writeNibble(0x2,false); // 4-bit mode
+    writeNibble(FOUR_BITMODE,false); // 4-bit mode
 
     writeCommand(0x28);    // Function set 001 BW N F - -
     writeCommand(0x0C);
@@ -83,9 +83,9 @@
 void I2CTextLCD::backlight(bool status) {
     _backlight=status;
     if (_backlight)
-        writeI2CByte(BACKLIGHT_ON | E_ON);
+        writeI2CByte(BACKLIGHT_ON | E1_ON);
     else
-        writeI2CByte(E_ON);
+        writeI2CByte(E1_ON);
 }
 
 
@@ -133,13 +133,13 @@
         data = data | RS_ON; // set rs bit
     }
 
-    writeI2CByte(data | E_ON); // E=1
+    writeI2CByte(data | E1_ON); // E=1
 
     wait(0.000040f);
     writeI2CByte(data);   // E=0
 
     wait(0.000040f);
-    writeI2CByte(data | E_ON);  // E=1
+    writeI2CByte(data | E1_ON);  // E=1
 }
 
 void I2CTextLCD::writeByte(int data, bool rs) {
@@ -148,12 +148,12 @@
 }
 
 void I2CTextLCD::writeCommand(int command) {
-    //command ^= RS_ON; // RS = 0;
+    // RS = 0;
     writeByte(command,false);
 }
 
 void I2CTextLCD::writeData(int data) {
-    //  data = data | RS_ON; //RS = 1
+    //RS = 1
     writeByte(data,true);
 
     _column++;
--- a/I2CTextLCD.h	Thu Dec 23 12:42:37 2010 +0000
+++ b/I2CTextLCD.h	Sun Apr 17 17:26:10 2011 +0000
@@ -10,10 +10,49 @@
 #include "mbed.h"
 #include "Stream.h"
 
-#define E_ON  0x10          //P4
-#define BACKLIGHT_ON  0x20  //P5
-#define RS_ON 0x80          //P7
+#define RS_ON         0x10   //P4
+#define E1_ON         0x20   //P5
+#define E2_ON         0x40   //P6
+#define BACKLIGHT_ON  0x80   //P7
+
+/* Display ON/OFF Control defines */
+#define DON                0x0F  //0b00001111  Display on 
+#define DOFF               0x0B  //0b00001011  Display off 
+#define CURSOR_ON          0x0F  //0b00001111  Cursor on 
+#define CURSOR_OFF         OxOD  //0b00001101  Cursor off 
+#define BLINK_ON           0x0F  //0b00001111  Cursor Blink 
+#define BLINK_OFF          0x0E  //0b00001110  Cursor No Blink 
+
+/* Cursor or Display Shift defines */
+#define SHIFT_CUR_LEFT     Ox13  //0b00010011  Cursor shifts to the left 
+#define SHIFT_CUR_RIGHT    Ox17  //0b00010111  Cursor shifts to the right 
+#define SHIFT_DISP_LEFT    Ox1B  //0b00011011  Display shifts to the left 
+#define SHIFT_DISP_RIGHT   0x1F  //0b00011111  Display shifts to the right 
 
+/* Function Set defines */
+#define EIGHT_BITMODE      0x03  //0b00000011  8-bit Interface D4-D7
+#define FOUR_BITMODE       0x02  //0b00000010  4-bit Interface D4-D7
+#define LINE_5X7           0x30  //0b00110000
+#define LINE_5X10          0x34  //0b00110100
+#define LINES_5X7          0x38  //0b00111000
+
+// Addtional define to support display mode
+
+#define DISP_FLIP_NONE     0x00  //0b00111100  No flip
+#define CLEAR_LCD          0x01  //0b00000001 
+
+// Addtional define to support entry mode & shift mode
+//#define ENTRY_CURSOR_DEC 0b00000101 /* Entry cursor move left */
+//#define ENTRY_CURSOR_INC 0b00000111 /* Entry cursor move to right */
+//#define ENTRY_DISPLAY_SHIFT 0b00000111 /* Entry the display to shift */
+//#define ENTRY_DISPLAY_NO_SHIFT 0b00000110 /* Entry no shift */
+
+// Use generic address
+
+#define LINE0 0x80
+#define LINE1 0xC0 
+#define LINE2 0x94 
+#define LINE3 0xD4 
 namespace mbed {
 
 /* Class: I2CTextLCD
@@ -50,10 +89,10 @@
      * P1              -  D5
      * P2              -  D6
      * P3              -  D7
-     * P4              -  E
-     * P5              -  backlight (connected to a relay)
-     * P6              -  nc
-     * P7              -  RS
+     * P4              -  RS
+     * P5              -  E1
+     * P6              -  E2
+     * P7              -  backlight (connected to a relay)
      * gnd             -  R/W
      *
      */