curves now sending/receiving correctly. Y values are now converted to Int16 values to allow handles to dip below 0~

master
realrobots 2025-10-10 23:12:08 +08:00
parent 88fec6ef3c
commit 9e3979f4d6
3 changed files with 8 additions and 7 deletions

View File

@ -137,8 +137,9 @@ void setup() {
// anim.saveToFile("/scurve.anim");
// Serial.println("SAVED");
handleSaveFile(testPayload, testPayloadLength);
anim.loadFromFile("/pointcurve2.anim");
//handleSaveFile(testPayload, testPayloadLength);
Serial.println("Loading test.anim");
anim.loadFromFile("/test.anim");
Serial.println(anim.header.frameCount);
anim.printCurves();
// Serial.print("CurveSegment size: ");

View File

@ -29,7 +29,7 @@ uint16_t Animation::getMotorPosition(uint8_t motorID, uint16_t timeCS) {
for (const auto& seg : curves[motorID]) {
if (timeCS >= seg.startTime && timeCS <= seg.endTime) {
// Convert uint16_t to float in range -1 to 1
auto toFloat = [](uint16_t v) {
auto toFloat = [](int16_t v) {
return (float(v) / 65535.0f) * 2.0f - 1.0f;
};

View File

@ -25,12 +25,12 @@ struct __attribute__((packed)) CurveSegment {
uint16_t startTime;// centiseconds (0.01s) MAX 655.35 seconds
uint16_t endTime;// centiseconds (0.01s) MAX 655.35 seconds
// remapped from -1 to 1 → 065535
uint16_t startPointY;
int16_t startPointY;
uint16_t startHandleX;
uint16_t startHandleY;
int16_t startHandleY;
uint16_t endHandleX;
uint16_t endHandleY;
uint16_t endPointY;
int16_t endHandleY;
int16_t endPointY;
};