The subsystem design/basis for the final project
Dependencies: mbed-rtos mbed-src pixylib
main.cpp@15:caa5a93a31d7, 2016-03-26 (annotated)
- Committer:
- balsamfir
- Date:
- Sat Mar 26 19:24:02 2016 +0000
- Revision:
- 15:caa5a93a31d7
- Parent:
- 14:2d609d465f00
- Child:
- 17:47e107f9587b
Added manual control;
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" |
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 | 15:caa5a93a31d7 | 40 | pc.printf("Robot Shutdown... \r\n\r\n"); |
balsamfir | 2:2bc519e14bae | 41 | break; |
balsamfir | 2:2bc519e14bae | 42 | case MANUAL_CONTROL: |
balsamfir | 2:2bc519e14bae | 43 | ManualControl(); |
balsamfir | 2:2bc519e14bae | 44 | break; |
balsamfir | 14:2d609d465f00 | 45 | case SYSTEM_TUNING: |
balsamfir | 15:caa5a93a31d7 | 46 | Tunning(); |
balsamfir | 14:2d609d465f00 | 47 | pc.printf("Robot Shutdown... \r\n\r\n"); |
balsamfir | 7:5ef312aa2678 | 48 | break; |
balsamfir | 2:2bc519e14bae | 49 | default: |
balsamfir | 3:dfb6733ae397 | 50 | pc.printf("Error: Invalid Selection \r\n\r\n"); |
balsamfir | 2:2bc519e14bae | 51 | break; |
JamesMacLean | 0:80a37292f6b2 | 52 | } |
balsamfir | 3:dfb6733ae397 | 53 | wait_ms(2000); |
JamesMacLean | 0:80a37292f6b2 | 54 | } |
JamesMacLean | 0:80a37292f6b2 | 55 | } |
JamesMacLean | 0:80a37292f6b2 | 56 | |
balsamfir | 2:2bc519e14bae | 57 | // Other Functions |
balsamfir | 2:2bc519e14bae | 58 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 59 | void PrintMenu(Serial *pc){ |
balsamfir | 3:dfb6733ae397 | 60 | pc->printf("\e[1;1H\e[2J"); |
balsamfir | 3:dfb6733ae397 | 61 | pc->printf("Select Mode: \r\n\r\n"); |
balsamfir | 3:dfb6733ae397 | 62 | |
balsamfir | 2:2bc519e14bae | 63 | pc->printf("---------------------------------------------------------------- \r\n"); |
balsamfir | 2:2bc519e14bae | 64 | pc->printf("0. Automated Tracking \r\n"); |
balsamfir | 2:2bc519e14bae | 65 | pc->printf("1. Manual Control \r\n"); |
balsamfir | 14:2d609d465f00 | 66 | pc->printf("2. System Tuning \r\n"); |
balsamfir | 2:2bc519e14bae | 67 | pc->printf("---------------------------------------------------------------- \r\n\r\n"); |
JamesMacLean | 0:80a37292f6b2 | 68 | |
balsamfir | 2:2bc519e14bae | 69 | pc->printf("=> "); |
JamesMacLean | 0:80a37292f6b2 | 70 | } |