Skip to content

Commit abc9a89

Browse files
per1234cmaglie
authored andcommitted
Use consistent formatting style for Processing code included in built-in example comments
1 parent 18b5327 commit abc9a89

File tree

7 files changed

+100
-102
lines changed

7 files changed

+100
-102
lines changed

build/shared/examples/04.Communication/Dimmer/Dimmer.ino

+23-20
Original file line numberDiff line numberDiff line change
@@ -42,42 +42,45 @@ void loop() {
4242
}
4343

4444
/* Processing code for this example
45+
4546
// Dimmer - sends bytes over a serial port
47+
4648
// by David A. Mellis
4749
// This example code is in the public domain.
4850
4951
import processing.serial.*;
5052
Serial port;
5153
5254
void setup() {
53-
size(256, 150);
55+
size(256, 150);
5456
55-
println("Available serial ports:");
56-
// if using Processing 2.1 or later, use Serial.printArray()
57-
println(Serial.list());
57+
println("Available serial ports:");
58+
// if using Processing 2.1 or later, use Serial.printArray()
59+
println(Serial.list());
5860
59-
// Uses the first port in this list (number 0). Change this to select the port
60-
// corresponding to your Arduino board. The last parameter (e.g. 9600) is the
61-
// speed of the communication. It has to correspond to the value passed to
62-
// Serial.begin() in your Arduino sketch.
63-
port = new Serial(this, Serial.list()[0], 9600);
61+
// Uses the first port in this list (number 0). Change this to select the port
62+
// corresponding to your Arduino board. The last parameter (e.g. 9600) is the
63+
// speed of the communication. It has to correspond to the value passed to
64+
// Serial.begin() in your Arduino sketch.
65+
port = new Serial(this, Serial.list()[0], 9600);
6466
65-
// If you know the name of the port used by the Arduino board, you can specify
66-
// it directly like this.
67-
//port = new Serial(this, "COM1", 9600);
67+
// If you know the name of the port used by the Arduino board, you can specify
68+
// it directly like this.
69+
//port = new Serial(this, "COM1", 9600);
6870
}
6971
7072
void draw() {
71-
// draw a gradient from black to white
72-
for (int i = 0; i < 256; i++) {
73-
stroke(i);
74-
line(i, 0, i, 150);
73+
// draw a gradient from black to white
74+
for (int i = 0; i < 256; i++) {
75+
stroke(i);
76+
line(i, 0, i, 150);
77+
}
78+
79+
// write the current X-position of the mouse to the serial port as
80+
// a single byte
81+
port.write(mouseX);
7582
}
7683
77-
// write the current X-position of the mouse to the serial port as
78-
// a single byte
79-
port.write(mouseX);
80-
}
8184
*/
8285

