Skip to content

Commit 4d5f33c

Browse files
8bitkickfacchinm
authored andcommitted
Sliding delay window for different VSYNC effects
1 parent fb5383a commit 4d5f33c

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

examples/ConnectionTest/ConnectionTest.ino

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
int bytesPerFrame;
3434
int errors = 0;
3535
int count = 0;
36+
int bestTime = 100000;
37+
int worstTime = 0;
38+
int delayTime = 300;
39+
40+
3641
long timer = 0;
3742
Arduino_CRC32 crc32;
3843

@@ -56,31 +61,35 @@ void setup() {
5661
}
5762

5863
void loop() {
64+
65+
// sliding delay window to try different start times wrt camera VSYNC
66+
if (delayTime>0) {delayTime=delayTime-10;}
67+
delay(delayTime);
5968

6069
// benchmarking
6170
timer = millis();
6271
Camera.readFrame(data);
6372
timer = millis() - timer;
64-
Serial.print(timer);
65-
Serial.println("ms ");
66-
67-
// error checking
68-
if (error_checking) {
69-
uint32_t const crc32_res = crc32.calc(data, bytesPerFrame);
70-
71-
Serial.print("0x");
72-
Serial.print(crc32_res, HEX);
73+
// Check if it is a best case or worse case time
74+
bestTime = min(timer, bestTime);
75+
worstTime = max(timer, worstTime);
7376

7477
// Test against known checksum values (minor pixel variations at the start but were visually confirmed to be a good test pattern)
78+
uint32_t const crc32_res = crc32.calc(data, bytesPerFrame);
7579
if (crc32_res != 0x15AB2939 && crc32_res != 0xD3EC95E && crc32_res != 0xB9C43ED9) {
7680
errors++;
7781
};
7882

7983
count++;
84+
8085
Serial.print(" errors:");
8186
Serial.print(errors);
8287
Serial.print("/");
83-
Serial.println(count);
84-
}
85-
88+
Serial.print(count);
89+
Serial.print(" best:");
90+
Serial.print(bestTime);
91+
Serial.print("ms worst:");
92+
Serial.print(worstTime);
93+
Serial.println("ms");
94+
8695
}

0 commit comments

Comments
 (0)