Skip to content

Commit 7b645b7

Browse files
authored
Merge pull request #667 from alrvid/alrvid/camera-sync-fix
Fix a synchronization bug
2 parents f10a895 + f899032 commit 7b645b7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

libraries/Camera/examples/CameraCaptureRawBytes/CameraCaptureRawBytes.ino

+8-3
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ void loop() {
6464
while(!Serial);
6565
}
6666

67-
// Time out after 2 seconds and send new data
67+
// Time out after 2 seconds, which sets the (constant) frame rate
6868
bool timeoutDetected = millis() - lastUpdate > 2000;
6969

70-
// Wait for sync byte.
71-
if(!timeoutDetected && Serial.read() != 1) return;
70+
// Wait for sync byte and timeout
71+
// Notice that this order must be kept, or the sync bytes will be
72+
// consumed prematurely
73+
if ((!timeoutDetected) || (Serial.read() != 1))
74+
{
75+
return;
76+
}
7277

7378
lastUpdate = millis();
7479

0 commit comments

Comments
 (0)