Tadao Iida / Mbed 2 deprecated LCD_SlideMessage

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003 
00004 void slideMessage(char* ,double ,int );
00005 //slideMessage(message, slidetime, row )
00006  
00007 TextLCD lcd(p24,p26,p27,p28,p29,p30);
00008 #define SIZE 16
00009 // I don't test TextLCD 20x ... 16x2B
00010 
00011 int main() {
00012     static char msg[] = "1234567890123456" ;
00013     static char msg1[] = "Welcome to mbed! mbed is a tool for Rapid Prototyping with Microcontrollers." ;
00014     static char msg2[] = "abcdefghijklmnop" ;
00015     
00016     slideMessage(msg1,0.5,0);
00017     return 0 ;
00018 }
00019 
00020 void slideMessage(char msg[], double time,int row)
00021 {
00022     int j, k ;   
00023     int len = ( strlen(msg) ) ;
00024         
00025     lcd.cls();
00026  
00027     while(1){  // <= Debug ha while wo comment nisuru
00028         printf("[len:%d  :: %s]",len,msg); // <= Debug
00029         printf("----- first loop -----\r\n"); // <= Debug        
00030         for (j = SIZE -1  ; j>=0 ; j-- ){
00031             printf("(%2d)",j); // <= Debug
00032             for ( k = j ; k < SIZE ; k++ ){
00033                 lcd.locate(k,row);
00034                 if ( len  > (k - j) ){
00035                     lcd.printf("%c",msg[k-j]) ;
00036                     printf("[%2d:%c]",k,msg[k-j]); // <= Debug
00037                 }else{
00038                     lcd.printf(" ") ;
00039                     printf("[%2d:*]",k); // <= Debug
00040                 }       
00041             }
00042             wait(time) ;
00043             printf("\r\n"); // <= Debug
00044         }
00045         printf("----- second loop -----\r\n"); // <= Debug
00046         for ( j = 1 ; j <= len  ; j++ ){
00047             printf("(%2d)",j); // <= Debug
00048             for ( k = 0; k < SIZE ; k++ ){
00049                 lcd.locate(k,row) ;
00050                 if( ( k + j ) < len ){
00051                     lcd.printf("%c",msg[k+j]) ;
00052                     printf("[%2d:%c]",k,msg[k+j]); // <= Debug
00053                 }else{
00054                     lcd.printf(" ") ;
00055                     printf("[%2d:*]",k); // <= Debug
00056                 }    
00057             }
00058             wait(time) ;
00059             printf("\r\n"); // <= Debug
00060         }    
00061     }   // <= Debug ha kokomo comment ni suru.
00062 }