diff --git a/HansonServo.ino b/HansonServo.ino index 0c8e6c4..69e483e 100644 --- a/HansonServo.ino +++ b/HansonServo.ino @@ -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: "); diff --git a/animation.cpp b/animation.cpp index caca1ff..a353112 100644 --- a/animation.cpp +++ b/animation.cpp @@ -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; }; diff --git a/animation.h b/animation.h index 0796da8..fde2ee6 100644 --- a/animation.h +++ b/animation.h @@ -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 → 0–65535 - 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; };