1602 キャラクタディスプレイ データ4bit接続用のテスト STM32F103RB CUCLEOボードでテスト

Dependencies:   CharLcd4bit mbed

Files at this revision

API Documentation at this revision

Comitter:
tshl
Date:
Fri Oct 06 05:04:58 2017 +0000
Commit message:
CharLcd4bit?????????

Changed in this revision

CharLcd4bit.lib 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
diff -r 000000000000 -r 53b69a4c796a CharLcd4bit.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CharLcd4bit.lib	Fri Oct 06 05:04:58 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/tshl/code/CharLcd4bit/#0e84781e64cf
diff -r 000000000000 -r 53b69a4c796a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 06 05:04:58 2017 +0000
@@ -0,0 +1,73 @@
+#include "mbed.h"
+#include "CharLcd4bit.h"
+
+// LEDのポート宣言
+DigitalOut Led(LED1);
+
+// LCDのライブラリ、LCDポート宣言
+CharLcd4bit lcd(A0, A1, A2, D4, D5, D6, D7);
+
+char message1[][16] = {
+    "Hello!",
+    "How are you?",
+    "I am fine.",
+    "And you?",
+    "I am fine too.",
+    ""
+};
+
+char message2[][16] = {
+    ">             ",
+    "->            ",
+    "-->           ",
+    "--->          ",
+    "---->         ",
+    "----->        ",
+    "------>       ",
+    "------->      ",
+    "-------->     ",
+    "--------->    ",
+    "---------->   ",
+    "----------->  ",
+    "------------> ",
+    "------------->"
+};
+
+int main() {
+    int message1Count = sizeof(message1) / 16;
+    int message2Count = sizeof(message2) / 16;
+    int message1Index = 0;
+    int message2Index = 0;
+    
+    // LCD初期化
+    lcd.Initialize();
+
+    lcd.WriteLine(1, "Waiting");
+    lcd.WriteLine(2, "  for Initialize...");
+    wait(3);
+    
+    // 表示クリア
+    lcd.Clear();
+    wait(3);    
+    
+    while(1) {        
+        Led = 0;
+        lcd.SetPosition(2, 15);
+        lcd.WriteChar(' ');
+        wait_ms(500);
+
+        lcd.WriteLine(1, message1[message1Index]);
+        message1Index++;
+        if(message1Index >= message1Count) message1Index = 0;
+
+        Led = 1;
+        lcd.SetPosition(2, 15);
+        lcd.WriteChar(0xA5);
+        wait_ms(500);
+        
+        lcd.SetPosition(2, 0);
+        lcd.WriteStr(message2[message2Index]);
+        message2Index++;
+        if(message2Index >= message2Count) message2Index = 0;
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 53b69a4c796a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 06 05:04:58 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/a330f0fddbec
\ No newline at end of file