diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2008-11-25 05:56:16 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2008-11-25 05:56:16 +0000 |
commit | c6be69970a25abc8a22c350e9486455aaec086eb (patch) | |
tree | 066d1dc299234ffe0722546ac4f27df14a92cac0 | |
parent | 6e9247a0756a52691b254ba811d80f37e36c8303 (diff) |
- added a "port" message for sending a complete port at a time, directly
reflecting the underlying digital message and the fact that digital outputs
on a microcrontroller are handled on an 8-bit port basis.
svn path=/trunk/externals/hardware/arduino/; revision=10379
-rw-r--r-- | arduino-help.pd | 20 | ||||
-rw-r--r-- | arduino-test.pd | 37 | ||||
-rw-r--r-- | arduino.pd | 102 |
3 files changed, 108 insertions, 51 deletions
diff --git a/arduino-help.pd b/arduino-help.pd index 1ce0710..cbef908 100644 --- a/arduino-help.pd +++ b/arduino-help.pd @@ -1,4 +1,5 @@ -#N canvas 80 22 674 563 10; +#N canvas 89 22 674 563 10; +#X declare -lib flatspace; #X obj 558 10 import flatspace; #N canvas 233 472 466 316 INSTALL-NOTES 0; #X text 39 201 [comport] \, from pd-cvs/externals/iem/comport; @@ -21,7 +22,7 @@ board !; #X msg 58 189 close; #X msg 58 234 info; #X text 11 149 select/close the serial port:; -#N canvas 248 49 442 351 DIGITAL-OUTPUT 0; +#N canvas 248 49 447 555 DIGITAL-OUTPUT 0; #X text 72 97 I/O the individual pins:; #X text 20 22 NOTE: don't forget to set pins to output mode first! ; @@ -122,6 +123,15 @@ board !; 0; #X obj 66 134 cnv 15 15 15 empty empty Tx 1 10 0 11 -128992 -13381 0; +#X obj 49 510 send \$0-arduino; +#X text 38 311 You can also send digital messages 8-bits at a time +\, called a "port". Microcontrollers like the Arduino are organized +around 8-bit ports. This allows you to set 8 pins at the same time +with one message; +#X msg 267 392 port 1 0; +#X msg 123 391 port 0 0; +#X msg 49 391 port 0 255; +#X msg 193 392 port 1 255; #X connect 3 0 20 0; #X connect 4 0 16 7; #X connect 5 0 16 8; @@ -150,6 +160,10 @@ board !; #X connect 17 0 11 0; #X connect 18 0 19 0; #X connect 19 0 17 0; +#X connect 29 0 27 0; +#X connect 30 0 27 0; +#X connect 31 0 27 0; +#X connect 32 0 27 0; #X restore 61 428 pd DIGITAL-OUTPUT; #N canvas 494 94 578 280 DIGITAL-INPUT 0; #X obj 114 67 r \$0-arduino-out; @@ -448,7 +462,7 @@ Holzmann; ; #X obj 499 185 tgl 15 0 empty empty 12 0 -6 1 12 -260818 -1 -1 0 1 ; -#X obj 516 185 tgl 15 0 empty empty 13 0 -6 1 12 -260818 -1 -1 1 1 +#X obj 516 185 tgl 15 0 empty empty 13 0 -6 1 12 -260818 -1 -1 0 1 ; #X msg 295 226 pinMode 13 1; #N canvas 163 104 696 323 send-to-arduino------------------- 0; diff --git a/arduino-test.pd b/arduino-test.pd index 5c67900..e4a38c3 100644 --- a/arduino-test.pd +++ b/arduino-test.pd @@ -131,7 +131,7 @@ #X floatatom 252 426 5 0 0 3 a5 - -; #X text 290 271 <- argument sets port #; #X obj 40 71 hradio 15 1 0 14 empty empty empty 0 -6 0 8 -176124 -1 --1 6; +-1 0; #X text 148 57 7; #X text 42 57 0; #X text 189 57 10; @@ -187,7 +187,7 @@ #X connect 16 0 17 0; #X connect 17 0 14 0; #X restore 41 125 pd pwm; -#X msg 41 147 pwm 6 0; +#X msg 41 147 pwm 0 0; #X msg 319 155 info; #X msg 358 155 version; #X obj 220 302 spigot; @@ -216,11 +216,11 @@ #X obj 550 77 tgl 15 1 empty ARDUINO_PINMODE_RESET 13 0 -6 1 12 -260818 -1 -1 1 1; #X text 328 44 turn on output mode for each pin (off=input); -#X msg 329 118 pinMode 2 1; -#N canvas 69 607 475 352 sending 0; +#X msg 329 118 pinMode 13 1; +#N canvas 108 55 475 478 sending 0; #X obj 69 208 cnv 15 100 22 empty empty empty 20 12 0 14 -253938 -66577 0; -#X obj 78 264 outlet; +#X obj 78 434 outlet; #X msg 78 211 digital 2 0; #X obj 197 148 tgl 15 0 empty empty 7 4 -6 1 12 -233017 -1 -1 0 1; #X obj 214 148 tgl 15 0 empty empty 8 4 -6 1 12 -233017 -1 -1 0 1; @@ -319,6 +319,20 @@ #X obj 261 43 trigger 0 float; #X obj 261 64 select 0; #X msg 261 84 0; +#X msg 405 389 port 1 0; +#X msg 263 389 port 0 0; +#X msg 189 389 port 0 255; +#X msg 331 389 port 1 255; +#X text 95 291 or send 8-bit ports in one message:; +#X msg 159 338 port 1 \$1; +#X msg 91 338 port 0 \$1; +#X msg 230 338 port 2 \$1; +#X obj 362 297 tgl 25 0 empty ARDUINO_TEST_RESET ALL 2 12 0 12 -262144 +-1 -1 255 255; +#X obj 362 246 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 +16383; +#X obj 362 266 metro 100; +#X floatatom 362 329 5 0 0 0 - - -; #X connect 2 0 1 0; #X connect 3 0 15 7; #X connect 4 0 15 8; @@ -352,6 +366,19 @@ #X connect 24 1 17 0; #X connect 25 0 26 0; #X connect 26 0 16 0; +#X connect 27 0 1 0; +#X connect 28 0 1 0; +#X connect 29 0 1 0; +#X connect 30 0 1 0; +#X connect 32 0 1 0; +#X connect 33 0 1 0; +#X connect 34 0 1 0; +#X connect 35 0 38 0; +#X connect 35 0 34 0; +#X connect 35 0 32 0; +#X connect 35 0 33 0; +#X connect 36 0 37 0; +#X connect 37 0 35 0; #X restore 14 244 pd sending digital outs; #X obj 14 225 tgl 15 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 16383 ; @@ -1,39 +1,40 @@ -#N canvas 486 297 585 366 10; +#N canvas 559 528 585 366 10; #X obj 32 26 inlet; #X obj 32 304 outlet; #X obj 515 304 outlet; -#N canvas 100 292 813 345 command 1; +#N canvas 100 292 813 345 command 0; #X obj 24 7 inlet; #X obj 281 289 outlet; -#N canvas 176 407 597 479 digital-out 0; -#X obj 3 15 inlet; -#X obj 283 440 outlet; -#X msg 372 88 \$1; -#X text 401 87 add channel to command; -#X text 410 131 0x90; -#X obj 372 132 + 144; -#X obj 372 110 div 8; -#X obj 211 391 float; -#X obj 144 391 float; -#X obj 408 16 inlet; -#X text 453 17 state from port-out; -#X msg 156 84 \$2; -#X obj 235 143 <<; -#X msg 235 122 1 \$1; -#X obj 283 242 * 8; -#X obj 171 371 >> 7; -#X obj 238 371 & 127; -#X obj 248 314 &; -#X msg 289 267 255 \$1; -#X obj 289 288 <<; -#X obj 4 55 trigger bang bang bang anything anything anything; -#X obj 193 255 float; -#X obj 254 338 >>; -#X obj 222 215 |; -#X obj 218 173 float; -#X obj 157 172 float; -#X obj 156 115 select 0 1; -#X obj 84 215 expr ~$f1 & $f2; +#N canvas 75 439 547 478 digital-out 0; +#X obj 4 15 inlet; +#X obj 284 440 outlet; +#X msg 373 158 \$1; +#X text 402 157 add channel to command; +#X text 411 201 0x90; +#X obj 373 202 + 144; +#X obj 373 180 div 8; +#X obj 212 391 float; +#X obj 145 391 float; +#X obj 459 16 inlet; +#X text 339 15 state from port-out; +#X msg 157 84 \$2; +#X obj 236 143 <<; +#X msg 236 122 1 \$1; +#X obj 284 242 * 8; +#X obj 172 371 >> 7; +#X obj 239 371 & 127; +#X obj 249 314 &; +#X msg 290 267 255 \$1; +#X obj 290 288 <<; +#X obj 5 55 trigger bang bang bang anything anything anything; +#X obj 194 255 float; +#X obj 255 338 >>; +#X obj 223 215 |; +#X obj 219 173 float; +#X obj 158 172 float; +#X obj 157 115 select 0 1; +#X obj 85 215 expr ~$f1 & $f2; +#X floatatom 462 49 0 0 0 0 - - -; #X connect 0 0 20 0; #X connect 2 0 6 0; #X connect 5 0 1 0; @@ -41,6 +42,8 @@ #X connect 6 0 14 0; #X connect 7 0 1 0; #X connect 8 0 1 0; +#X connect 9 0 23 0; +#X connect 9 0 28 0; #X connect 11 0 26 0; #X connect 12 0 24 1; #X connect 12 0 25 1; @@ -239,23 +242,26 @@ #X connect 17 0 3 1; #X restore 662 136 pd sysex; #X obj 662 114 route sysex string; -#N canvas 481 623 569 343 port-out 0; +#N canvas 107 510 569 343 port-out 0; #X obj 13 15 inlet; #X obj 167 281 outlet; #X msg 244 82 \$1; -#X text 273 81 add channel to command; -#X text 309 187 0x90; -#X obj 271 188 + 144; -#X obj 244 106 moses; +#X text 343 149 add channel to command; +#X text 309 190 0x90; +#X obj 271 191 + 144; +#X obj 244 129 moses; #X obj 13 55 trigger bang anything anything anything; -#X obj 271 126 moses 16; -#X obj 353 196 print [arduino]; -#X msg 353 174 ERROR: no such channel: \$1; +#X obj 271 149 moses 16; +#X obj 353 219 print [arduino]; +#X msg 353 197 ERROR: no such channel: \$1; #X msg 167 82 \$2; #X msg 90 82 \$2; -#X obj 167 106 & 127; -#X obj 90 106 & 128; -#X obj 90 131 == 128; +#X obj 167 129 & 127; +#X obj 90 130 & 128; +#X obj 90 151 == 128; +#X obj 21 285 outlet; +#X obj 36 230 * 8; +#X obj 21 251 <<; #X connect 0 0 7 0; #X connect 2 0 6 0; #X connect 5 0 1 0; @@ -265,13 +271,17 @@ #X connect 7 2 11 0; #X connect 7 3 2 0; #X connect 8 0 5 0; +#X connect 8 0 17 0; #X connect 8 1 10 0; #X connect 10 0 9 0; #X connect 11 0 13 0; #X connect 12 0 14 0; +#X connect 12 0 18 0; #X connect 13 0 1 0; #X connect 14 0 15 0; #X connect 15 0 1 0; +#X connect 17 0 18 1; +#X connect 18 0 16 0; #X restore 425 122 pd port-out; #X obj 361 77 route digital port version firmware; #X connect 0 0 12 0; @@ -296,7 +306,8 @@ #X connect 14 0 13 0; #X connect 14 1 13 1; #X connect 14 2 1 0; -#X connect 15 0 1 0; +#X connect 15 0 2 1; +#X connect 15 1 1 0; #X connect 16 0 2 0; #X connect 16 1 15 0; #X connect 16 2 10 0; @@ -706,6 +717,9 @@ byte left over; #X restore 32 229 pd convert to symbolic commands; #X text 27 331 (C) Copyright 2006-2008 Free Software Foundation; #X text 334 330 released under the GNU GPL v2 or later; +#X obj 188 203 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X obj 188 181 route open; #X connect 0 0 3 0; #X connect 3 0 10 0; #X connect 5 0 6 0; @@ -714,6 +728,8 @@ byte left over; #X connect 10 0 8 0; #X connect 10 1 7 0; #X connect 10 1 2 0; +#X connect 10 1 15 0; #X connect 11 0 1 0; #X connect 11 0 9 0; #X connect 11 1 2 0; +#X connect 15 0 14 0; |