mbed/ARM 活用事例 第2章 キャラクタLCDを極めよう

Dependencies:   TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
sunifu
Date:
Tue Oct 04 12:30:13 2011 +0000
Commit message:

Changed in this revision

TextLCD.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Tue Oct 04 12:30:13 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 04 12:30:13 2011 +0000
@@ -0,0 +1,64 @@
+#include "mbed.h"
+#include "TextLCD.h"
+
+TextLCD lcd(p24, p26, p27, p28, p29, p30);
+// ’[Žq”ԍ†P20‚©‚çƒZƒ“ƒT[‚Ì’l‚ðtemp_in‚ÉŽæ‚荞‚Þ‚½‚߂̐錾‚Å‚·B
+AnalogIn temp_in(p20);
+AnalogIn humid_in(p19);
+
+// ƒZƒ“ƒT‚ð10[•b]ŽüŠú‚ŌĂяo‚·‚½‚߂̃IƒuƒWƒFƒNƒg
+Ticker  in;
+
+
+void Update(){
+    float r_temp, r_humid;
+    float temp,humid;
+    // ƒZƒ“ƒT[‚©‚ç’l‚ð“Ç‚ÝŽæ‚è‚Ü‚·B
+    temp = temp_in;
+    humid = humid_in;
+    
+    // ƒZƒ“ƒT[‚Ì’l‚ð•â³‚µ‚Ü‚·B
+    // 0-3.3[V]‚ª0.0-1.0‚ɑΉž‚µ‚Ä‚¢‚邽‚߁A“ü—Í’l‚É3.3‚ðæŽZ‚µ“dˆ³‚É‚µ‚āA
+    // ‚³‚ç‚É100 ‚ðæŽZ‚µ‰·“x‚É•ÏŠ·‚µ‚Ä‚¢‚Ü‚·B
+    // r_temp = temp * 3.3 * 100 ;   // ---- (1)
+    r_humid = humid * 3.3 * 100 ;   
+
+    // ƒZƒ“ƒT[‚Ì’l‚ð•â³‚µ‚Ü‚·B
+    // 3[V]‚Å50Ž‚É‚È‚é‚悤‚É6”{‚Ì‘•Ší‚Å“ü—Í“dˆ³‚𑝕‚µ‚Ä‚¢‚é‚̂ŁA
+    // 1Ž‰·“x‚ªã¸‚·‚é‚Əo—Í‚ª+0.06[V]‘‰Á‚µ‚Ü‚·B
+    // AnalogIn‚̏ãŒÀ’l3.3[V]‚ª“ü—Í‚³‚ê‚é‚ƁA‰·“x‚Í55Ž‚É‚È‚è‚Ü‚·B
+    // 0-3.3[V]‚ª0.0-1.0‚ɑΉž‚µ‚Ä‚¢‚邽‚߁A1.0‚Ì“ü—Í’l‚Å55Ž‚É‚È‚è‚Ü‚·B
+    // ‚µ‚½‚ª‚Á‚āA“ü—Í’l‚É55‚ð‚©‚¯‚é‚Ɖ·“x‚É‚È‚è‚Ü‚·B
+    r_temp =  temp * 55.0  ;   // ---- (2)
+
+    lcd.cls();
+    lcd.locate(0,0);
+
+    // printfŠÖ”‚Í‚¢‚ë‚¢‚ë‚Æ•Ö—˜‚ÉŽg‚¦‚é‚Ì‚Å‚·‚ªAà–¾‚·‚é‚Æ’·‚­‚È‚Á‚Ä‚µ‚Ü‚¢‚Ü‚·B
+    // Ú‚µ‚¢Žg‚¢•û‚́ACŒ¾Œê‚Ì•¶–@‚ðà–¾‚µ‚Ä‚¢‚éƒz[ƒ€ƒy[ƒW‚⏑Ð‚È‚Ç‚Å’²‚ׂĂ݂Ă­‚¾‚³‚¢B
+    // printfŠÖ”‚Ì""‚Ì’†‚Ì•¶Žš—ñ‚ªLCD‚É•\Ž¦‚³‚ê‚Ü‚·B‚±‚Ì’†‚Å%5.2f‚Ì•”•ª‚́A""‚ÌŒã‚̕ϐ”‚Ì
+    // ’l‚ª•\Ž¦‚³‚ê‚Ü‚·B
+    // %5.2f‚Ìf‚ÍŽÀ”ƒf[ƒ^‚Ì•\Ž¦‚ŁA%5.2‚͐”Žš‚̐”‚ª‘S•”‚Å5Œ…‚»‚Ì‚¤‚¿¬”“_ˆÈ‰º2Œ…‚Å•\Ž¦‚µ‚Ü‚·B
+    lcd.printf("RoomTemp %5.2f",r_temp);
+
+    // ’PˆÊ‚́Ž‚ð•\Ž¦‚µ‚Ä‚¢‚Ü‚·B
+    lcd.locate(14,0);
+    lcd.putc(0xDf); 
+    lcd.putc(0x43);
+
+    // •\Ž¦ˆÊ’u‚ð‰º‚Ì’i‚̍¶’[‚©‚ç‚ÉŽw’肵‚Ü‚·B
+    lcd.locate(0,1);
+    // ¶‘¤‚É“ü—Í’lA‰E‘¤‚É“ü—Í“dˆ³‚ð•\Ž¦‚µ‚Ä‚¢‚Ü‚·B
+    // printf
+    lcd.printf("humidity%5.1f%%",r_humid);    
+}
+
+int main() {
+    // 10•b–ˆ‚ɃZƒ“ƒT[‚©‚ç‚Ì’l‚ðXV‚µ‚Ü‚·B
+    in.attach(&Update,10);
+        
+    // –³ŒÀƒ‹[ƒv‚µ‚Ü‚·B
+    while(1){        
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 04 12:30:13 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912