The subsystem design/basis for the final project

Dependencies:   mbed-rtos mbed-src pixylib

Committer:
balsamfir
Date:
Thu Apr 07 13:19:29 2016 +0000
Revision:
18:501f1007a572
Parent:
17:47e107f9587b
Child:
19:05b8123905fb
Added compatibility with new PS3 control app

Who changed what in which revision?

UserRevisionLine numberNew contents of line
balsamfir 2:2bc519e14bae 1 // Includes
balsamfir 2:2bc519e14bae 2 // ----------------------------------------------------------------
JamesMacLean 0:80a37292f6b2 3
balsamfir 2:2bc519e14bae 4 #include "global.h"
balsamfir 2:2bc519e14bae 5 #include "robot.h"
JamesMacLean 0:80a37292f6b2 6
balsamfir 15:caa5a93a31d7 7 // Definitions
balsamfir 2:2bc519e14bae 8 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 9 enum Mode {
balsamfir 3:dfb6733ae397 10 AUTO_TRACK = '0',
balsamfir 3:dfb6733ae397 11 MANUAL_CONTROL = '1',
balsamfir 14:2d609d465f00 12 SYSTEM_TUNING = '2'
balsamfir 2:2bc519e14bae 13 };
JamesMacLean 0:80a37292f6b2 14
balsamfir 2:2bc519e14bae 15 void PrintMenu(Serial *pc);
JamesMacLean 0:80a37292f6b2 16
JamesMacLean 0:80a37292f6b2 17
balsamfir 2:2bc519e14bae 18 // Wiring - TODO
balsamfir 2:2bc519e14bae 19 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 20 //
balsamfir 2:2bc519e14bae 21 //
balsamfir 2:2bc519e14bae 22 //
balsamfir 2:2bc519e14bae 23 //
balsamfir 2:2bc519e14bae 24 //
balsamfir 2:2bc519e14bae 25 //
JamesMacLean 0:80a37292f6b2 26
balsamfir 2:2bc519e14bae 27 // Main Program
balsamfir 2:2bc519e14bae 28 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 29 int main() {
balsamfir 3:dfb6733ae397 30 int mode;
balsamfir 15:caa5a93a31d7 31 InitRobot();
balsamfir 3:dfb6733ae397 32
JamesMacLean 0:80a37292f6b2 33 while (1) {
balsamfir 2:2bc519e14bae 34 PrintMenu(&pc);
balsamfir 2:2bc519e14bae 35 mode = pc.getc();
balsamfir 3:dfb6733ae397 36 pc.printf("\r\n\r\n");
balsamfir 18:501f1007a572 37 if ((mode == '0')||(mode == 'a')) {
balsamfir 18:501f1007a572 38 AutoTrack();
balsamfir 18:501f1007a572 39 } else if ((mode == '1')||(mode == 'm')) {
balsamfir 18:501f1007a572 40 ManualControl();
balsamfir 18:501f1007a572 41 } else if (mode == '2') {
balsamfir 18:501f1007a572 42 Tunning();
balsamfir 18:501f1007a572 43 } else {
balsamfir 18:501f1007a572 44 pc.printf("Error: Invalid Selection \r\n\r\n");
JamesMacLean 0:80a37292f6b2 45 }
balsamfir 3:dfb6733ae397 46 wait_ms(2000);
JamesMacLean 0:80a37292f6b2 47 }
JamesMacLean 0:80a37292f6b2 48 }
JamesMacLean 0:80a37292f6b2 49
balsamfir 2:2bc519e14bae 50 // Other Functions
balsamfir 2:2bc519e14bae 51 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 52 void PrintMenu(Serial *pc){
balsamfir 3:dfb6733ae397 53 pc->printf("\e[1;1H\e[2J");
balsamfir 3:dfb6733ae397 54 pc->printf("Select Mode: \r\n\r\n");
balsamfir 3:dfb6733ae397 55
balsamfir 2:2bc519e14bae 56 pc->printf("---------------------------------------------------------------- \r\n");
balsamfir 2:2bc519e14bae 57 pc->printf("0. Automated Tracking \r\n");
balsamfir 2:2bc519e14bae 58 pc->printf("1. Manual Control \r\n");
balsamfir 14:2d609d465f00 59 pc->printf("2. System Tuning \r\n");
balsamfir 2:2bc519e14bae 60 pc->printf("---------------------------------------------------------------- \r\n\r\n");
JamesMacLean 0:80a37292f6b2 61
balsamfir 2:2bc519e14bae 62 pc->printf("=> ");
JamesMacLean 0:80a37292f6b2 63 }