A TextLCD interface for driving 4-bit 16x2 KS0066U LCD
Dependents: KS0066U4_16x2 LAB05_Oppgave4 LAB05_Oppgave2 LAB05_Oppgave3 ... more
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.
|
Diff: TextLCD.cpp
- Revision:
- 16:ca413e232eaa
- Parent:
- 15:dc4f024fd1aa
- Child:
- 17:5ffb16966db2
diff -r dc4f024fd1aa -r ca413e232eaa TextLCD.cpp --- a/TextLCD.cpp Sun Sep 20 17:15:01 2015 +0000 +++ b/TextLCD.cpp Mon Sep 21 09:25:53 2015 +0000 @@ -56,10 +56,13 @@ //Enable 4 bit mode From KS0066U Documentation void TextLCD::init_4BitMode2LinesDisplayOn() { + //Start by selecting configuration mode CLEAR_RS(); CLEAR_RW(); + wait(.015); // Wait 150ms to ensure powered up + // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus) writeLcdBitD4toD7(0x3); pulseEn(); @@ -72,16 +75,23 @@ wait_ms(2); //Enable 4 bit mode From KS0066U Documentation - writeLcdBitD4toD7(0x2);//(0b0010); // Select 4- bit start - pulseEn(); //LCD exec function + writeLcdBitD4toD7(0x2);// (0b0010) 4- bit start / 4-bit mode wait_us(100); - + writeLcdBitD4toD7(0x2); + pulseEn(); + wait_us(100); writeLcdBitD4toD7(0x2);////(0b0010); // Select 4- bit start (Already on the out port no need to write once more ) pulseEn(); //LCD exec function - wait_us(100); + wait_us(50); writeLcdBitD4toD7(0xC);//(0b1100); // 2 Lines + Disp On pulseEn(); //LCD exec function + + lcdComand(0x01); // Clear Display + wait_ms(3); + lcdComand(0x28); // Function set 001 BW N F - - + lcdComand(0x06); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes + lcdComand(0x0C); // Dispon + Hide cursor wait_us(100); }