Skip to content

Commit

Permalink
Update Processing example.
Browse files Browse the repository at this point in the history
* Use faster baudrate.
* Upscale image to VGA for better viewing.
  • Loading branch information
iabdalkader committed Jan 15, 2021
1 parent 0bc3fa2 commit 13b1372
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import java.nio.ByteOrder;
Serial myPort;

// must match resolution used in the sketch
final int cameraWidth = 324;
final int cameraHeight = 244;
final int cameraWidth = 320;
final int cameraHeight = 240;
final int cameraBytesPerPixel = 1;
final int bytesPerFrame = cameraWidth * cameraHeight * cameraBytesPerPixel;

Expand All @@ -23,14 +23,14 @@ byte[] frameBuffer = new byte[bytesPerFrame];

void setup()
{
size(324, 244);
size(640, 480);

// if you have only ONE serial port active
//myPort = new Serial(this, Serial.list()[0], 9600); // if you have only ONE serial port active

// if you know the serial port name
//myPort = new Serial(this, "COM5", 9600); // Windows
myPort = new Serial(this, "/dev/ttyACM0", 9600); // Linux
myPort = new Serial(this, "/dev/ttyACM0", 921600); // Linux
//myPort = new Serial(this, "/dev/cu.usbmodem14401", 9600); // Mac

// wait for full frame of bytes
Expand All @@ -41,7 +41,9 @@ void setup()

void draw()
{
image(myImage, 0, 0);
PImage img = myImage.copy();
img.resize(640, 480);
image(img, 0, 0);
}

void serialEvent(Serial myPort) {
Expand Down

0 comments on commit 13b1372

Please sign in to comment.