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

Dependencies:   MobileLCD mbed

Committer:
robt
Date:
Fri May 24 21:35:33 2013 +0000
Revision:
0:c36ba3b21cbe
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robt 0:c36ba3b21cbe 1 /*Program Example 8.8: Program which reads character from computer screen, and displays on Nokia LCD display.
robt 0:c36ba3b21cbe 2 */
robt 0:c36ba3b21cbe 3 #include "mbed.h"
robt 0:c36ba3b21cbe 4 #include "MobileLCD.h"
robt 0:c36ba3b21cbe 5 MobileLCD lcd(p11, p12, p13, p15, p16); //mosi,miso,clk,cs,rst
robt 0:c36ba3b21cbe 6 Serial pc(USBTX, USBRX); // host terminal comms setup
robt 0:c36ba3b21cbe 7 char c; // char variable for keyboard input
robt 0:c36ba3b21cbe 8 void screen_setup(void); // function prototype
robt 0:c36ba3b21cbe 9
robt 0:c36ba3b21cbe 10 int main() {
robt 0:c36ba3b21cbe 11 pc.printf("\n\rType something to be displayed:\n\r");
robt 0:c36ba3b21cbe 12 screen_setup(); // call the screen setup function
robt 0:c36ba3b21cbe 13 while(1){
robt 0:c36ba3b21cbe 14 c = pc.getc(); // c = character input from computer keyboard
robt 0:c36ba3b21cbe 15 wait(0.001);
robt 0:c36ba3b21cbe 16 if (c=='#'){ // perform the following if "#" is pressed
robt 0:c36ba3b21cbe 17 screen_setup(); // call the screen setup function
robt 0:c36ba3b21cbe 18 lcd.locate(0,0); // move the cursor back to row 0 column 0
robt 0:c36ba3b21cbe 19 }
robt 0:c36ba3b21cbe 20 else{
robt 0:c36ba3b21cbe 21 lcd.printf("%c",c); // print character on the LCD screen
robt 0:c36ba3b21cbe 22 pc.printf("%c",c); // print character on the terminal screen
robt 0:c36ba3b21cbe 23 }
robt 0:c36ba3b21cbe 24 }
robt 0:c36ba3b21cbe 25 }
robt 0:c36ba3b21cbe 26
robt 0:c36ba3b21cbe 27 //function definition for screen_setup
robt 0:c36ba3b21cbe 28 void screen_setup(void) {
robt 0:c36ba3b21cbe 29 lcd.background(0x0000FF); // set the background colour
robt 0:c36ba3b21cbe 30 lcd.cls(); // clear the screen
robt 0:c36ba3b21cbe 31 }