working multi line scoller message on lcd

Dependencies:   mbed C12832_lcd

Revision:
0:1f7f335b262d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 03 14:24:49 2021 +0000
@@ -0,0 +1,94 @@
+#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); 
+    }
+}
\ No newline at end of file