The subsystem design/basis for the final project

Dependencies:   mbed-rtos mbed-src pixylib

Committer:
balsamfir
Date:
Fri Mar 25 13:36:14 2016 +0000
Revision:
5:f655435d0782
Parent:
4:01252f56e0e5
Child:
7:5ef312aa2678
Backup before revert

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