Skip to content

Commit ee49989

Browse files
committed
Remove unnecessary check
1 parent 198d296 commit ee49989

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

libraries/Portenta_Camera/extras/CameraRawBytesVisualizer/CameraRawBytesVisualizer.pde

+9-14
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ final int bytesPerFrame = cameraPixelCount * cameraBytesPerPixel;
2222
PImage myImage;
2323
byte[] frameBuffer = new byte[bytesPerFrame];
2424

25-
void setup()
26-
{
25+
void setup() {
2726
size(640, 480);
2827

2928
// if you have only ONE serial port active
@@ -43,15 +42,14 @@ void setup()
4342
myPort.write(1);
4443
}
4544

46-
void draw()
47-
{
45+
void draw() {
4846
PImage img = myImage.copy();
4947
img.resize(640, 480);
5048
image(img, 0, 0);
5149
}
5250

5351
void serialEvent(Serial myPort) {
54-
// read the saw bytes in
52+
// read the received bytes
5553
myPort.readBytes(frameBuffer);
5654

5755
// access raw bytes via byte buffer
@@ -62,17 +60,14 @@ void serialEvent(Serial myPort) {
6260

6361
while (bb.hasRemaining()) {
6462
// read 16-bit pixel
65-
byte p = bb.get();
66-
63+
byte pixelValue = bb.get();
6764

6865
// set pixel color
69-
myImage .pixels[i++] = color(Byte.toUnsignedInt(p));
70-
71-
// Let the Arduino sketch know we received all pixels
72-
// and are ready for the next frame
73-
if(i == cameraPixelCount){
74-
myPort.write(1);
75-
}
66+
myImage.pixels[i++] = color(Byte.toUnsignedInt(pixelValue));
7667
}
68+
7769
myImage.updatePixels();
70+
// Let the Arduino sketch know we received all pixels
71+
// and are ready for the next frame
72+
myPort.write(1);
7873
}

0 commit comments

Comments
 (0)