working multi line scoller message on lcd

Dependencies:   mbed C12832_lcd

main.cpp

Committer:
andrewbw01
Date:
2021-03-03
Revision:
0:1f7f335b262d

File content as of revision 0:1f7f335b262d:

#include "mbed.h"
#include "C12832_lcd.h"

C12832_LCD lcd;             // create lcd object

char welcome_str1[] ="**********";
char welcome_str2[] =" Welcome  ";
char welcome_str3[] ="**********";

int vert_line_hight = 9;

void scroll_msg_right(void);                // fuction prototypes
void scroll_msg_left(void); 


int main()
{
    scroll_msg_right();
    wait(0.1);
    scroll_msg_left();
    
    while(1)
    {}
}



// scroll message right
void scroll_msg_right(void)
{
    for(int i=10; i>0; i--)             // scroll one character on at a time
    {
        lcd.cls();
        lcd.locate(0,0);
        lcd.printf("%s", (welcome_str1+i));
        
        lcd.locate(0, vert_line_hight);
        lcd.printf("%s", (welcome_str2+i));
        
        lcd.locate(0, vert_line_hight*2);
        lcd.printf("%s", (welcome_str3+i));
        
        wait(0.2); 
    }
    
    for(int i=0; i<45; i++)                     // scroll message
    {
        lcd.cls();
        lcd.locate(i,0);
        lcd.printf("%s", welcome_str1);
        
        lcd.locate(i, vert_line_hight);
        lcd.printf("%s",  welcome_str2);
        
        lcd.locate(i, vert_line_hight*2);
        lcd.printf("%s", welcome_str3);
        
        wait(0.075);
    }
}
         
        
void scroll_msg_left(void)
{
    for(int i=45; i>0; i--)
    {
        lcd.cls();
        lcd.locate(i,0);
        lcd.printf("%s", welcome_str1);
        
        lcd.locate(i, vert_line_hight);
        lcd.printf("%s", welcome_str2);
        
        lcd.locate(i, vert_line_hight*2);
        lcd.printf("%s", welcome_str3);
        
        wait(0.075);
    }
    
    for(int i=0; i<11; i++)             // scroll one character on at a time
    {
        lcd.cls();
        lcd.locate(0,0);
        lcd.printf("%s", (welcome_str1+i));
        
        lcd.locate(0, vert_line_hight);
        lcd.printf("%s", (welcome_str2+i));
        
        lcd.locate(0, vert_line_hight*2);
        lcd.printf("%s", (welcome_str3+i));
        
        wait(0.2); 
    }
}