by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   MobileLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*Program Example 8.8: Program which reads character from computer screen, and displays on Nokia LCD display. 
00002                                                                            */
00003 #include "mbed.h"
00004 #include "MobileLCD.h"
00005 MobileLCD lcd(p11, p12, p13, p15, p16); //mosi,miso,clk,cs,rst
00006 Serial pc(USBTX, USBRX);                // host terminal comms setup
00007 char c;                                 // char variable for keyboard input
00008 void screen_setup(void);                // function prototype
00009 
00010 int main() {
00011   pc.printf("\n\rType something to be displayed:\n\r");
00012   screen_setup();                     // call the screen setup function
00013   while(1){
00014     c = pc.getc();             // c = character input from computer keyboard
00015     wait(0.001);
00016     if (c=='#'){               // perform the following if "#" is pressed
00017       screen_setup();          // call the screen setup function
00018       lcd.locate(0,0);         // move the cursor back to row 0 column 0
00019     }
00020     else{
00021       lcd.printf("%c",c);      // print character on the LCD screen
00022       pc.printf("%c",c);       // print character on the terminal screen
00023     }
00024   }
00025 }
00026 
00027 //function definition for screen_setup
00028 void screen_setup(void) {               
00029   lcd.background(0x0000FF);           // set the background colour
00030   lcd.cls();                          // clear the screen
00031 }