diff --git a/esp32/include/msgs/mode_msg.hpp b/esp32/include/msgs/mode_msg.hpp index 4e93ad4..1b2125c 100644 --- a/esp32/include/msgs/mode_msg.hpp +++ b/esp32/include/msgs/mode_msg.hpp @@ -1,7 +1,7 @@ #pragma once #include -enum class MotionState { ON, OFF }; +enum class MotionState { DEACTIVATED, IDLE, CALIBRATION, REST, STAND, CRAWL, WALK }; struct ModeMsg { MotionState mode; diff --git a/esp32/include/msgs/servo_msg.hpp b/esp32/include/msgs/servo_msg.hpp new file mode 100644 index 0000000..5a3e8df --- /dev/null +++ b/esp32/include/msgs/servo_msg.hpp @@ -0,0 +1,22 @@ +#pragma once +#include + +#ifndef NUM_SERVOS +#define NUM_SERVOS 12 +#endif + +struct ServoMsg { + float angles[NUM_SERVOS]; + friend void toJson(JsonVariant v, ServoMsg const &a) { + JsonArray arr = v.to(); + for (int i = 0; i < NUM_SERVOS; i++) { + arr.add(a.angles[i]); + } + } + void fromJson(JsonVariantConst o) { + JsonArrayConst arr = o.as(); + for (int i = 0; i < NUM_SERVOS; i++) { + angles[i] = arr[i].as(); + } + } +}; \ No newline at end of file