Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI MODSERIAL
main.cpp@1:675b67b2ae02, 2019-10-22 (annotated)
- Committer:
- JasperFix
- Date:
- Tue Oct 22 08:43:25 2019 +0000
- Revision:
- 1:675b67b2ae02
- Parent:
- 0:05da2ae2ad90
- Child:
- 4:40dc3d3da129
State machine in switch gebeund
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| samzijp | 0:05da2ae2ad90 | 1 | #include "mbed.h" |
| JasperFix | 1:675b67b2ae02 | 2 | #include "MODSERIAL.h" |
| JasperFix | 1:675b67b2ae02 | 3 | #include "QEI.h" |
| samzijp | 0:05da2ae2ad90 | 4 | |
| samzijp | 0:05da2ae2ad90 | 5 | |
| JasperFix | 1:675b67b2ae02 | 6 | Serial pc(USBTX, USBRX); |
| JasperFix | 1:675b67b2ae02 | 7 | |
| JasperFix | 1:675b67b2ae02 | 8 | enum states {WAITING, MOTOR_ANGLE_CLBRT, EMG_CLBRT, HOMING, WAITING4SIGNAL, OPERATION, SHOOTING, DEMO, FAILURE_MODE}; |
| JasperFix | 1:675b67b2ae02 | 9 | states currentState = WAITING; // Start in waiting state |
| samzijp | 0:05da2ae2ad90 | 10 | |
| JasperFix | 1:675b67b2ae02 | 11 | void state_machine(void){ |
| JasperFix | 1:675b67b2ae02 | 12 | |
| JasperFix | 1:675b67b2ae02 | 13 | switch(current_state){ |
| JasperFix | 1:675b67b2ae02 | 14 | |
| JasperFix | 1:675b67b2ae02 | 15 | case WAITING: |
| JasperFix | 1:675b67b2ae02 | 16 | |
| JasperFix | 1:675b67b2ae02 | 17 | break; |
| JasperFix | 1:675b67b2ae02 | 18 | |
| JasperFix | 1:675b67b2ae02 | 19 | case MOTOR_ANGLE_CLBRT: |
| JasperFix | 1:675b67b2ae02 | 20 | |
| JasperFix | 1:675b67b2ae02 | 21 | break; |
| JasperFix | 1:675b67b2ae02 | 22 | |
| JasperFix | 1:675b67b2ae02 | 23 | case EMG_CLBRT: |
| JasperFix | 1:675b67b2ae02 | 24 | |
| JasperFix | 1:675b67b2ae02 | 25 | break; |
| JasperFix | 1:675b67b2ae02 | 26 | |
| JasperFix | 1:675b67b2ae02 | 27 | case HOMING: |
| JasperFix | 1:675b67b2ae02 | 28 | |
| JasperFix | 1:675b67b2ae02 | 29 | break; |
| JasperFix | 1:675b67b2ae02 | 30 | |
| JasperFix | 1:675b67b2ae02 | 31 | case WAITING4SIGNAL: |
| JasperFix | 1:675b67b2ae02 | 32 | |
| JasperFix | 1:675b67b2ae02 | 33 | break; |
| JasperFix | 1:675b67b2ae02 | 34 | |
| JasperFix | 1:675b67b2ae02 | 35 | case OPERATION: |
| JasperFix | 1:675b67b2ae02 | 36 | |
| JasperFix | 1:675b67b2ae02 | 37 | break; |
| JasperFix | 1:675b67b2ae02 | 38 | |
| JasperFix | 1:675b67b2ae02 | 39 | case SHOOTING: |
| JasperFix | 1:675b67b2ae02 | 40 | |
| JasperFix | 1:675b67b2ae02 | 41 | break; |
| JasperFix | 1:675b67b2ae02 | 42 | |
| JasperFix | 1:675b67b2ae02 | 43 | case DEMO: |
| JasperFix | 1:675b67b2ae02 | 44 | |
| JasperFix | 1:675b67b2ae02 | 45 | break; |
| JasperFix | 1:675b67b2ae02 | 46 | |
| JasperFix | 1:675b67b2ae02 | 47 | case FAILURE_MODE: |
| JasperFix | 1:675b67b2ae02 | 48 | |
| JasperFix | 1:675b67b2ae02 | 49 | break; |
| JasperFix | 1:675b67b2ae02 | 50 | |
| JasperFix | 1:675b67b2ae02 | 51 | |
| JasperFix | 1:675b67b2ae02 | 52 | int main() |
| JasperFix | 1:675b67b2ae02 | 53 | { |
| JasperFix | 1:675b67b2ae02 | 54 | |
| samzijp | 0:05da2ae2ad90 | 55 | } |
| samzijp | 0:05da2ae2ad90 | 56 | } |