42 lines
963 B
C++
42 lines
963 B
C++
#pragma once
|
|
#include <Arduino.h>
|
|
#include <vector>
|
|
|
|
struct FirmwareVersion {
|
|
uint8_t major;
|
|
uint8_t minor;
|
|
};
|
|
|
|
struct ServoModel {
|
|
uint8_t major;
|
|
uint8_t minor;
|
|
};
|
|
|
|
struct Motor {
|
|
String name;
|
|
uint8_t motorID;
|
|
ServoModel servoModel;
|
|
uint16_t position;
|
|
bool isEnabled = true;
|
|
};
|
|
|
|
struct RobotConfig {
|
|
String deviceName;
|
|
FirmwareVersion firmwareVersion;
|
|
std::vector<Motor> motors;
|
|
|
|
uint16_t getMotorPosition(uint8_t motorID) const;
|
|
uint8_t getMotorModel(uint8_t motorID);
|
|
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;
|
|
|
|
bool saveToFFat(const char* path = "/robot_config.bin") const;
|
|
bool loadFromFFat(const char* path = "/robot_config.bin");
|
|
bool loadOrCreateDefault(const char* path = "/robot_config.bin");
|
|
|
|
};
|