Display text on screen.

Dependencies:   TextLCD mbed MaxSonar RTC-DS1307

Fork of TextLCD_HelloWorld by Simon Ford

Revision:
4:c669026b6f6e
Parent:
3:5e0ba6e35849
Child:
5:2f13ec8efe0b
--- a/main.cpp	Tue May 23 13:43:33 2017 +0000
+++ b/main.cpp	Wed May 24 12:02:38 2017 +0000
@@ -1,17 +1,46 @@
 // Hello World! for the TextLCD
 
 #include "mbed.h"
+#include <string>
 #include "TextLCD.h"
 
 TextLCD lcd(PTE30, PTE29, PTE23, PTE22, PTE21, PTE20); // rs, e, d4-d7
 
+DigitalOut screen1(PTE5);
+DigitalOut screen2(PTE4);
+
+void UpdateScreen(DigitalOut screen, string text);
+
 int i = 0;
 
 int main() {
-    while(1){
+    screen1 = 1;
+    screen2 = 1;
+    wait(1);
+    
+    UpdateScreen(screen2, "Screen2");
+    
+    UpdateScreen(screen1, "Screen1");
+    
+}
+
+void UpdateScreen(DigitalOut screen, string text)
+{
+    //disable all E pin for all screens
+    screen1 = 0;
+    screen2 = 0;
+        
+    //enable E pin for the scrren that we want to update
+    screen = 1;
+    
+    //some weird behaviour after disabling the E pin once means that we need to update the screen several times for it to display properly
+    for(i = 0; i < 10; i++)
+    {
         lcd.cls();
-        lcd.printf("The Time now is: %d", i);
-        i++;
-        wait(1);
+        char text_char_array[1024];
+        strcpy(text_char_array, text.c_str());
+        lcd.printf(text_char_array);
     }
+        
+    
 }