8386
/* Max/MSP v5 patch for this example

build/shared/examples/04.Communication/Graph/Graph.ino

+3-4
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ void loop() {
4242
4343
// Graphing sketch
4444
45-
4645
// This program takes ASCII-encoded strings from the serial port at 9600 baud
4746
// and graphs them. It expects values in the range 0 to 1023, followed by a
4847
// newline, or newline and carriage return
4948
50-
// Created 20 Apr 2005
51-
// Updated 24 Nov 2015
49+
// created 20 Apr 2005
50+
// updated 24 Nov 2015
5251
// by Tom Igoe
5352
// This example code is in the public domain.
5453
@@ -77,6 +76,7 @@ void loop() {
7776
// set initial background:
7877
background(0);
7978
}
79+
8080
void draw () {
8181
// draw the line:
8282
stroke(127, 34, 255);
@@ -92,7 +92,6 @@ void loop() {
9292
}
9393
}
9494
95-
9695
void serialEvent (Serial myPort) {
9796
// get the ASCII string:
9897
String inString = myPort.readStringUntil('\n');

build/shared/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino

+39-44
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void loop() {
4949

5050
/* Processing code for this example
5151
52-
// mouse over serial
52+
// Mouse over serial
5353
5454
// Demonstrates how to send data to the Arduino I/O board, in order to turn ON
5555
// a light if the mouse is over a square and turn it off if the mouse is not.
@@ -60,8 +60,6 @@ void loop() {
6060
// by Tom Igoe
6161
// This example code is in the public domain.
6262
63-
64-
6563
import processing.serial.*;
6664
6765
float boxX;
@@ -72,52 +70,49 @@ void loop() {
7270
Serial port;
7371
7472
void setup() {
75-
size(200, 200);
76-
boxX = width/2.0;
77-
boxY = height/2.0;
78-
rectMode(RADIUS);
79-
80-
// List all the available serial ports in the output pane.
81-
// You will need to choose the port that the Arduino board is connected to
82-
// from this list. The first port in the list is port #0 and the third port
83-
// in the list is port #2.
84-
// if using Processing 2.1 or later, use Serial.printArray()
85-
println(Serial.list());
86-
87-
// Open the port that the Arduino board is connected to (in this case #0)
88-
// Make sure to open the port at the same speed Arduino is using (9600bps)
89-
port = new Serial(this, Serial.list()[0], 9600);
90-
73+
size(200, 200);
74+
boxX = width / 2.0;
75+
boxY = height / 2.0;
76+
rectMode(RADIUS);
77+
78+
// List all the available serial ports in the output pane.
79+
// You will need to choose the port that the Arduino board is connected to
80+
// from this list. The first port in the list is port #0 and the third port
81+
// in the list is port #2.
82+
// if using Processing 2.1 or later, use Serial.printArray()
83+
println(Serial.list());
84+
85+
// Open the port that the Arduino board is connected to (in this case #0)
86+
// Make sure to open the port at the same speed Arduino is using (9600bps)
87+
port = new Serial(this, Serial.list()[0], 9600);
9188
}
9289
93-
void draw()
94-
{
95-
background(0);
96-
97-
// Test if the cursor is over the box
98-
if (mouseX > boxX-boxSize && mouseX < boxX+boxSize &&
99-
mouseY > boxY-boxSize && mouseY < boxY+boxSize) {
100-
mouseOverBox = true;
101-
// draw a line around the box and change its color:
102-
stroke(255);
103-
fill(153);
104-
// send an 'H' to indicate mouse is over square:
105-
port.write('H');
106-
}
107-
else {
108-
// return the box to its inactive state:
109-
stroke(153);
110-
fill(153);
111-
// send an 'L' to turn the LED off:
112-
port.write('L');
113-
mouseOverBox = false;
114-
}
90+
void draw() {
91+
background(0);
92+
93+
// Test if the cursor is over the box
94+
if (mouseX > boxX - boxSize && mouseX < boxX + boxSize &&
95+
mouseY > boxY - boxSize && mouseY < boxY + boxSize) {
96+
mouseOverBox = true;
97+
// draw a line around the box and change its color:
98+
stroke(255);
99+
fill(153);
100+
// send an 'H' to indicate mouse is over square:
101+
port.write('H');
102+
}
103+
else {
104+
// return the box to its inactive state:
105+
stroke(153);
106+
fill(153);
107+
// send an 'L' to turn the LED off:
108+
port.write('L');
109+
mouseOverBox = false;
110+
}
115111
116-
// Draw the box
117-
rect(boxX, boxY, boxSize, boxSize);
112+
// Draw the box
113+
rect(boxX, boxY, boxSize, boxSize);
118114
}
119115
120-
121116
*/
122117

123118
/*

build/shared/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino

+7-7
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,27 @@ void establishContact() {
6464
}
6565
}
6666

67-
/*
68-
Processing sketch to run with this example:
67+
/* Processing sketch to run with this example:
6968
7069
// This example code is in the public domain.
7170
7271
import processing.serial.*;
7372
74-
int bgcolor; // Background color
75-
int fgcolor; // Fill color
73+
int bgcolor; // Background color
74+
int fgcolor; // Fill color
7675
Serial myPort; // The serial port
7776
int[] serialInArray = new int[3]; // Where we'll put what we receive
7877
int serialCount = 0; // A count of how many bytes we receive
79-
int xpos, ypos; // Starting position of the ball
78+
int xpos, ypos; // Starting position of the ball
8079
boolean firstContact = false; // Whether we've heard from the microcontroller
8180
8281
void setup() {
8382
size(256, 256); // Stage size
8483
noStroke(); // No border on the next thing drawn
8584
8685
// Set the starting position of the ball (middle of the stage)
87-
xpos = width/2;
88-
ypos = height/2;
86+
xpos = width / 2;
87+
ypos = height / 2;
8988
9089
// Print a list of the serial ports for debugging purposes
9190
// if using Processing 2.1 or later, use Serial.printArray()
@@ -140,6 +139,7 @@ void establishContact() {
140139
}
141140
}
142141
}
142+
143143
*/
144144

