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

Dependencies:   TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
sunifu
Date:
Tue Oct 04 12:50:27 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
diff -r 000000000000 -r 8f82c02ccf5d TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Tue Oct 04 12:50:27 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
diff -r 000000000000 -r 8f82c02ccf5d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 04 12:50:27 2011 +0000
@@ -0,0 +1,62 @@
+#include "mbed.h"
+#include "TextLCD.h"
+
+void slideMessage(char* ,double ,int );
+//slideMessage(message, slidetime, row )
+ 
+TextLCD lcd(p24,p26,p27,p28,p29,p30);
+#define SIZE 16
+// I don't test TextLCD 20x ... 16x2B
+
+int main() {
+    static char msg[] = "1234567890123456" ;
+    static char msg1[] = "Welcome to mbed! mbed is a tool for Rapid Prototyping with Microcontrollers." ;
+    static char msg2[] = "abcdefghijklmnop" ;
+    
+    slideMessage(msg1,0.5,0);
+    return 0 ;
+}
+
+void slideMessage(char msg[], double time,int row)
+{
+    int j, k ;   
+    int len = ( strlen(msg) ) ;
+        
+    lcd.cls();
+ 
+    while(1){  // <= Debug ha while wo comment nisuru
+        printf("[len:%d  :: %s]",len,msg); // <= Debug
+        printf("----- first loop -----\r\n"); // <= Debug        
+        for (j = SIZE -1  ; j>=0 ; j-- ){
+            printf("(%2d)",j); // <= Debug
+            for ( k = j ; k < SIZE ; k++ ){
+                lcd.locate(k,row);
+                if ( len  > (k - j) ){
+                    lcd.printf("%c",msg[k-j]) ;
+                    printf("[%2d:%c]",k,msg[k-j]); // <= Debug
+                }else{
+                    lcd.printf(" ") ;
+                    printf("[%2d:*]",k); // <= Debug
+                }       
+            }
+            wait(time) ;
+            printf("\r\n"); // <= Debug
+        }
+        printf("----- second loop -----\r\n"); // <= Debug
+        for ( j = 1 ; j <= len  ; j++ ){
+            printf("(%2d)",j); // <= Debug
+            for ( k = 0; k < SIZE ; k++ ){
+                lcd.locate(k,row) ;
+                if( ( k + j ) < len ){
+                    lcd.printf("%c",msg[k+j]) ;
+                    printf("[%2d:%c]",k,msg[k+j]); // <= Debug
+                }else{
+                    lcd.printf(" ") ;
+                    printf("[%2d:*]",k); // <= Debug
+                }    
+            }
+            wait(time) ;
+            printf("\r\n"); // <= Debug
+        }    
+    }   // <= Debug ha kokomo comment ni suru.
+}
\ No newline at end of file
diff -r 000000000000 -r 8f82c02ccf5d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 04 12:50:27 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912