HansonServo/robotconfig.h

32 lines
780 B
C++

#pragma once
#include <Arduino.h>
#include <vector>
struct FirmwareVersion {
uint8_t major;
uint8_t minor;
};
struct Motor {
String name; // Optional: name or ID of the motor
uint8_t motorID;
uint16_t position; // Current position in encoder ticks or degrees
bool isEnabled = true;
};
struct RobotConfig {
String deviceName; // Name of the robot
FirmwareVersion firmwareVersion;
std::vector<Motor> motors; // Dynamic array of motors
uint16_t getMotorPosition(uint8_t motorID) const;
bool setMotorPosition(uint8_t motorID, uint16_t newPosition);
bool setMotorEnabled(uint8_t motorID,bool enable);
bool isMotorEnabled(uint8_t motorID);
void enableAllMotors();
String serializeJSON() const;
std::vector<uint8_t> serializeToBytes() const;
};