Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BufferedSerial FatFileSystemCpp mbed
Diff: main.cpp
- Revision:
- 7:87aea27cc68b
- Parent:
- 6:61274e214f46
- Child:
- 8:961bb15570a1
--- a/main.cpp Tue Feb 09 16:55:52 2021 +0000 +++ b/main.cpp Fri Feb 12 14:24:55 2021 +0000 @@ -243,7 +243,7 @@ } if (PPMTrackIndex == _longPPMTrackLen_) PPMTrackIndex = 0; - printf("Frame rate detected as %s. My clock is %.4f ppm fast\r\n", detectedRate.frameRateString(), PPMHighAcc); + // printf("Frame rate detected as %s. My clock is %.4f ppm fast\r\n", detectedRate.frameRateString(), PPMHighAcc); } else { printf("Frame rate unclear\r\n"); PPMHighAcc=0; @@ -272,7 +272,7 @@ bool dropFrame, uint32_t frameStartTime) { static int lastFrame = 0; - static float ppmError; + static float ppmError=0; static int outCount = 0; if ((frame != (lastFrame + 1)) && detectedRate.currentRate()) { long timeSinceSecondStart = detectedRate.getOffsetFromSecondStart(minutes, seconds, frame); @@ -327,29 +327,32 @@ static int outCount = 0; uint32_t patternStartTime; if (detectedRate.isValid()) { - uint32_t ThisSecondStart = frameStartTime ; if (!ppsRunning) { - uint32_t pulseStartTime = frameStartTime + (int)(detectedRate.currentPeriodUS()*5+0.5f); - uint32_t timeTillStart = pulseStartTime - inputTimer.read_us(); - ppsRunning = true; - __disable_irq(); - PPSsyncTimer.attach_us(callback(OnPPSCync), timeTillStart); - __enable_irq(); - printf("PPS start scheduled for %0.3f seconds.\r\n", - timeTillStart / 1000000.0f); - VBOXTicks = 0; - outCount = 0; + LTCInput.readWaitingData(); + if (outCount<20) { + outCount++; + } else { + const LTCDecode::LTCData_t *frameData = LTCInput.getLastFrame(); + detectedRate.setDrop(frameData->frameDrop); + uint32_t ThisSecondStart = frameStartTime - detectedRate.getOffsetFromSecondStart(frameData->minutes, frameData->seconds, frameData->frame); + uint32_t nextSecondStart = ThisSecondStart + 1000000; + ppsRunning = true; + __disable_irq(); + uint32_t nextSec = nextSecondStart - inputTimer.read_us(); + PPSsyncTimer.attach_us(callback(OnPPSCync), nextSec); + __enable_irq(); + printf("PPS start scheduled for %0.3f seconds.\r\n", nextSec / 1000000.0f); + + VBOXTicks = (frameData->hours * 3600 + frameData->minutes * 60 + (frameData->seconds + 1)) * 100; + LTCInput.disable(); + } } else { -// if (outCount == 0) -// patternStartTime = inputTimer.elapsed_time(); -// else { -// expectedTotalUS = outCount -// } + framePositionOutput(); } } - // frame rate and clock error calculation + +// frame rate and clock error calculation frameRateMeasure(frameStartTime, false); - framePositionOutput(); } volatile bool NewFramePulse= false; @@ -430,7 +433,7 @@ pc.printf("%s\r\n",VIPSStatusMessages[message-1]); } - if (GenLockOnlyMode) { + if (true) { // GenLockOnlyMode) { if (GenLockToSync) { pc.printf("No LTC detected for 100 frames. Falling back to genlock on sync input\r\n"); Syncin.rise(callback(&OnPPFInput)); @@ -443,6 +446,9 @@ uint32_t lastframeTime = inputTimer.read_us(); while (true) { + if (!ppsRunning) + LTCInput.readWaitingData(); + if (NewFramePulse) { // running on a frame // printf("frame\r"); lastframeTime = FramePulseTime;