A TextLCD interface for driving 4-bit 16x2 KS0066U LCD

Dependents:   KS0066U4_16x2 LAB05_Oppgave4 LAB05_Oppgave2 LAB05_Oppgave3 ... more

Import program

00001  #include "mbed.h"
00002  #include "TextLCD.h"
00003  
00004  TextLCD lcd(D11,D10,D9,D5,D4,D3,D2);
00005  int main()
00006  {    
00007     lcd.gotoxy(1,1);
00008     lcd.printf("Hello");
00009  
00010     lcd.gotoxy(4,2);
00011     lcd.printf("World");
00012     
00013     while(1) {
00014         wait_ms(300);
00015     }
00016  }

Import library

Public Member Functions

TextLCD (PinName rs, PinName rw, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, const char *name=NULL)
Create a TextLCD interface and initiated 16x2 char mode.
void lcdComand (unsigned char cmd)
Writes a Command to the LCD-module.
void lcdData (unsigned char data)
Writes charecters to the LCD display.
void gotoxy (int, int)
moves text cursor to a screen column and row
int putc (int c)
Write a character to the LCD.
int printf (const char *format,...)
Write a formatted string to the LCD.

Protected Member Functions

void writeLcdBitD4toD7 (char data)
Writes the low nible of data to the LCD-module.
void pulseEn ()
Causes the LCD-module to read the data on the data input pins EN = 1 for L-to-H / EN = 0 for H-to-L.
void init_4BitMode2LinesDisplayOn ()
Enable 4 bit mode From KS0066U Documentation.

/media/uploads/rlanghbv/lcdmoduletop.jpg /media/uploads/rlanghbv/lcdmodulebottom.jpg

Revision:
3:d2f70de20dbe
Parent:
2:f0a520c95838
Child:
4:264d9b06bf60
--- a/TextLCD.cpp	Sun Sep 20 10:42:51 2015 +0000
+++ b/TextLCD.cpp	Sun Sep 20 11:06:45 2015 +0000
@@ -6,7 +6,6 @@
  */
 
 #include "mbed.h"
-#include "LCD_IO_MAP.h"
 #include "TextLCD.h"
 
 #define SET_EN() (LCD_EN=1)
@@ -19,7 +18,27 @@
 
 
 //Enables the LCD Module for use 2-Lines...
-TextLCD::TextLCD()
+/*TextLCD::TextLCD()
+{
+    CLEAR_EN(); //EN =0
+    wait_ms(500);
+
+    init_4BitMode2LinesDisplayOn();  //enabler 4 bit mode
+    wait_us(100);
+
+    lcdComand(0x28);//(0b0010 1000);	// 4- bit mode   LCD 2 line 5x7 Matrix
+    wait_us(100);
+    lcdComand(0xE);//(0b0000 1110);  //Hva gjør vi her ?
+    wait_us(100);
+    lcdComand(0x01); //(0b00000001); //Hva gjør vi her ?
+    wait_us(100);
+    lcdComand(0x06);//(0b00000110);  //Hva gjør vi her ?
+    wait_us(100);
+}*/
+
+TextLCD::TextLCD(PinName rs,PinName rw, PinName e, PinName d4, PinName d5,
+                 PinName d6, PinName d7) : LCD_RS(rs),LCD_RW(rw),
+        LCD_EN(e), LCD_D4(d4), LCD_D5(d5), LCD_D6(d6), LCD_D7(d7)
 {
     CLEAR_EN(); //EN =0
     wait_ms(500);
@@ -38,6 +57,10 @@
 }
 
 
+
+
+
+
 // Causes the LCD-module to read the data on the data input pins
 void TextLCD::pulseEn()
 {