Adds new messages

This commit is contained in:
Rune Harlyk
2025-07-08 15:20:01 +02:00
parent 06b05b2dc1
commit a592848f34
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include <ArduinoJson.h>
enum class MotionState { ON, OFF };
enum class MotionState { DEACTIVATED, IDLE, CALIBRATION, REST, STAND, CRAWL, WALK };
struct ModeMsg {
MotionState mode;
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#include <ArduinoJson.h>
#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<JsonArray>();
for (int i = 0; i < NUM_SERVOS; i++) {
arr.add(a.angles[i]);
}
}
void fromJson(JsonVariantConst o) {
JsonArrayConst arr = o.as<JsonArrayConst>();
for (int i = 0; i < NUM_SERVOS; i++) {
angles[i] = arr[i].as<float>();
}
}
};