Skip to content

Commit cb06a62

Browse files
committed
misc processing examples updates
1 parent 046c222 commit cb06a62

17 files changed

Lines changed: 189 additions & 315 deletions

File tree

examples/osc/processing/sensors/apds9960/ambient_light_theater/ambient_light_theater.pde

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@ String ambientPath = "/opendeck/sensors/apds9960/ambient_light";
1616
float ambient = 0.0;
1717
float visualAmbient = 0.0;
1818
int lastPacketMs = 0;
19-
int packetCount = 0;
2019
boolean receivedData = false;
2120

2221
ArrayList<Dust> dust = new ArrayList<Dust>();
2322

2423
void setup() {
25-
size(1200, 900, P2D);
24+
size(2560, 1600, P2D);
2625
surface.setTitle("OpenDeck APDS9960 Ambient Light Theater");
2726

2827
oscP5 = new OscP5(this, oscListenPort);
29-
textFont(createFont("SansSerif", 18));
28+
textFont(createFont("SansSerif", 24));
3029

3130
for (int i = 0; i < 220; i++) {
3231
dust.add(new Dust());
@@ -117,10 +116,10 @@ void drawDust() {
117116
}
118117

119118
void drawMeter() {
120-
float x = 54;
121-
float y = height - 90;
122-
float w = width - 108;
123-
float h = 24;
119+
float x = 40;
120+
float y = 150;
121+
float w = 760;
122+
float h = 30;
124123

125124
noStroke();
126125
fill(28, 30, 36);
@@ -136,32 +135,18 @@ void drawMeter() {
136135

137136
fill(245);
138137
textAlign(LEFT, BOTTOM);
139-
textSize(18);
138+
textSize(24);
140139
text("ambient light " + nf(ambient, 1, 3), x, y - 10);
141140
}
142141

143142
void drawHud() {
144143
fill(245);
145144
textAlign(LEFT, TOP);
146-
textSize(22);
147-
text("APDS9960 ambient light theater", 40, 36);
145+
textSize(32);
146+
text("APDS9960 ambient light theater", 40, 40);
148147

149-
textSize(18);
150-
text("Status: " + statusText(), 40, 72);
151-
text("Packets: " + packetCount, 40, 102);
152-
text("OSC: " + ambientPath, 40, 132);
153-
}
154-
155-
String statusText() {
156-
if (!receivedData) {
157-
return "waiting for OSC";
158-
}
159-
160-
if (millis() - lastPacketMs > 1600) {
161-
return "stale";
162-
}
163-
164-
return "receiving OSC";
148+
textSize(24);
149+
text("OSC: " + ambientPath, 40, 86);
165150
}
166151

167152
void oscEvent(OscMessage message) {
@@ -183,7 +168,6 @@ void oscEvent(OscMessage message) {
183168

184169
receivedData = true;
185170
lastPacketMs = millis();
186-
packetCount++;
187171
}
188172

189173
class Dust {

examples/osc/processing/sensors/apds9960/color_studio/color_studio.pde

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@ float visualRed = 0.0;
2020
float visualGreen = 0.0;
2121
float visualBlue = 0.0;
2222
int lastPacketMs = 0;
23-
int packetCount = 0;
2423
boolean receivedData = false;
2524

2625
ArrayList<ColorChip> history = new ArrayList<ColorChip>();
2726

2827
void setup() {
29-
size(1200, 900, P2D);
28+
size(2560, 1600, P2D);
3029
surface.setTitle("OpenDeck APDS9960 Color Studio");
3130

3231
oscP5 = new OscP5(this, oscListenPort);
33-
textFont(createFont("SansSerif", 18));
32+
textFont(createFont("SansSerif", 24));
3433
}
3534

3635
void draw() {
@@ -82,7 +81,7 @@ void drawSwatch() {
8281

8382
fill(contrastColor(sensed));
8483
textAlign(CENTER, CENTER);
85-
textSize(26);
84+
textSize(35);
8685
text(rgbLabel(), cx, cy + size * 0.39);
8786
}
8887

@@ -101,7 +100,7 @@ void drawChannels() {
101100
void drawChannel(String label, float value, int channelColor, float x, float y, float w, float h) {
102101
fill(245);
103102
textAlign(LEFT, CENTER);
104-
textSize(18);
103+
textSize(24);
105104
text(label, x - 30, y + h / 2.0);
106105

107106
noStroke();
@@ -123,7 +122,7 @@ void drawHistory() {
123122

124123
fill(245);
125124
textAlign(LEFT, CENTER);
126-
textSize(18);
125+
textSize(24);
127126
text("recent", x, y - 38);
128127

129128
for (int i = 0; i < history.size(); i++) {
@@ -144,25 +143,11 @@ void drawHistory() {
144143
void drawHud() {
145144
fill(245);
146145
textAlign(LEFT, TOP);
147-
textSize(22);
148-
text("APDS9960 color studio", 40, 36);
146+
textSize(32);
147+
text("APDS9960 color studio", 40, 40);
149148

150-
textSize(18);
151-
text("Status: " + statusText(), 40, 72);
152-
text("Packets: " + packetCount, 40, 102);
153-
text("OSC: " + rgbPath, 40, 132);
154-
}
155-
156-
String statusText() {
157-
if (!receivedData) {
158-
return "waiting for OSC";
159-
}
160-
161-
if (millis() - lastPacketMs > 1600) {
162-
return "stale";
163-
}
164-
165-
return "receiving OSC";
149+
textSize(24);
150+
text("OSC: " + rgbPath, 40, 86);
166151
}
167152

168153
String rgbLabel() {
@@ -197,7 +182,6 @@ void oscEvent(OscMessage message) {
197182

198183
receivedData = true;
199184
lastPacketMs = millis();
200-
packetCount++;
201185

202186
if (history.size() == 0 || colorDistance(history.get(0).c, sensedColor(redValue, greenValue, blueValue)) > 18) {
203187
history.add(0, new ColorChip(sensedColor(redValue, greenValue, blueValue)));

examples/osc/processing/sensors/apds9960/gesture_swipe_pad/gesture_swipe_pad.pde

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ String gesturePath = "/opendeck/sensors/apds9960/gesture";
1515

1616
String lastGesture = "";
1717
int lastPacketMs = 0;
18-
int packetCount = 0;
1918
boolean receivedData = false;
2019

2120
ArrayList<Card> cards = new ArrayList<Card>();
@@ -29,11 +28,11 @@ float outgoingProgress = 1.0;
2928
int[] palette;
3029

3130
void setup() {
32-
size(1200, 900, P2D);
31+
size(2560, 1600, P2D);
3332
surface.setTitle("OpenDeck APDS9960 Card Swipe");
3433

3534
oscP5 = new OscP5(this, oscListenPort);
36-
textFont(createFont("SansSerif", 18));
35+
textFont(createFont("SansSerif", 24));
3736

3837
palette = new int[] {
3938
color(36, 145, 212),
@@ -99,7 +98,7 @@ void drawDirectionHints() {
9998
fill(255, 120);
10099
noStroke();
101100
textAlign(CENTER, CENTER);
102-
textSize(16);
101+
textSize(22);
103102
text("up", cx, cy - cardH / 2.0 - 58);
104103
text("down", cx, cy + cardH / 2.0 + 58);
105104
text("left", cx - cardW / 2.0 - 70, cy);
@@ -165,7 +164,7 @@ void drawHistory() {
165164

166165
fill(245);
167166
textAlign(LEFT, TOP);
168-
textSize(18);
167+
textSize(24);
169168
text("history", x, y - 34);
170169

171170
for (int i = 0; i < history.size(); i++) {
@@ -178,26 +177,12 @@ void drawHistory() {
178177
void drawHud() {
179178
fill(245);
180179
textAlign(LEFT, TOP);
181-
textSize(22);
182-
text("APDS9960 card swipe", 40, 36);
183-
184-
textSize(18);
185-
text("Status: " + statusText(), 40, 72);
186-
text("Packets: " + packetCount, 40, 102);
187-
text("Last: " + (lastGesture.length() == 0 ? "-" : lastGesture), 40, 132);
188-
text("OSC: " + gesturePath, 40, 162);
189-
}
190-
191-
String statusText() {
192-
if (!receivedData) {
193-
return "waiting for OSC";
194-
}
195-
196-
if (millis() - lastPacketMs > 1800) {
197-
return "stale";
198-
}
180+
textSize(32);
181+
text("APDS9960 card swipe", 40, 40);
199182

200-
return "receiving OSC";
183+
textSize(24);
184+
text("Last: " + (lastGesture.length() == 0 ? "-" : lastGesture), 40, 86);
185+
text("OSC: " + gesturePath, 40, 122);
201186
}
202187

203188
void oscEvent(OscMessage message) {
@@ -222,7 +207,6 @@ void handleGesture(String gesture) {
222207
lastGesture = gesture;
223208
receivedData = true;
224209
lastPacketMs = millis();
225-
packetCount++;
226210

227211
if (outgoingCard == null && cards.size() > 0) {
228212
outgoingCard = cards.get(0);

examples/osc/processing/sensors/apds9960/proximity_bloom/proximity_bloom.pde

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ String proximityPath = "/opendeck/sensors/apds9960/proximity";
1515

1616
int proximity = 0;
1717
int lastPacketMs = 0;
18-
int packetCount = 0;
1918
boolean receivedData = false;
2019

2120
float visualProximity = 0.0;
@@ -26,11 +25,11 @@ ArrayList<Spark> sparks = new ArrayList<Spark>();
2625
int maxSparks = 180;
2726

2827
void setup() {
29-
size(1200, 900, P2D);
28+
size(2560, 1600, P2D);
3029
surface.setTitle("OpenDeck APDS9960 Proximity Bloom");
3130

3231
oscP5 = new OscP5(this, oscListenPort);
33-
textFont(createFont("SansSerif", 18));
32+
textFont(createFont("SansSerif", 24));
3433

3534
for (int i = 0; i < maxSparks; i++) {
3635
sparks.add(new Spark());
@@ -137,10 +136,10 @@ void drawSparks() {
137136
}
138137

139138
void drawMeter() {
140-
float x = 54;
141-
float y = height - 90;
142-
float w = width - 108;
143-
float h = 24;
139+
float x = 40;
140+
float y = 150;
141+
float w = 760;
142+
float h = 30;
144143

145144
noStroke();
146145
fill(32);
@@ -156,32 +155,18 @@ void drawMeter() {
156155

157156
fill(235);
158157
textAlign(LEFT, BOTTOM);
159-
textSize(18);
158+
textSize(24);
160159
text("proximity " + proximity + " / 255", x, y - 10);
161160
}
162161

163162
void drawHud() {
164163
fill(245);
165164
textAlign(LEFT, TOP);
166-
textSize(22);
167-
text("APDS9960 proximity bloom", 40, 38);
165+
textSize(32);
166+
text("APDS9960 proximity bloom", 40, 40);
168167

169-
textSize(18);
170-
text("Status: " + statusText(), 40, 72);
171-
text("Packets: " + packetCount, 40, 102);
172-
text("OSC: " + proximityPath, 40, 132);
173-
}
174-
175-
String statusText() {
176-
if (!receivedData) {
177-
return "waiting for OSC";
178-
}
179-
180-
if (millis() - lastPacketMs > 1200) {
181-
return "stale";
182-
}
183-
184-
return "receiving OSC";
168+
textSize(24);
169+
text("OSC: " + proximityPath, 40, 86);
185170
}
186171

187172
void oscEvent(OscMessage message) {
@@ -203,7 +188,6 @@ void oscEvent(OscMessage message) {
203188

204189
receivedData = true;
205190
lastPacketMs = millis();
206-
packetCount++;
207191
}
208192

209193
class Spark {

examples/osc/processing/sensors/bno085/gravity_visualizer/gravity_visualizer.pde

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ ArrayList<PVector> trail = new ArrayList<PVector>();
3333
int maxTrailPoints = 220;
3434

3535
void setup() {
36-
size(1200, 900, P3D);
36+
size(2560, 1600, P3D);
3737
surface.setTitle("OpenDeck BNO085 Gravity Visualizer");
3838

3939
oscP5 = new OscP5(this, oscListenPort);
40-
textFont(createFont("SansSerif", 18));
40+
textFont(createFont("SansSerif", 24));
4141
}
4242

4343
void draw() {
@@ -189,24 +189,24 @@ void drawHud() {
189189

190190
fill(238);
191191
textAlign(LEFT, TOP);
192-
textSize(20);
192+
textSize(32);
193193

194-
String status = receivedData ? "receiving OSC" : "waiting for OSC on port " + oscListenPort;
195194
float magnitude = sqrt((gravityX * gravityX) + (gravityY * gravityY) + (gravityZ * gravityZ));
196195

197-
text("BNO085 gravity visualizer", 38, 34);
198-
text("Status: " + status, 38, 66);
199-
text("Gravity: x " + nf(gravityX, 0, 3) + " y " + nf(gravityY, 0, 3) + " z " + nf(gravityZ, 0, 3), 38, 98);
200-
text("Magnitude: " + nf(magnitude, 0, 3), 38, 130);
201-
text("Keys: t trail, r reset view, +/- zoom", 38, height - 52);
196+
text("BNO085 gravity visualizer", 40, 40);
197+
198+
textSize(24);
199+
text("Gravity: x " + nf(gravityX, 0, 3) + " y " + nf(gravityY, 0, 3) + " z " + nf(gravityZ, 0, 3), 40, 86);
200+
text("Magnitude: " + nf(magnitude, 0, 3), 40, 122);
201+
text("Keys: t trail, r reset view, +/- zoom", 40, 158);
202202

203203
drawComponentMeter(width - 280, 50, "X", gravityX, color(255, 70, 70));
204204
drawComponentMeter(width - 200, 50, "Y", gravityY, color(70, 220, 130));
205205
drawComponentMeter(width - 120, 50, "Z", gravityZ, color(80, 150, 255));
206206

207207
if (millis() - lastPacketMs > 2000) {
208208
fill(255, 190, 40);
209-
text("Enable BNO085 Gravity output in OpenDeck.", 38, 164);
209+
text("Enable BNO085 Gravity output in OpenDeck.", 40, 194);
210210
}
211211

212212
hint(ENABLE_DEPTH_TEST);
@@ -236,7 +236,7 @@ void drawComponentMeter(float x, float y, String label, float value, color c) {
236236

237237
fill(235);
238238
textAlign(CENTER, TOP);
239-
textSize(16);
239+
textSize(22);
240240
text(label, x + 21, y + h + 10);
241241
}
242242

0 commit comments

Comments
 (0)