We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ee49989 commit b9feb3dCopy full SHA for b9feb3d
libraries/Portenta_Camera/extras/CameraRawBytesVisualizer/CameraRawBytesVisualizer.pde
@@ -21,6 +21,7 @@ final int bytesPerFrame = cameraPixelCount * cameraBytesPerPixel;
21
22
PImage myImage;
23
byte[] frameBuffer = new byte[bytesPerFrame];
24
+int lastUpdate = 0;
25
26
void setup() {
27
size(640, 480);
@@ -46,9 +47,16 @@ void draw() {
46
47
PImage img = myImage.copy();
48
img.resize(640, 480);
49
image(img, 0, 0);
50
+ // Time out after 1.5 seconds and ask for new data
51
+ if(millis() - lastUpdate > 1500) {
52
+ println("Connection timed out.");
53
+ myPort.write(1);
54
+ }
55
}
56
57
void serialEvent(Serial myPort) {
58
+ lastUpdate = millis();
59
+
60
// read the received bytes
61
myPort.readBytes(frameBuffer);
62
0 commit comments