The subsystem design/basis for the final project
Dependencies: mbed-rtos mbed-src pixylib
main.cpp@14:2d609d465f00, 2016-03-26 (annotated)
- Committer:
- balsamfir
- Date:
- Sat Mar 26 17:52:34 2016 +0000
- Revision:
- 14:2d609d465f00
- Parent:
- 7:5ef312aa2678
- Child:
- 15:caa5a93a31d7
Everything tuned and working nice
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 | |
JamesMacLean | 0:80a37292f6b2 | 7 | |
balsamfir | 2:2bc519e14bae | 8 | // Definitions |
balsamfir | 2:2bc519e14bae | 9 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 10 | enum Mode { |
balsamfir | 3:dfb6733ae397 | 11 | AUTO_TRACK = '0', |
balsamfir | 3:dfb6733ae397 | 12 | MANUAL_CONTROL = '1', |
balsamfir | 14:2d609d465f00 | 13 | SYSTEM_TUNING = '2' |
balsamfir | 2:2bc519e14bae | 14 | }; |
JamesMacLean | 0:80a37292f6b2 | 15 | |
balsamfir | 2:2bc519e14bae | 16 | void PrintMenu(Serial *pc); |
JamesMacLean | 0:80a37292f6b2 | 17 | |
JamesMacLean | 0:80a37292f6b2 | 18 | |
balsamfir | 2:2bc519e14bae | 19 | // Wiring - TODO |
balsamfir | 2:2bc519e14bae | 20 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 21 | // |
balsamfir | 2:2bc519e14bae | 22 | // |
balsamfir | 2:2bc519e14bae | 23 | // |
balsamfir | 2:2bc519e14bae | 24 | // |
balsamfir | 2:2bc519e14bae | 25 | // |
balsamfir | 2:2bc519e14bae | 26 | // |
JamesMacLean | 0:80a37292f6b2 | 27 | |
balsamfir | 2:2bc519e14bae | 28 | // Main Program |
balsamfir | 2:2bc519e14bae | 29 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 30 | int main() { |
balsamfir | 3:dfb6733ae397 | 31 | int mode; |
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 | 14:2d609d465f00 | 39 | AutoTrack(false); |
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 | 14:2d609d465f00 | 45 | AutoTrack(true); |
balsamfir | 14:2d609d465f00 | 46 | pc.printf("Robot Shutdown... \r\n\r\n"); |
balsamfir | 7:5ef312aa2678 | 47 | break; |
balsamfir | 2:2bc519e14bae | 48 | default: |
balsamfir | 3:dfb6733ae397 | 49 | pc.printf("Error: Invalid Selection \r\n\r\n"); |
balsamfir | 2:2bc519e14bae | 50 | break; |
JamesMacLean | 0:80a37292f6b2 | 51 | } |
balsamfir | 3:dfb6733ae397 | 52 | wait_ms(2000); |
JamesMacLean | 0:80a37292f6b2 | 53 | } |
JamesMacLean | 0:80a37292f6b2 | 54 | } |
JamesMacLean | 0:80a37292f6b2 | 55 | |
balsamfir | 2:2bc519e14bae | 56 | // Other Functions |
balsamfir | 2:2bc519e14bae | 57 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 58 | void PrintMenu(Serial *pc){ |
balsamfir | 3:dfb6733ae397 | 59 | pc->printf("\e[1;1H\e[2J"); |
balsamfir | 3:dfb6733ae397 | 60 | pc->printf("Select Mode: \r\n\r\n"); |
balsamfir | 3:dfb6733ae397 | 61 | |
balsamfir | 2:2bc519e14bae | 62 | pc->printf("---------------------------------------------------------------- \r\n"); |
balsamfir | 2:2bc519e14bae | 63 | pc->printf("0. Automated Tracking \r\n"); |
balsamfir | 2:2bc519e14bae | 64 | pc->printf("1. Manual Control \r\n"); |
balsamfir | 14:2d609d465f00 | 65 | pc->printf("2. System Tuning \r\n"); |
balsamfir | 2:2bc519e14bae | 66 | pc->printf("---------------------------------------------------------------- \r\n\r\n"); |
JamesMacLean | 0:80a37292f6b2 | 67 | |
balsamfir | 2:2bc519e14bae | 68 | pc->printf("=> "); |
JamesMacLean | 0:80a37292f6b2 | 69 | } |