The subsystem design/basis for the final project

Dependencies:   mbed-rtos mbed-src pixylib

Committer:
balsamfir
Date:
Sun Apr 03 19:00:21 2016 +0000
Revision:
17:47e107f9587b
Parent:
15:caa5a93a31d7
Child:
18:501f1007a572
Added print ability to tunning

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 2:2bc519e14bae 37 switch (mode) {
balsamfir 2:2bc519e14bae 38 case AUTO_TRACK:
balsamfir 15:caa5a93a31d7 39 AutoTrack();
balsamfir 2:2bc519e14bae 40 break;
balsamfir 2:2bc519e14bae 41 case MANUAL_CONTROL:
balsamfir 2:2bc519e14bae 42 ManualControl();
balsamfir 2:2bc519e14bae 43 break;
balsamfir 14:2d609d465f00 44 case SYSTEM_TUNING:
balsamfir 15:caa5a93a31d7 45 Tunning();
balsamfir 7:5ef312aa2678 46 break;
balsamfir 2:2bc519e14bae 47 default:
balsamfir 3:dfb6733ae397 48 pc.printf("Error: Invalid Selection \r\n\r\n");
balsamfir 2:2bc519e14bae 49 break;
JamesMacLean 0:80a37292f6b2 50 }
balsamfir 3:dfb6733ae397 51 wait_ms(2000);
JamesMacLean 0:80a37292f6b2 52 }
JamesMacLean 0:80a37292f6b2 53 }
JamesMacLean 0:80a37292f6b2 54
balsamfir 2:2bc519e14bae 55 // Other Functions
balsamfir 2:2bc519e14bae 56 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 57 void PrintMenu(Serial *pc){
balsamfir 3:dfb6733ae397 58 pc->printf("\e[1;1H\e[2J");
balsamfir 3:dfb6733ae397 59 pc->printf("Select Mode: \r\n\r\n");
balsamfir 3:dfb6733ae397 60
balsamfir 2:2bc519e14bae 61 pc->printf("---------------------------------------------------------------- \r\n");
balsamfir 2:2bc519e14bae 62 pc->printf("0. Automated Tracking \r\n");
balsamfir 2:2bc519e14bae 63 pc->printf("1. Manual Control \r\n");
balsamfir 14:2d609d465f00 64 pc->printf("2. System Tuning \r\n");
balsamfir 2:2bc519e14bae 65 pc->printf("---------------------------------------------------------------- \r\n\r\n");
JamesMacLean 0:80a37292f6b2 66
balsamfir 2:2bc519e14bae 67 pc->printf("=> ");
JamesMacLean 0:80a37292f6b2 68 }