![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Simple Menu Program for the Application Board LCD
Revision 0:386952ad9742, committed 2014-01-12
- Comitter:
- bobarry
- Date:
- Sun Jan 12 03:05:34 2014 +0000
- Commit message:
- Going to publish it on mbed
Changed in this revision
diff -r 000000000000 -r 386952ad9742 C12832_lcd.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832_lcd.lib Sun Jan 12 03:05:34 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/dreschpe/code/C12832_lcd/#468cdccff7af
diff -r 000000000000 -r 386952ad9742 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Jan 12 03:05:34 2014 +0000 @@ -0,0 +1,101 @@ +// A simple menu program, displaying on the mbed Application Board +// Ideas on how to eliminate the 6 warnings would be appreciated! +// Bo Barry 1/11/2014 (My first 'published' program) + + +#include "mbed.h" +DigitalOut myled(LED1); +#include "C12832_lcd.h" +C12832_LCD lcd; +#include <stdio.h> + +void load_menu(void); +void sum(void); +void rest(void); + +int main(void) +{ + + lcd.locate(0,2); + lcd.cls(); + lcd.printf("mbed Application Board!"); + wait(2); + load_menu(); + return 0; +} + +void load_menu(void) +{ + int choice; + do + { + lcd.locate(0,2); + lcd.cls(); + lcd.printf("Menu\n"); + lcd.printf("1. Sum 2. Rest 3. Exit\n"); + scanf("%d",&choice); + + switch(choice) + { + case 1: sum(); + break; + case 2: rest(); + break; + case 3: + lcd.locate(0,2); + lcd.cls(); + lcd.printf("Quitting program!"); + exit(0); + break; + default: lcd.printf("Invalid choice!"); + break; + } + + } while (choice != 3); + +} + +void sum(void) +{ + int num1, num2; + // int ch; + + printf("Enter number 1: "); + scanf("%d",&num1); + lcd.locate(0,2); + lcd.cls(); + printf("Enter number 2: "); + scanf("%d",&num2); + lcd.locate(0,2); + lcd.cls(); + printf("The sum of the numbers was: %d",num1+num2); + wait(2); + + // Flushes input buffer from the newline from scanf() + // while ( (ch = getchar()) != '\n' && ch != EOF) ; + lcd.locate(0,2); + lcd.cls(); + printf("Press ENTER to continue."); + // while ( (ch = getchar()) != '\n' && ch != EOF); + return; +} + +void rest(void) +{ + lcd.locate(0,2); + lcd.cls(); + // int ch; + printf("Sleepy sleepy... zZZzZzZz\n"); + wait(2); + printf("You now feel awake again!"); + wait(2); + // Flushes input buffer + // while ((ch = getchar()) != '\n' && ch != EOF) ; + + lcd.locate(0,2); + lcd.cls(); + printf("Press ENTER to continue."); + // while ((ch = getchar()) != '\n' && ch != EOF); + + return; +} \ No newline at end of file
diff -r 000000000000 -r 386952ad9742 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Jan 12 03:05:34 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file