The subsystem design/basis for the final project

Dependencies:   mbed-rtos mbed-src pixylib

Committer:
balsamfir
Date:
Fri Mar 25 19:34:16 2016 +0000
Revision:
7:5ef312aa2678
Parent:
5:f655435d0782
Child:
14:2d609d465f00
First working version

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"
balsamfir 2:2bc519e14bae 6 #include "tuning.h"
JamesMacLean 0:80a37292f6b2 7
JamesMacLean 0:80a37292f6b2 8
balsamfir 2:2bc519e14bae 9 // Definitions
balsamfir 2:2bc519e14bae 10 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 11 enum Mode {
balsamfir 3:dfb6733ae397 12 AUTO_TRACK = '0',
balsamfir 3:dfb6733ae397 13 MANUAL_CONTROL = '1',
balsamfir 5:f655435d0782 14 MOTOR_TUNING = '2',
balsamfir 5:f655435d0782 15 SPEED_TUNING = '3',
balsamfir 5:f655435d0782 16 STEERING_TUNING = '4',
balsamfir 7:5ef312aa2678 17 TILT_TUNING = '5',
balsamfir 7:5ef312aa2678 18 SYSTEM_TUNING = '6'
balsamfir 2:2bc519e14bae 19 };
JamesMacLean 0:80a37292f6b2 20
balsamfir 2:2bc519e14bae 21 void PrintMenu(Serial *pc);
JamesMacLean 0:80a37292f6b2 22
JamesMacLean 0:80a37292f6b2 23
balsamfir 2:2bc519e14bae 24 // Wiring - TODO
balsamfir 2:2bc519e14bae 25 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 26 //
balsamfir 2:2bc519e14bae 27 //
balsamfir 2:2bc519e14bae 28 //
balsamfir 2:2bc519e14bae 29 //
balsamfir 2:2bc519e14bae 30 //
balsamfir 2:2bc519e14bae 31 //
JamesMacLean 0:80a37292f6b2 32
balsamfir 2:2bc519e14bae 33 // Main Program
balsamfir 2:2bc519e14bae 34 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 35 int main() {
balsamfir 3:dfb6733ae397 36 int mode;
balsamfir 3:dfb6733ae397 37
JamesMacLean 0:80a37292f6b2 38 while (1) {
balsamfir 2:2bc519e14bae 39 PrintMenu(&pc);
balsamfir 2:2bc519e14bae 40 mode = pc.getc();
balsamfir 3:dfb6733ae397 41 pc.printf("\r\n\r\n");
balsamfir 2:2bc519e14bae 42 switch (mode) {
balsamfir 2:2bc519e14bae 43 case AUTO_TRACK:
balsamfir 2:2bc519e14bae 44 AutoTrack();
balsamfir 2:2bc519e14bae 45 break;
balsamfir 2:2bc519e14bae 46 case MANUAL_CONTROL:
balsamfir 2:2bc519e14bae 47 ManualControl();
balsamfir 2:2bc519e14bae 48 break;
balsamfir 2:2bc519e14bae 49 case MOTOR_TUNING:
balsamfir 2:2bc519e14bae 50 MotorTuning();
balsamfir 2:2bc519e14bae 51 break;
balsamfir 2:2bc519e14bae 52 case SPEED_TUNING:
balsamfir 2:2bc519e14bae 53 SpeedTuning();
balsamfir 2:2bc519e14bae 54 break;
balsamfir 2:2bc519e14bae 55 case STEERING_TUNING:
balsamfir 2:2bc519e14bae 56 SteeringTuning();
balsamfir 2:2bc519e14bae 57 break;
balsamfir 2:2bc519e14bae 58 case TILT_TUNING:
balsamfir 5:f655435d0782 59 TiltTuning();
balsamfir 2:2bc519e14bae 60 break;
balsamfir 7:5ef312aa2678 61 case SYSTEM_TUNING:
balsamfir 7:5ef312aa2678 62 SystemTuning();
balsamfir 7:5ef312aa2678 63 break;
balsamfir 2:2bc519e14bae 64 default:
balsamfir 3:dfb6733ae397 65 pc.printf("Error: Invalid Selection \r\n\r\n");
balsamfir 2:2bc519e14bae 66 break;
JamesMacLean 0:80a37292f6b2 67 }
balsamfir 3:dfb6733ae397 68 wait_ms(2000);
JamesMacLean 0:80a37292f6b2 69 }
JamesMacLean 0:80a37292f6b2 70 }
JamesMacLean 0:80a37292f6b2 71
balsamfir 2:2bc519e14bae 72 // Other Functions
balsamfir 2:2bc519e14bae 73 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 74 void PrintMenu(Serial *pc){
balsamfir 3:dfb6733ae397 75 pc->printf("\e[1;1H\e[2J");
balsamfir 3:dfb6733ae397 76 pc->printf("Select Mode: \r\n\r\n");
balsamfir 3:dfb6733ae397 77
balsamfir 2:2bc519e14bae 78 pc->printf("---------------------------------------------------------------- \r\n");
balsamfir 2:2bc519e14bae 79 pc->printf("0. Automated Tracking \r\n");
balsamfir 2:2bc519e14bae 80 pc->printf("1. Manual Control \r\n");
balsamfir 5:f655435d0782 81 pc->printf("2. Motor Tuning \r\n");
balsamfir 5:f655435d0782 82 pc->printf("3. Speed Tuning \r\n");
balsamfir 5:f655435d0782 83 pc->printf("4. Steering Tuning \r\n");
balsamfir 5:f655435d0782 84 pc->printf("5. Tilt Tuning \r\n");
balsamfir 7:5ef312aa2678 85 pc->printf("6. System Tuning \r\n");
balsamfir 2:2bc519e14bae 86 pc->printf("---------------------------------------------------------------- \r\n\r\n");
JamesMacLean 0:80a37292f6b2 87
balsamfir 2:2bc519e14bae 88 pc->printf("=> ");
JamesMacLean 0:80a37292f6b2 89 }