TextLCD library for controlling various LCD panels based on the HD44780 4-bit interface

Dependencies:   mbed

Fork of TextLCD by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
zhangyx
Date:
Fri Jul 07 15:27:16 2017 +0000
Parent:
8:308d188a2d3a
Child:
10:b5b2b8035bbf
Commit message:
LCD2004 demo

Changed in this revision

TextLCD.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/TextLCD.cpp	Thu Jan 02 21:07:01 2014 +0000
+++ b/TextLCD.cpp	Fri Jul 07 15:27:16 2017 +0000
@@ -25,7 +25,7 @@
 
 TextLCD::TextLCD(PinName rs, PinName e, PinName d4, PinName d5,
                  PinName d6, PinName d7, LCDType type) : _rs(rs),
-        _e(e), _d(d4, d5, d6, d7),
+        _e(e,1), _d(d4, d5, d6, d7),
         _type(type) {
 
     _e  = 1;
@@ -39,12 +39,13 @@
         wait(0.00164);  // this command takes 1.64ms, so wait for it
     }
     writeByte(0x2);     // 4-bit mode
-    wait(0.000040f);    // most instructions take 40us
+    wait(0.00164);    // 1.64ms
 
     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
     cls();
+
 }
 
 void TextLCD::character(int column, int row, int c) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jul 07 15:27:16 2017 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+#include "TextLCD.h"
+int main() {
+    TextLCD lcd(A5, A4, A3, A2, A1, A0, TextLCD::LCD20x4); // rs, e, d4-d7, model
+    
+    lcd.printf("Hello World!");
+    wait_ms(1000); //等待1秒
+    lcd.cls(); //清屏
+    
+    for(int i=0; i<10000; i+=4){
+        lcd.locate(0,0); //分别控制起始的列和行,从0开始
+        lcd.printf("%d", i);
+        wait_ms(1000); //等待1秒
+        
+        lcd.locate(0,1);
+        lcd.printf("%d", i+1);
+        wait_ms(1000);
+        
+        lcd.locate(0,2);
+        lcd.printf("%d", i+2);
+        wait_ms(1000);
+        
+        lcd.locate(0,3);
+        lcd.printf("%d", i+3);
+        wait_ms(1000);
+        
+        lcd.cls(); //清屏
+    }
+
+    while(1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jul 07 15:27:16 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/64910690c574
\ No newline at end of file