145145
/*

build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino

+24-26
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,22 @@ void establishContact() {
6666
}
6767
}
6868

69-
70-
/*
71-
Processing code to run with this example:
69+
/* Processing code to run with this example:
7270
7371
// This example code is in the public domain.
7472
7573
import processing.serial.*; // import the Processing serial library
7674
Serial myPort; // The serial port
7775
78-
float bgcolor; // Background color
79-
float fgcolor; // Fill color
80-
float xpos, ypos; // Starting position of the ball
76+
float bgcolor; // Background color
77+
float fgcolor; // Fill color
78+
float xpos, ypos; // Starting position of the ball
8179
8280
void setup() {
83-
size(640,480);
81+
size(640, 480);
8482
8583
// List all the available serial ports
86-
// if using Processing 2.1 or later, use Serial.printArray()
84+
// if using Processing 2.1 or later, use Serial.printArray()
8785
println(Serial.list());
8886
8987
// I know that the first port in the serial list on my Mac is always my
@@ -114,25 +112,25 @@ void establishContact() {
114112
// read the serial buffer:
115113
String myString = myPort.readStringUntil('\n');
116114
// if you got any bytes other than the linefeed:
117-
myString = trim(myString);
118-
119-
// split the string at the commas and convert the sections into integers:
120-
int sensors[] = int(split(myString, ','));
121-
122-
// print out the values you got:
123-
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
124-
print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
125-
}
126-
// add a linefeed after all the sensor values are printed:
127-
println();
128-
if (sensors.length > 1) {
129-
xpos = map(sensors[0], 0,1023,0,width);
130-
ypos = map(sensors[1], 0,1023,0,height);
131-
fgcolor = sensors[2];
132-
}
133-
// send a byte to ask for more data:
134-
myPort.write("A");
115+
myString = trim(myString);
116+
117+
// split the string at the commas and convert the sections into integers:
118+
int sensors[] = int(split(myString, ','));
119+
120+
// print out the values you got:
121+
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
122+
print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
123+
}
124+
// add a linefeed after all the sensor values are printed:
125+
println();
126+
if (sensors.length > 1) {
127+
xpos = map(sensors[0], 0, 1023, 0, width);
128+
ypos = map(sensors[1], 0, 1023, 0, height);
129+
fgcolor = sensors[2];
135130
}
131+
// send a byte to ask for more data:
132+
myPort.write("A");
133+
}
136134
137135
*/
138136

build/shared/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void loop() {
7676
float[] colors = float(split(inString, ","));
7777
// if the array has at least three elements, you know you got the whole
7878
// thing. Put the numbers in the color variables:
79-
if (colors.length >=3) {
79+
if (colors.length >= 3) {
8080
// map them to the range 0-255:
8181
redValue = map(colors[0], 0, 1023, 0, 255);
8282
greenValue = map(colors[1], 0, 1023, 0, 255);

build/shared/examples/10.StarterKit_BasicKit/p14_TweakTheArduinoLogo/p14_TweakTheArduinoLogo.ino

+3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ void loop() {
3333
}
3434

3535
/* Processing code for this example
36+
3637
// Tweak the Arduino Logo
38+
3739
// by Scott Fitzgerald
3840
// This example code is in the public domain.
3941
@@ -95,4 +97,5 @@ void loop() {
9597
// draw the Arduino logo
9698
image(logo, 0, 0);
9799
}
100+
98101
*/

0 commit comments

Comments
 (0)