Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 9:5af2538e7684, committed 2016-12-18
- Comitter:
- suupen
- Date:
- Sun Dec 18 11:39:04 2016 +0000
- Parent:
- 8:308d188a2d3a
- Commit message:
- SC2004CSLB???????1charactor?????(cls())??initialize???????
Changed in this revision
| TextLCD.cpp | Show annotated file Show diff for this revision Revisions of this file |
| TextLCD.h | 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 Sun Dec 18 11:39:04 2016 +0000
@@ -31,19 +31,26 @@
_e = 1;
_rs = 0; // command mode
- wait(0.015); // Wait 15ms to ensure powered up
+ wait(0.040); // Wait 40ms to ensure powered up
// send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus)
- for (int i=0; i<3; i++) {
+ for (int i=0; i<4; i++) {
writeByte(0x3);
- wait(0.00164); // this command takes 1.64ms, so wait for it
+ wait(0.00410f); // this command takes 4.10ms, so wait for it
}
writeByte(0x2); // 4-bit mode
wait(0.000040f); // most instructions take 40us
writeCommand(0x28); // Function set 001 BW N F - -
- writeCommand(0x0C);
+
+ writeCommand(0x08); // Display OFF
+ writeCommand(0x01); // Display ON
+
+ writeCommand(0x0C); // Display ON/OFF Display On, Cursor OFF, Blink OFF
writeCommand(0x6); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes
+
+// writeCommand(0x14); // Cursor or Display Shift Cursor movement, Shift to the right
+
cls();
}
@@ -59,7 +66,17 @@
locate(0, 0);
}
+void TextLCD::displayONOFF(int d, int c, int b){
+ int a = (0x08 | (d & 0x01) << 2 | (c & 0x01) << 1 | (b & 0x01));
+ writeCommand(a); // Instruction Display On/OFF
+ wait(0.000040f); // This command takes 40us (necessary >37us)
+
+}
+
void TextLCD::locate(int column, int row) {
+ writeCommand(0x02); // set cursor to 0 // 1charactor ずれずれるので応急対応
+ wait(0.00164f); // This command takes 1.64 ms
+
_column = column;
_row = row;
}
@@ -105,6 +122,8 @@
void TextLCD::writeCommand(int command) {
_rs = 0;
writeByte(command);
+ wait(0.000040f); // most instructions take 40us
+
}
void TextLCD::writeData(int data) {
@@ -116,6 +135,7 @@
switch (_type) {
case LCD20x4:
switch (row) {
+
case 0:
return 0x80 + column;
case 1:
@@ -124,6 +144,7 @@
return 0x94 + column;
case 3:
return 0xd4 + column;
+
}
case LCD16x2B:
return 0x80 + (row * 40) + column;
--- a/TextLCD.h Thu Jan 02 21:07:01 2014 +0000
+++ b/TextLCD.h Sun Dec 18 11:39:04 2016 +0000
@@ -85,6 +85,14 @@
/** Clear the screen and locate to 0,0 */
void cls();
+ /** display On/Off
+ * @param d : 0:Display OFF 1:ON
+ * @param c : 0:Cursor OFF 1:ON
+ * @param b : 0 Blaink OFF 1:ON
+ */
+ void displayONOFF(int d, int c, int b);
+
+
int rows();
int columns();