Bayley Wang
/
foc-ed_in_the_bot_compact
robot
Diff: main.cpp
- Revision:
- 194:05e119bc5a78
- Parent:
- 193:3abadeecf908
- Child:
- 195:b61a734eb50c
--- a/main.cpp Sat Feb 10 05:35:49 2018 +0000 +++ b/main.cpp Sat Feb 10 06:05:50 2018 +0000 @@ -14,6 +14,7 @@ #include "BREMSStructs.h" #include "BREMSConfig.h" +#include "prefs.h" #include "layout.h" #include "derived.h" #include "main.h" @@ -118,10 +119,25 @@ } void slow_loop() { - float x = io.throttle_in->get_throttle(); - x = control.throttle_filter->update(x); - control.user_cmd = io.throttle_in->get_usecs(); - control.torque_percent = th->map(x, read.w); + switch (BREMS_src) { + case CMD_SRC_RC: + control.user_cmd = control.throttle_filter->update(io.throttle_in->get_throttle()); + break; + case CMD_SRC_ANALOG: + //handle analog throttle here + break; + case CMD_SRC_TERMINAL: + case CMD_SRC_SERIAL: + case CMD_SRC_CAN: + case CMD_SRC_INTERNAL: + //these sources are updated by callbacks + break; + default: + //this should never happen! + break; + } + + control.torque_percent = th->map(control.user_cmd, read.w); dq->map(control.torque_percent, read.w, &control.d_ref, &control.q_ref); }