aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Pd_firmware/Pd_firmware.pde79
-rw-r--r--arduino-help.pd213
-rw-r--r--arduino.pd39
3 files changed, 188 insertions, 143 deletions
diff --git a/Pd_firmware/Pd_firmware.pde b/Pd_firmware/Pd_firmware.pde
index ba93885..367a6e8 100644
--- a/Pd_firmware/Pd_firmware.pde
+++ b/Pd_firmware/Pd_firmware.pde
@@ -24,6 +24,15 @@
* 230 - next byte sets PWM0 value
* 231 - next byte sets PWM1 value
* 232 - next byte sets PWM2 value
+ * 238 - disable all digital inputs
+ * 239 - enable all digital inputs
+ * 240 - disable all analog inputs
+ * 241 - enable 1 analog input (0)
+ * 242 - enable 2 analog inputs (0,1)
+ * 243 - enable 3 analog inputs (0-2)
+ * 244 - enable 4 analog inputs (0-3)
+ * 245 - enable 5 analog inputs (0-4)
+ * 246 - enable 6 analog inputs (0-5)
*
* Pd->Arduino byte cycle
* ----------------------
@@ -83,6 +92,9 @@ int digitalPinStatus;
*/
int pwmStatus;
+boolean digitalInputsEnabled = true;
+byte analogInputsEnabled = 6;
+
byte analogPin;
int analogData;
@@ -105,6 +117,7 @@ void transmitDigitalInput(byte startPin) {
digitalData = 0; // pin set to PWM, don't read
}
else {
+ // TODO: get digital in working
// digitalData = digitalRead(digitalPin);
digitalData = pwmStatus;
}
@@ -151,15 +164,15 @@ void processInput(byte inputData) {
// the PWM commands (230-232) have a byte of data following the command
if (waitForPWMData > 0) {
- printByte(150);
- printByte(inputData);
+ // printByte(150);
+ // printByte(inputData);
analogWrite(waitForPWMData,inputData);
waitForPWMData = 0;
}
else if(inputData < 128) {
- printByte(151);
+ // printByte(151);
if(firstInputByte) {
- printByte(160);
+ // printByte(160);
for(i=0; i<7; ++i) {
mask = 1 << i;
//printByte(254);
@@ -173,7 +186,7 @@ void processInput(byte inputData) {
firstInputByte = false;
}
else {
- printByte(161);
+ // printByte(161);
// output data for pins 7-13
for(i=7; i<TOTAL_DIGITAL_PINS; ++i) {
mask = 1 << i;
@@ -189,8 +202,8 @@ void processInput(byte inputData) {
}
}
else {
- printByte(152);
- printByte(inputData);
+ // printByte(152);
+ // printByte(inputData);
switch (inputData) {
case 200:
case 201:
@@ -230,6 +243,21 @@ void processInput(byte inputData) {
waitForPWMData = inputData - 221; // set waitForPWMData to the PWM pin number
setPinMode(waitForPWMData, PWM);
break;
+ case 238:
+ digitalInputsEnabled = false;
+ break;
+ case 239:
+ digitalInputsEnabled = true;
+ break;
+ case 240:
+ case 241:
+ case 242:
+ case 243:
+ case 244:
+ case 245:
+ case 246:
+ analogInputsEnabled = inputData - 240;
+ break;
case 255:
firstInputByte = true;
break;
@@ -251,26 +279,33 @@ void setup() {
// -------------------------------------------------------------------------
void loop() {
- /*
- * get analog in
+ checkForInput();
+
+ // read all digital pins, in enabled
+ if(digitalInputsEnabled) {
+ transmitDigitalInput(0);
+ checkForInput();
+ transmitDigitalInput(7);
+ checkForInput();
+ }
+ else if(analogInputsEnabled) {
+ // filler bytes, since the first thing sent is always the digitalInputs
+ printByte(0);
+ printByte(0);
+ }
+
+ /* get analog in, for the number enabled
*/
- for(analogPin=0; analogPin<6; ++analogPin)
- {
+ for(analogPin=0; analogPin<analogInputsEnabled; ++analogPin) {
analogData = analogRead(analogPin);
// these two bytes get converted back into the whole number in Pd
printByte(analogData >> 7); // bitshift the big stuff into the output byte
printByte(analogData % 128); // mod by 32 for the small byte
+ checkForInput();
}
- // read all digital pins
- transmitDigitalInput(0);
- transmitDigitalInput(7);
-
- checkForInput();
-
- /* end with the cycle marker */
- printByte(255);
-
- // setPinMode(13,OUTPUT);
- // digitalWrite(13,HIGH);
+ /* end with the cycle marker, if any of the inputs are enabled */
+ if( digitalInputsEnabled || analogInputsEnabled) {
+ printByte(255);
+ }
}
diff --git a/arduino-help.pd b/arduino-help.pd
index 793bf9d..bbf0526 100644
--- a/arduino-help.pd
+++ b/arduino-help.pd
@@ -1,13 +1,12 @@
-#N canvas 386 0 642 596 10;
+#N canvas 374 0 654 608 10;
#X obj 478 -14 import cyclone zexy;
-#X text 295 191 On Mac OS X \, set this to the right value:;
#X msg 200 183 open \$1;
#N canvas 162 133 530 380 serin 0;
#X obj 120 61 cnv 15 15 15 empty \$0-number-canvas 2 4 7 0 14 -233017
-1 0;
#X obj 200 225 s \$0-number-canvas;
#X obj 60 61 hradio 15 1 0 4 empty empty empty 0 -6 0 8 -225271 -1
--1 2;
+-1 0;
#X obj 59 147 outlet;
#X obj 60 13 inlet;
#X msg 200 202 label \$1;
@@ -25,33 +24,32 @@
#X text 259 552 released under the GNU GPL;
#X text 45 537 (C) Copyright 2006 Hans-Christoph Steiner <hans@at.or.at>
;
-#X obj 6 370 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 14
--3754 -1 -1 490 256;
+#X obj 21 394 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+14 -3754 -1 -1 0 256;
#X msg 260 183 close;
-#X obj 68 489 print --------------------;
-#X msg 299 209 devicename /dev/tty.usbserial-1913;
-#X obj 489 258 spigot;
-#X obj 520 240 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+#X obj 83 513 print --------------------;
+#X obj 519 330 spigot;
+#X obj 550 312 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
-#X obj 486 283 select 255;
+#X obj 516 355 select 255;
#X obj 395 29 hradio 15 1 0 14 empty empty empty 0 -6 0 8 -262144 -1
--1 6;
-#X obj 372 30 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
+-1 0;
+#X obj 372 30 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 391 102 +;
#X obj 372 76 * 14;
#X obj 391 123 + 200;
#X floatatom 397 146 5 0 0 0 - - -;
#X obj 395 48 t b f;
-#X obj 508 315 tolist;
-#X obj 511 423 print;
-#X obj 511 404 list;
-#X obj 535 337 list-len;
-#X obj 535 357 change;
-#X obj 426 288 spigot;
-#X obj 459 270 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+#X obj 538 387 tolist;
+#X obj 541 495 print;
+#X obj 541 476 list;
+#X obj 565 409 list-len;
+#X obj 565 429 change;
+#X obj 456 360 spigot;
+#X obj 489 342 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
-#X obj 537 378 bang;
+#X obj 567 450 bang;
#N canvas 295 269 594 315 decode 0;
#X obj 241 26 inlet;
#X obj 46 189 & 1;
@@ -125,11 +123,11 @@
#X connect 26 0 15 0;
#X connect 27 0 16 0;
#X connect 28 0 17 0;
-#X restore 329 455 pd decode buttons;
+#X restore 344 479 pd decode buttons;
#X obj 57 10 hsl 128 15 0 1 0 0 empty empty PWM_control_(0-1) -2 -6
-1 10 -225271 -1 -1 4900 0;
-#X msg 67 449 bang;
-#X obj 235 237 arduino 3;
+1 10 -225271 -1 -1 0 0;
+#X msg 82 473 bang;
+#X obj 255 261 arduino 3;
#X floatatom 434 50 5 0 0 0 - - -;
#X text 504 2 7;
#X text 399 12 0;
@@ -147,7 +145,6 @@
#X obj 203 31 bng 35 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
-1;
#X obj 195 76 t b b;
-#X msg 219 95 2;
#X text 504 12 0;
#X text 547 13 3;
#X msg 13 249 231 \, 1 \, 223 \, 255 \, 0 \, 12;
@@ -158,84 +155,98 @@
#X obj 14 155 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X msg 114 116 230 \, 1 \, 231 \, 1 \, 220;
-#X obj 426 309 print;
-#X obj 202 290 spigot 0;
-#X obj 245 271 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
+#X obj 456 381 print;
+#X obj 217 314 spigot 0;
+#X obj 260 295 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
-#X obj 33 341 route analog0 analog1 analog2 analog3 analog4 analog5
+#X obj 48 365 route analog0 analog1 analog2 analog3 analog4 analog5
;
-#X obj 325 411 route digital;
-#X obj 398 431 print GARBAGE;
-#X obj 69 370 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+#X obj 340 435 route digital;
+#X obj 413 455 print GARBAGE;
+#X obj 84 394 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+14 -3754 -1 -1 0 256;
+#X obj 336 394 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
14 -3754 -1 -1 0 256;
-#X obj 321 370 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
-14 -3754 -1 -1 14 256;
-#X obj 258 370 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
-14 -3754 -1 -1 1 256;
-#X obj 195 370 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
-14 -3754 -1 -1 7 256;
-#X obj 132 370 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+#X obj 273 394 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
14 -3754 -1 -1 0 256;
-#X obj 203 313 speedlim 40;
-#X floatatom 272 467 6 0 0 0 - - -;
-#X connect 2 0 32 0;
-#X connect 3 0 2 0;
-#X connect 8 0 32 0;
-#X connect 10 0 32 0;
-#X connect 11 0 13 0;
-#X connect 12 0 11 1;
-#X connect 13 0 21 1;
-#X connect 13 1 21 0;
-#X connect 14 0 20 0;
-#X connect 14 0 33 0;
-#X connect 15 0 17 0;
-#X connect 16 0 18 0;
-#X connect 17 0 16 0;
-#X connect 18 0 19 0;
-#X connect 18 0 32 0;
-#X connect 20 0 17 0;
-#X connect 20 1 16 1;
-#X connect 21 0 23 1;
-#X connect 21 0 24 0;
-#X connect 23 0 22 0;
-#X connect 24 0 25 0;
-#X connect 25 0 28 0;
-#X connect 26 0 57 0;
-#X connect 27 0 26 1;
-#X connect 28 0 23 0;
-#X connect 30 0 38 0;
-#X connect 31 0 9 0;
-#X connect 32 0 26 0;
-#X connect 32 0 58 0;
-#X connect 32 1 11 0;
-#X connect 37 0 32 0;
+#X obj 210 394 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+14 -3754 -1 -1 0 256;
+#X obj 147 394 nbx 4 16 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+14 -3754 -1 -1 0 256;
+#X floatatom 287 491 6 0 0 0 - - -;
+#X msg 219 95 3;
+#X obj 373 184 hradio 15 1 1 7 empty empty empty 0 -6 0 8 -262144 -1
+-1 0;
+#X text 371 168 how many analogIns to enable:;
+#X obj 372 203 + 240;
+#X obj 419 205 tgl 15 1 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 419 223 + 238;
+#X text 442 204 enable/disable digitalIns;
+#X floatatom 359 184 1 0 0 0 - - -;
+#X obj 218 337 speedlim 5;
+#X connect 1 0 30 0;
+#X connect 2 0 1 0;
+#X connect 7 0 30 0;
+#X connect 9 0 11 0;
+#X connect 10 0 9 1;
+#X connect 11 0 19 1;
+#X connect 11 1 19 0;
+#X connect 12 0 18 0;
+#X connect 12 0 31 0;
+#X connect 13 0 15 0;
+#X connect 14 0 16 0;
+#X connect 15 0 14 0;
+#X connect 16 0 17 0;
+#X connect 16 0 30 0;
+#X connect 18 0 15 0;
+#X connect 18 1 14 1;
+#X connect 19 0 21 1;
+#X connect 19 0 22 0;
+#X connect 21 0 20 0;
+#X connect 22 0 23 0;
+#X connect 23 0 26 0;
+#X connect 24 0 54 0;
+#X connect 25 0 24 1;
+#X connect 26 0 21 0;
+#X connect 28 0 36 0;
+#X connect 29 0 8 0;
+#X connect 30 0 55 0;
+#X connect 30 1 9 0;
+#X connect 30 1 24 0;
+#X connect 35 0 30 0;
+#X connect 36 0 35 0;
+#X connect 37 0 36 1;
#X connect 38 0 37 0;
-#X connect 39 0 38 1;
-#X connect 40 0 39 0;
-#X connect 41 0 39 0;
-#X connect 42 0 39 0;
-#X connect 44 0 8 0;
-#X connect 45 0 32 0;
-#X connect 46 0 47 0;
-#X connect 47 0 56 0;
-#X connect 47 1 48 0;
-#X connect 48 0 3 0;
-#X connect 51 0 32 0;
-#X connect 52 0 32 0;
-#X connect 53 0 52 0;
-#X connect 54 0 53 0;
-#X connect 55 0 54 0;
-#X connect 56 0 32 0;
-#X connect 58 0 68 0;
-#X connect 59 0 58 1;
-#X connect 60 0 7 0;
-#X connect 60 1 63 0;
-#X connect 60 2 67 0;
-#X connect 60 3 66 0;
-#X connect 60 4 65 0;
-#X connect 60 5 64 0;
-#X connect 60 6 61 0;
-#X connect 61 0 29 0;
-#X connect 61 0 69 0;
-#X connect 61 1 62 0;
-#X connect 68 0 60 0;
+#X connect 39 0 37 0;
+#X connect 40 0 37 0;
+#X connect 42 0 7 0;
+#X connect 43 0 30 0;
+#X connect 44 0 45 0;
+#X connect 45 0 53 0;
+#X connect 45 1 66 0;
+#X connect 48 0 30 0;
+#X connect 49 0 30 0;
+#X connect 50 0 49 0;
+#X connect 51 0 50 0;
+#X connect 52 0 51 0;
+#X connect 53 0 30 0;
+#X connect 55 0 74 0;
+#X connect 56 0 55 1;
+#X connect 57 0 6 0;
+#X connect 57 1 60 0;
+#X connect 57 2 64 0;
+#X connect 57 3 63 0;
+#X connect 57 4 62 0;
+#X connect 57 5 61 0;
+#X connect 57 6 58 0;
+#X connect 58 0 27 0;
+#X connect 58 0 65 0;
+#X connect 58 1 59 0;
+#X connect 66 0 2 0;
+#X connect 67 0 69 0;
+#X connect 67 0 73 0;
+#X connect 69 0 30 0;
+#X connect 70 0 71 0;
+#X connect 71 0 30 0;
+#X connect 74 0 57 0;
diff --git a/arduino.pd b/arduino.pd
index 759aa01..62fca08 100644
--- a/arduino.pd
+++ b/arduino.pd
@@ -1,4 +1,4 @@
-#N canvas 81 0 588 515 10;
+#N canvas 81 0 600 527 10;
#X obj 388 -14 import cyclone zexy;
#X text 390 446 released under the GNU GPL;
#X text 17 448 (C) Copyright 2006 Hans-Christoph Steiner <hans@at.or.at>
@@ -52,7 +52,7 @@
#X msg 11 100 reset;
#X obj 121 173 +;
#X obj 121 194 trigger bang float;
-#X obj 127 363 pack symbol float;
+#X obj 127 345 pack symbol float;
#X msg 125 228 0;
#X obj 349 135 gate 4;
#X obj 340 159 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
@@ -76,7 +76,7 @@
#X obj 11 58 select 255;
#X obj 134 152 * 128;
#X obj 11 -9 inlet;
-#X obj 127 413 outlet;
+#X obj 127 395 outlet;
#X obj 492 396 outlet;
#X obj 11 36 comport \$1 9600;
#N canvas 0 0 466 316 command 0;
@@ -108,23 +108,23 @@
#X connect 11 0 1 0;
#X restore 11 12 pd command processing;
#X obj 67 94 moses 128;
-#X obj 100 271 moses 6;
-#X msg 140 335 symbol digital;
-#X obj 7 335 makefilename analog%c;
-#X obj 140 314 bang;
-#X obj 7 312 + 48;
+#X msg 48 316 symbol digital;
+#X obj 143 315 makefilename analog%c;
#X obj 100 249 float;
#X obj 139 249 + 1;
-#X obj 127 388 list trim;
+#X obj 127 370 list trim;
+#X obj 100 271 select 0;
+#X text 373 418 DEBUG/RAW data (this will change);
+#X obj 143 293 + 47;
#X connect 3 0 5 0;
#X connect 3 1 23 0;
#X connect 4 0 3 0;
#X connect 4 0 8 0;
#X connect 5 0 6 0;
-#X connect 6 0 35 0;
+#X connect 6 0 32 0;
#X connect 6 1 7 1;
-#X connect 7 0 37 0;
-#X connect 8 0 35 1;
+#X connect 7 0 34 0;
+#X connect 8 0 32 1;
#X connect 9 0 10 0;
#X connect 9 1 11 0;
#X connect 9 2 12 0;
@@ -147,13 +147,12 @@
#X connect 27 0 26 0;
#X connect 28 0 27 0;
#X connect 29 0 3 0;
-#X connect 30 0 34 0;
-#X connect 30 1 33 0;
+#X connect 30 0 7 0;
#X connect 31 0 7 0;
-#X connect 32 0 7 0;
-#X connect 33 0 31 0;
-#X connect 34 0 32 0;
+#X connect 32 0 33 0;
+#X connect 32 0 35 0;
+#X connect 33 0 32 1;
+#X connect 34 0 25 0;
#X connect 35 0 30 0;
-#X connect 35 0 36 0;
-#X connect 36 0 35 1;
-#X connect 37 0 25 0;
+#X connect 35 1 37 0;
+#X connect 37 0 31 0;