Display text on screen.

Dependencies:   TextLCD mbed MaxSonar RTC-DS1307

Fork of TextLCD_HelloWorld by Simon Ford

main.cpp

Committer:
aueangpanit
Date:
2017-05-24
Revision:
4:c669026b6f6e
Parent:
3:5e0ba6e35849
Child:
5:2f13ec8efe0b

File content as of revision 4:c669026b6f6e:

// 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() {
    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();
        char text_char_array[1024];
        strcpy(text_char_array, text.c_str());
        lcd.printf(text_char_array);
    }
        
    
}