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 HIDScope biquadFilter MODSERIAL FastPWM
main.cpp@6:41b02057fc2c, 2019-10-01 (annotated)
- Committer:
- Rieks
- Date:
- Tue Oct 01 13:11:49 2019 +0000
- Revision:
- 6:41b02057fc2c
- Parent:
- 5:77929f5f1f32
- Child:
- 7:af0c16ae48d7
Start of implementation state-indicator leds
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rieks | 6:41b02057fc2c | 1 | //includes |
Rieks | 6:41b02057fc2c | 2 | #include "mbed.h" |
Rieks | 6:41b02057fc2c | 3 | //objects and variables |
Rieks | 6:41b02057fc2c | 4 | DigitalOut ledb(LED_BLUE); // ledb=true is led off!! |
Rieks | 6:41b02057fc2c | 5 | DigitalOut ledg(LED_GREEN); |
Rieks | 6:41b02057fc2c | 6 | DigitalOut ledr(LED_RED); |
JornD | 5:77929f5f1f32 | 7 | enum States {MovementIdle, CalibrationIdle, Demo, Startup, CalibrationPhysical, Move, TiltCup, FailState}; |
JornD | 2:6d026d5655c5 | 8 | States CurrentState; |
JornD | 1:a5c1140f464a | 9 | |
JornD | 2:6d026d5655c5 | 10 | void Run_Demo(void) |
JornD | 2:6d026d5655c5 | 11 | { |
Rieks | 6:41b02057fc2c | 12 | ledg=false; |
Rieks | 6:41b02057fc2c | 13 | ledr=true; |
Rieks | 6:41b02057fc2c | 14 | ledb=true;//only turns on the green light |
JornD | 5:77929f5f1f32 | 15 | |
JornD | 5:77929f5f1f32 | 16 | } |
JornD | 2:6d026d5655c5 | 17 | |
JornD | 5:77929f5f1f32 | 18 | void Run_MovementIdle(void) |
JornD | 5:77929f5f1f32 | 19 | { |
JornD | 5:77929f5f1f32 | 20 | |
JornD | 5:77929f5f1f32 | 21 | } |
JornD | 5:77929f5f1f32 | 22 | |
JornD | 5:77929f5f1f32 | 23 | void Run_CalibrationIdle(void) |
JornD | 5:77929f5f1f32 | 24 | { |
JornD | 5:77929f5f1f32 | 25 | |
JornD | 5:77929f5f1f32 | 26 | } |
JornD | 5:77929f5f1f32 | 27 | |
JornD | 5:77929f5f1f32 | 28 | void Run_Startup(void) |
JornD | 5:77929f5f1f32 | 29 | { |
JornD | 5:77929f5f1f32 | 30 | |
JornD | 2:6d026d5655c5 | 31 | } |
JornD | 2:6d026d5655c5 | 32 | |
JornD | 5:77929f5f1f32 | 33 | void Run_CalibrationPhysical(void) |
JornD | 2:6d026d5655c5 | 34 | { |
JornD | 5:77929f5f1f32 | 35 | |
JornD | 5:77929f5f1f32 | 36 | } |
JornD | 2:6d026d5655c5 | 37 | |
JornD | 5:77929f5f1f32 | 38 | void Run_CalibrationEMG(void) |
JornD | 5:77929f5f1f32 | 39 | { |
JornD | 5:77929f5f1f32 | 40 | |
JornD | 2:6d026d5655c5 | 41 | } |
JornD | 2:6d026d5655c5 | 42 | |
JornD | 5:77929f5f1f32 | 43 | void Run_Move(void) |
JornD | 5:77929f5f1f32 | 44 | { |
JornD | 5:77929f5f1f32 | 45 | |
JornD | 5:77929f5f1f32 | 46 | } |
JornD | 5:77929f5f1f32 | 47 | |
JornD | 5:77929f5f1f32 | 48 | void Run_TiltCup(void) |
JornD | 5:77929f5f1f32 | 49 | { |
JornD | 5:77929f5f1f32 | 50 | |
JornD | 5:77929f5f1f32 | 51 | } |
JornD | 5:77929f5f1f32 | 52 | |
JornD | 5:77929f5f1f32 | 53 | void Run_FailState(void) |
Rieks | 6:41b02057fc2c | 54 | { |
Rieks | 6:41b02057fc2c | 55 | ledg=true; |
Rieks | 6:41b02057fc2c | 56 | ledb=true; |
Rieks | 6:41b02057fc2c | 57 | while(true){ |
Rieks | 6:41b02057fc2c | 58 | ledr=!ledr; |
Rieks | 6:41b02057fc2c | 59 | wait(0.5f); } |
JornD | 5:77929f5f1f32 | 60 | } |
JornD | 5:77929f5f1f32 | 61 | |
JornD | 5:77929f5f1f32 | 62 | //State Machine |
JornD | 2:6d026d5655c5 | 63 | void StateMachine(void) |
JornD | 2:6d026d5655c5 | 64 | { |
JornD | 2:6d026d5655c5 | 65 | switch(CurrentState) |
JornD | 2:6d026d5655c5 | 66 | { |
JornD | 2:6d026d5655c5 | 67 | case Demo: |
JornD | 2:6d026d5655c5 | 68 | Run_Demo; |
JornD | 2:6d026d5655c5 | 69 | break; |
JornD | 5:77929f5f1f32 | 70 | case MovementIdle: |
Rieks | 6:41b02057fc2c | 71 | Run_MovementIdle; |
JornD | 5:77929f5f1f32 | 72 | break; |
JornD | 5:77929f5f1f32 | 73 | case CalibrationIdle: |
JornD | 5:77929f5f1f32 | 74 | Run_CalibrationIdle; |
JornD | 5:77929f5f1f32 | 75 | break; |
JornD | 5:77929f5f1f32 | 76 | case Startup; |
Rieks | 6:41b02057fc2c | 77 | Run_Startup; |
JornD | 5:77929f5f1f32 | 78 | break; |
JornD | 5:77929f5f1f32 | 79 | case CalibrationPhysical: |
JornD | 5:77929f5f1f32 | 80 | Run_CalibrationPhysical; |
JornD | 5:77929f5f1f32 | 81 | break; |
JornD | 5:77929f5f1f32 | 82 | case CalibrationEMG: |
JornD | 5:77929f5f1f32 | 83 | Run_CalibrationEMG; |
JornD | 5:77929f5f1f32 | 84 | break; |
JornD | 5:77929f5f1f32 | 85 | case Move: |
JornD | 5:77929f5f1f32 | 86 | Run_Move; |
JornD | 5:77929f5f1f32 | 87 | break; |
JornD | 5:77929f5f1f32 | 88 | case TiltCup: |
JornD | 5:77929f5f1f32 | 89 | Run_TiltCup; |
JornD | 5:77929f5f1f32 | 90 | break; |
JornD | 5:77929f5f1f32 | 91 | case FailState: |
JornD | 5:77929f5f1f32 | 92 | Run_FailState; |
JornD | 2:6d026d5655c5 | 93 | break; |
JornD | 2:6d026d5655c5 | 94 | } |
JornD | 2:6d026d5655c5 | 95 | } |
JornD | 1:a5c1140f464a | 96 | |
JornD | 5:77929f5f1f32 | 97 | //Main Loop |
JornD | 1:a5c1140f464a | 98 | int main() |
Rieks | 6:41b02057fc2c | 99 | { ledb=true; |
Rieks | 6:41b02057fc2c | 100 | ledr=true; |
Rieks | 6:41b02057fc2c | 101 | ledg=true;//turn off all leds |
JornD | 5:77929f5f1f32 | 102 | CurrentState = Startup; |
JornD | 1:a5c1140f464a | 103 | while(true) |
JornD | 1:a5c1140f464a | 104 | { |
JornD | 1:a5c1140f464a | 105 | |
JornD | 1:a5c1140f464a | 106 | } |
JornD | 1:a5c1140f464a | 107 | } |