tweaks to FRME packets
parent
2a1b4bd276
commit
ca2fb29a02
|
|
@ -175,35 +175,45 @@ void runFrameAnimation() {
|
|||
currentTick++;
|
||||
|
||||
// Handle animation end
|
||||
uint16_t framesPlayed = currentTick - animState.startFrame;
|
||||
uint16_t totalFrames = animState.current->getFrameCount();
|
||||
uint16_t framesPlayed = currentTick - animState.startFrame;
|
||||
uint16_t remainingFrames = (totalFrames > animState.startFrame) ? (totalFrames - animState.startFrame) : 0;
|
||||
|
||||
// Debug: log completion check near the end
|
||||
if (remainingFrames > 0 && framesPlayed >= remainingFrames - 1) {
|
||||
sendMessage("Completion check - currentTick: " + String(currentTick) + ", framesPlayed: " + String(framesPlayed) + ", remainingFrames: " + String(remainingFrames) + ", totalFrames: " + String(totalFrames));
|
||||
}
|
||||
|
||||
// Check if we've played all remaining frames (from startFrame to totalFrames-1)
|
||||
if (totalFrames > 0 && remainingFrames > 0 && framesPlayed >= remainingFrames) {
|
||||
sendMessage("Animation completion triggered! Sending completion packet.");
|
||||
switch (animState.playMode) {
|
||||
case PLAY_ONCE:
|
||||
animState.stop();
|
||||
{
|
||||
// Send completion packet BEFORE stopping animation
|
||||
uint8_t done[4];
|
||||
done[0] = currentTick & 0xFF;
|
||||
done[1] = (currentTick >> 8) & 0xFF;
|
||||
done[2] = static_cast<uint8_t>(animState.playMode);
|
||||
done[3] = 1; // complete
|
||||
//sendPacket(Tag::FRAME, done, 4);
|
||||
sendPacket(Tag::FRAME, done, 4);
|
||||
animState.stop();
|
||||
}
|
||||
break;
|
||||
case PLAY_LOOP:
|
||||
// Reset to start frame for seamless looping
|
||||
currentTick = animState.startFrame;
|
||||
break;
|
||||
case PLAY_REPEAT:
|
||||
if (--animState.repeatsRemaining == 0) {
|
||||
animState.stop();
|
||||
// Send completion packet BEFORE stopping animation
|
||||
uint8_t done[4];
|
||||
done[0] = currentTick & 0xFF;
|
||||
done[1] = (currentTick >> 8) & 0xFF;
|
||||
done[2] = static_cast<uint8_t>(animState.playMode);
|
||||
done[3] = 1; // complete
|
||||
//sendPacket(Tag::FRAME, done, 4);
|
||||
sendPacket(Tag::FRAME, done, 4);
|
||||
animState.stop();
|
||||
} else {
|
||||
currentTick = animState.startFrame;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue