The subsystem design/basis for the final project
Dependencies: mbed-rtos mbed-src pixylib
main.cpp@4:01252f56e0e5, 2016-03-18 (annotated)
- Committer:
- balsamfir
- Date:
- Fri Mar 18 17:05:22 2016 +0000
- Revision:
- 4:01252f56e0e5
- Parent:
- 3:dfb6733ae397
- Child:
- 5:f655435d0782
Commit before adding features
Who changed what in which revision?
User | Revision | Line number | New 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 "response.h" |
balsamfir | 2:2bc519e14bae | 7 | #include "tuning.h" |
JamesMacLean | 0:80a37292f6b2 | 8 | |
JamesMacLean | 0:80a37292f6b2 | 9 | |
balsamfir | 2:2bc519e14bae | 10 | // Definitions |
balsamfir | 2:2bc519e14bae | 11 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 12 | enum Mode { |
balsamfir | 3:dfb6733ae397 | 13 | AUTO_TRACK = '0', |
balsamfir | 3:dfb6733ae397 | 14 | MANUAL_CONTROL = '1', |
balsamfir | 4:01252f56e0e5 | 15 | MOTOR_RESPONSE = '2', |
balsamfir | 4:01252f56e0e5 | 16 | SPEED_RESPONSE = '3', |
balsamfir | 4:01252f56e0e5 | 17 | STEERING_RESPONSE = '4', |
balsamfir | 4:01252f56e0e5 | 18 | TILT_RESPONSE = '5', |
balsamfir | 4:01252f56e0e5 | 19 | MOTOR_TUNING = '6', |
balsamfir | 4:01252f56e0e5 | 20 | SPEED_TUNING = '7', |
balsamfir | 4:01252f56e0e5 | 21 | STEERING_TUNING = '8', |
balsamfir | 4:01252f56e0e5 | 22 | TILT_TUNING = '9' |
balsamfir | 2:2bc519e14bae | 23 | }; |
JamesMacLean | 0:80a37292f6b2 | 24 | |
balsamfir | 2:2bc519e14bae | 25 | void PrintMenu(Serial *pc); |
JamesMacLean | 0:80a37292f6b2 | 26 | |
JamesMacLean | 0:80a37292f6b2 | 27 | |
balsamfir | 2:2bc519e14bae | 28 | // Wiring - TODO |
balsamfir | 2:2bc519e14bae | 29 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 30 | // |
balsamfir | 2:2bc519e14bae | 31 | // |
balsamfir | 2:2bc519e14bae | 32 | // |
balsamfir | 2:2bc519e14bae | 33 | // |
balsamfir | 2:2bc519e14bae | 34 | // |
balsamfir | 2:2bc519e14bae | 35 | // |
JamesMacLean | 0:80a37292f6b2 | 36 | |
balsamfir | 2:2bc519e14bae | 37 | // Main Program |
balsamfir | 2:2bc519e14bae | 38 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 39 | int main() { |
balsamfir | 3:dfb6733ae397 | 40 | int mode; |
balsamfir | 3:dfb6733ae397 | 41 | |
JamesMacLean | 0:80a37292f6b2 | 42 | while (1) { |
balsamfir | 2:2bc519e14bae | 43 | PrintMenu(&pc); |
balsamfir | 2:2bc519e14bae | 44 | mode = pc.getc(); |
balsamfir | 3:dfb6733ae397 | 45 | pc.printf("\r\n\r\n"); |
balsamfir | 2:2bc519e14bae | 46 | switch (mode) { |
balsamfir | 2:2bc519e14bae | 47 | case AUTO_TRACK: |
balsamfir | 2:2bc519e14bae | 48 | AutoTrack(); |
balsamfir | 2:2bc519e14bae | 49 | break; |
balsamfir | 2:2bc519e14bae | 50 | case MANUAL_CONTROL: |
balsamfir | 2:2bc519e14bae | 51 | ManualControl(); |
balsamfir | 2:2bc519e14bae | 52 | break; |
balsamfir | 2:2bc519e14bae | 53 | case MOTOR_RESPONSE: |
balsamfir | 2:2bc519e14bae | 54 | MotorResponse(); |
balsamfir | 2:2bc519e14bae | 55 | break; |
balsamfir | 2:2bc519e14bae | 56 | case SPEED_RESPONSE: |
balsamfir | 2:2bc519e14bae | 57 | SpeedResponse(); |
balsamfir | 2:2bc519e14bae | 58 | break; |
balsamfir | 2:2bc519e14bae | 59 | case STEERING_RESPONSE: |
balsamfir | 2:2bc519e14bae | 60 | SteeringResponse(); |
balsamfir | 2:2bc519e14bae | 61 | break; |
balsamfir | 2:2bc519e14bae | 62 | case TILT_RESPONSE: |
balsamfir | 2:2bc519e14bae | 63 | TiltResponse(); |
balsamfir | 2:2bc519e14bae | 64 | break; |
balsamfir | 2:2bc519e14bae | 65 | case MOTOR_TUNING: |
balsamfir | 2:2bc519e14bae | 66 | MotorTuning(); |
balsamfir | 2:2bc519e14bae | 67 | break; |
balsamfir | 2:2bc519e14bae | 68 | case SPEED_TUNING: |
balsamfir | 2:2bc519e14bae | 69 | SpeedTuning(); |
balsamfir | 2:2bc519e14bae | 70 | break; |
balsamfir | 2:2bc519e14bae | 71 | case STEERING_TUNING: |
balsamfir | 2:2bc519e14bae | 72 | SteeringTuning(); |
balsamfir | 2:2bc519e14bae | 73 | break; |
balsamfir | 2:2bc519e14bae | 74 | case TILT_TUNING: |
balsamfir | 3:dfb6733ae397 | 75 | TiltTuning(); |
balsamfir | 2:2bc519e14bae | 76 | break; |
balsamfir | 2:2bc519e14bae | 77 | default: |
balsamfir | 3:dfb6733ae397 | 78 | pc.printf("Error: Invalid Selection \r\n\r\n"); |
balsamfir | 2:2bc519e14bae | 79 | break; |
JamesMacLean | 0:80a37292f6b2 | 80 | } |
balsamfir | 3:dfb6733ae397 | 81 | wait_ms(2000); |
JamesMacLean | 0:80a37292f6b2 | 82 | } |
JamesMacLean | 0:80a37292f6b2 | 83 | } |
JamesMacLean | 0:80a37292f6b2 | 84 | |
balsamfir | 2:2bc519e14bae | 85 | // Other Functions |
balsamfir | 2:2bc519e14bae | 86 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 87 | void PrintMenu(Serial *pc){ |
balsamfir | 3:dfb6733ae397 | 88 | pc->printf("\e[1;1H\e[2J"); |
balsamfir | 3:dfb6733ae397 | 89 | pc->printf("Select Mode: \r\n\r\n"); |
balsamfir | 3:dfb6733ae397 | 90 | |
balsamfir | 2:2bc519e14bae | 91 | pc->printf("---------------------------------------------------------------- \r\n"); |
balsamfir | 2:2bc519e14bae | 92 | pc->printf("0. Automated Tracking \r\n"); |
balsamfir | 2:2bc519e14bae | 93 | pc->printf("1. Manual Control \r\n"); |
balsamfir | 4:01252f56e0e5 | 94 | pc->printf("2. Motor Response \r\n"); |
balsamfir | 4:01252f56e0e5 | 95 | pc->printf("3. Speed Response \r\n"); |
balsamfir | 4:01252f56e0e5 | 96 | pc->printf("4. Steering Response \r\n"); |
balsamfir | 4:01252f56e0e5 | 97 | pc->printf("5. Tilt Response \r\n"); |
balsamfir | 4:01252f56e0e5 | 98 | pc->printf("6. Motor Tunning \r\n"); |
balsamfir | 4:01252f56e0e5 | 99 | pc->printf("7. Speed Tunning \r\n"); |
balsamfir | 4:01252f56e0e5 | 100 | pc->printf("8. Steeing Tunning \r\n"); |
balsamfir | 4:01252f56e0e5 | 101 | pc->printf("9. Tilit Tunning \r\n"); |
balsamfir | 2:2bc519e14bae | 102 | pc->printf("---------------------------------------------------------------- \r\n\r\n"); |
JamesMacLean | 0:80a37292f6b2 | 103 | |
balsamfir | 2:2bc519e14bae | 104 | pc->printf("=> "); |
JamesMacLean | 0:80a37292f6b2 | 105 | } |