エレキジャック Web版 mbedで初めてのマイコン開発 LCDを極める!でLCDに表示された文字列がスライドするプログラムです。http://www.eleki-jack.com/arm/mbed/cat691/lcd-1/ <5/5>にスライド文字列用のプログラム解説があります。

Dependencies:   mbed

main.cpp

Committer:
sunifu
Date:
2010-09-22
Revision:
0:d4893e58d648

File content as of revision 0:d4893e58d648:

#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() {
    char msg[] = "1234567890123456" ;
    char msg1[] = "Welcome to mbed! mbed is a tool for Rapid Prototyping with Microcontrollers." ;
    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){        
        for (j = SIZE -1  ; j>=0 ; j-- ){
            for ( k = j ; k < SIZE ; k++ ){
                lcd.locate(k,row);
                if ( len  > (k - j) )
                    lcd.printf("%c",msg[k-j]) ;
                else
                    lcd.printf(" ") ;
            }          
            wait(time) ;
        }
 
        for ( j = 1 ; j <= len  ; j++ ){
            for ( k = 0; k < SIZE ; k++ ){
                lcd.locate(k,row) ;
                if( ( k + j ) < len )
                    lcd.printf("%c",msg[k+j]) ;
                else
                    lcd.printf(" ") ;
            }
            wait(time) ;
        }    
    }   
}