![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This program can control the of Application board's joystick and the results can be checked on the LCD (C12832).
main.cpp@0:3cb0e69f1806, 2013-10-08 (annotated)
- Committer:
- ssery
- Date:
- Tue Oct 08 11:13:01 2013 +0000
- Revision:
- 0:3cb0e69f1806
Simple joystick controller with LCD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ssery | 0:3cb0e69f1806 | 1 | #include "mbed.h" |
ssery | 0:3cb0e69f1806 | 2 | #include "C12832_lcd.h" |
ssery | 0:3cb0e69f1806 | 3 | |
ssery | 0:3cb0e69f1806 | 4 | // LCD and Joystick Setting |
ssery | 0:3cb0e69f1806 | 5 | C12832_LCD lcd; |
ssery | 0:3cb0e69f1806 | 6 | |
ssery | 0:3cb0e69f1806 | 7 | BusIn Up(p15); |
ssery | 0:3cb0e69f1806 | 8 | BusIn Down(p12); |
ssery | 0:3cb0e69f1806 | 9 | BusIn Left(p13); |
ssery | 0:3cb0e69f1806 | 10 | BusIn Right(p16); |
ssery | 0:3cb0e69f1806 | 11 | BusOut Reset(p14); |
ssery | 0:3cb0e69f1806 | 12 | |
ssery | 0:3cb0e69f1806 | 13 | // Custom Function |
ssery | 0:3cb0e69f1806 | 14 | void initialize(); |
ssery | 0:3cb0e69f1806 | 15 | |
ssery | 0:3cb0e69f1806 | 16 | // Main |
ssery | 0:3cb0e69f1806 | 17 | int main() |
ssery | 0:3cb0e69f1806 | 18 | { |
ssery | 0:3cb0e69f1806 | 19 | initialize(); |
ssery | 0:3cb0e69f1806 | 20 | while(1) |
ssery | 0:3cb0e69f1806 | 21 | { |
ssery | 0:3cb0e69f1806 | 22 | lcd.locate(0,15); // Set Location print a text |
ssery | 0:3cb0e69f1806 | 23 | // Operations by Joystic |
ssery | 0:3cb0e69f1806 | 24 | if (Up) |
ssery | 0:3cb0e69f1806 | 25 | lcd.printf("UP"); |
ssery | 0:3cb0e69f1806 | 26 | if (Down) |
ssery | 0:3cb0e69f1806 | 27 | lcd.printf("Down"); |
ssery | 0:3cb0e69f1806 | 28 | if (Left) |
ssery | 0:3cb0e69f1806 | 29 | lcd.printf("Left"); |
ssery | 0:3cb0e69f1806 | 30 | if (Right) |
ssery | 0:3cb0e69f1806 | 31 | lcd.printf("Right"); |
ssery | 0:3cb0e69f1806 | 32 | if (Reset) |
ssery | 0:3cb0e69f1806 | 33 | initialize(); |
ssery | 0:3cb0e69f1806 | 34 | } |
ssery | 0:3cb0e69f1806 | 35 | } |
ssery | 0:3cb0e69f1806 | 36 | void initialize() |
ssery | 0:3cb0e69f1806 | 37 | { |
ssery | 0:3cb0e69f1806 | 38 | lcd.cls(); |
ssery | 0:3cb0e69f1806 | 39 | lcd.locate(0,0); |
ssery | 0:3cb0e69f1806 | 40 | lcd.printf("Joystic and LCD Controller!"); |
ssery | 0:3cb0e69f1806 | 41 | } |