1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
#N struct IR-blobs float x float y symbol s;
#N struct NC-stick float x float y symbol s;
#N canvas 134 135 881 633 10;
#X msg 19 322 disconnect;
#X obj 280 309 tgl 25 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X msg 60 95 discover;
#X obj 122 396 wiimote;
#X msg 280 339 setRumble \$1;
#X obj 216 186 tgl 25 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 122 186 tgl 25 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X msg 216 216 reportAcceleration \$1;
#X msg 122 216 reportIR \$1;
#N canvas 25 33 700 644 \$0-accelerometer-stuff 0;
#X obj 218 12 inlet;
#X obj 366 221 unpack 0 0 0;
#X obj 92 612 expr sqrt(pow($f1 \, 2) + pow($f2 \, 2) + pow($f3 \,
2));
#X obj 357 280 atan;
#X obj 357 259 expr $f1 / $f2;
#X obj 389 304 expr if ($f1 > 0 \, 3.14159 \, -3.14159);
#X obj 357 331 pack 0 0 0;
#X obj 357 353 expr if ($f3 <= 0 \, $f1 + $f2 \, $f1);
#X obj 357 375 * -1;
#X obj 328 61 unpack 0 0 0;
#X obj 42 443 s \$0-wii-pitch-set;
#X obj 357 445 s \$0-wii-roll-set;
#X obj 407 81 s \$0-wii-accZ-set;
#X obj 367 100 s \$0-wii-accY-set;
#X obj 328 119 s \$0-wii-accX-set;
#X text 75 514 The pitch and roll are only accurate if there are no
extra accelerations due to hand movement. We can check if the total
acceleration is close to gravity and only use pitch and roll in that
case. The total acceleration is given by:;
#X text 340 39 raw accerlation:;
#X obj 31 221 unpack 0 0 0;
#X obj 42 280 atan;
#X obj 42 259 expr $f1 / $f2;
#X obj 74 304 expr if ($f1 > 0 \, 3.14159 \, -3.14159);
#X obj 42 331 pack 0 0 0;
#X obj 42 353 expr if ($f3 <= 0 \, $f1 + $f2 \, $f1);
#X obj 42 375 * -1;
#X obj 225 578 unpack 0 0 0;
#X connect 0 0 9 0;
#X connect 0 0 17 0;
#X connect 0 0 1 0;
#X connect 1 0 4 0;
#X connect 1 0 5 0;
#X connect 1 2 4 1;
#X connect 1 2 6 2;
#X connect 3 0 6 0;
#X connect 4 0 3 0;
#X connect 5 0 6 1;
#X connect 6 0 7 0;
#X connect 7 0 8 0;
#X connect 8 0 11 0;
#X connect 9 0 14 0;
#X connect 9 1 13 0;
#X connect 9 2 12 0;
#X connect 17 1 19 0;
#X connect 17 1 20 0;
#X connect 17 2 19 1;
#X connect 17 2 21 2;
#X connect 18 0 21 0;
#X connect 19 0 18 0;
#X connect 20 0 21 1;
#X connect 21 0 22 0;
#X connect 22 0 23 0;
#X connect 23 0 10 0;
#X connect 24 0 2 0;
#X connect 24 1 2 1;
#X connect 24 2 2 2;
#X restore 134 485 pd \$0-accelerometer-stuff;
#N canvas 0 0 652 563 \$0-IR-stuff 0;
#X obj 134 18 inlet;
#X obj 122 510 pointer;
#X msg 122 488 traverse pd-IR-data \, next;
#X obj 134 63 route 0 1 2 3;
#X obj 23 482 unpack 0 0 0;
#X floatatom 483 44 5 0 0 0 IR-Blob: - -;
#X floatatom 522 44 5 0 0 0 - - -;
#X floatatom 562 44 5 0 0 0 - - -;
#X obj 15 533 set IR-blobs x y;
#X obj 231 400 pointer;
#X obj 132 372 unpack 0 0 0;
#X obj 124 423 set IR-blobs x y;
#X msg 231 378 traverse pd-IR-data \, next \, next;
#X obj 231 357 loadbang;
#X obj 122 467 loadbang;
#X obj 320 289 pointer;
#X obj 221 261 unpack 0 0 0;
#X obj 213 312 set IR-blobs x y;
#X obj 320 246 loadbang;
#X msg 320 267 traverse pd-IR-data \, next \, next \, next;
#X obj 380 177 pointer;
#X obj 281 149 unpack 0 0 0;
#X obj 273 200 set IR-blobs x y;
#X obj 380 134 loadbang;
#X msg 380 155 traverse pd-IR-data \, next \, next \, next \, next
;
#X connect 0 0 3 0;
#X connect 1 0 8 2;
#X connect 2 0 1 0;
#X connect 3 0 4 0;
#X connect 3 1 10 0;
#X connect 3 2 16 0;
#X connect 3 3 21 0;
#X connect 4 0 8 0;
#X connect 4 1 8 1;
#X connect 9 0 11 2;
#X connect 10 0 11 0;
#X connect 10 1 11 1;
#X connect 12 0 9 0;
#X connect 13 0 12 0;
#X connect 14 0 2 0;
#X connect 15 0 17 2;
#X connect 16 0 17 0;
#X connect 16 1 17 1;
#X connect 18 0 19 0;
#X connect 19 0 15 0;
#X connect 20 0 22 2;
#X connect 21 0 22 0;
#X connect 21 1 22 1;
#X connect 23 0 24 0;
#X connect 24 0 20 0;
#X restore 146 463 pd \$0-IR-stuff;
#X msg 408 356 setLED \$1;
#X obj 408 307 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 432 307 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 456 307 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 480 307 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X text 365 306 LEDs:;
#N canvas 0 0 409 401 bytemask 0;
#X obj 269 332 outlet;
#X obj 269 279 float;
#X obj 318 183 |;
#X obj 110 239 -;
#X obj 110 204 float;
#X obj 110 184 trigger bang float;
#X obj 231 204 &;
#X obj 183 142 route 0 1;
#X msg 36 56 \$1 1;
#X msg 106 56 \$1 2;
#X msg 176 56 \$1 4;
#X msg 246 56 \$1 8;
#X obj 36 15 inlet;
#X obj 106 15 inlet;
#X obj 176 15 inlet;
#X obj 246 15 inlet;
#X obj 36 35 change;
#X obj 106 35 change;
#X obj 176 35 change;
#X obj 246 35 change;
#X connect 1 0 2 1;
#X connect 1 0 4 1;
#X connect 1 0 6 1;
#X connect 1 0 0 0;
#X connect 2 0 1 0;
#X connect 3 0 1 0;
#X connect 4 0 3 0;
#X connect 5 0 4 0;
#X connect 5 1 6 0;
#X connect 6 0 3 1;
#X connect 7 0 5 0;
#X connect 7 1 2 0;
#X connect 8 0 7 0;
#X connect 9 0 7 0;
#X connect 10 0 7 0;
#X connect 11 0 7 0;
#X connect 12 0 16 0;
#X connect 13 0 17 0;
#X connect 14 0 18 0;
#X connect 15 0 19 0;
#X connect 16 0 8 0;
#X connect 17 0 9 0;
#X connect 18 0 10 0;
#X connect 19 0 11 0;
#X restore 408 333 pd bytemask;
#X obj 161 589 wiimote 00:19:1D:BE:6A:66;
#X text 5 6 IN ORDER TO CONNECT: First put the wiimote into discover
mode (press buttons 1 and 2 simultaneously).;
#X text 221 68 <- Then you can connect to a specific address;
#X text 127 96 <- Or you can try to automatically detect a wiimote.
;
#X obj 375 186 tgl 25 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X text 74 557 You can also specify the address as a creation argument:
;
#X text 115 138 By default \, the wiimote does not report acceleration
data \, IR data \, or any data from an attached extension (eg \, nunchuck).
You must specifically enable each reporting mode:;
#X text 86 571 (make sure to enable discover mode before creation)
;
#X msg 375 216 reportNunchuck \$1;
#N canvas 0 0 920 244 \$0-nunchuck-stuff 0;
#X obj 559 61 inlet;
#X obj 672 134 pointer;
#X obj 672 91 loadbang;
#X obj 559 96 unpack 0 0;
#X obj 565 179 set NC-stick x y;
#X obj 49 71 inlet;
#X text 42 32 inlet #1: BUTTONS;
#X text 294 35 inlet #2: ACCELERATION;
#X obj 304 72 inlet;
#X obj 304 105 unpack 0 0 0;
#X obj 383 125 s \$0-nc-accZ-set;
#X obj 343 144 s \$0-nc-accY-set;
#X obj 304 163 s \$0-nc-accX-set;
#X text 567 32 inlet #3: STICK;
#X obj 49 117 s \$0-nc-btn-set;
#X msg 672 112 traverse pd-NC-data \, next;
#X connect 0 0 3 0;
#X connect 1 0 4 2;
#X connect 2 0 15 0;
#X connect 3 0 4 0;
#X connect 3 1 4 1;
#X connect 5 0 14 0;
#X connect 8 0 9 0;
#X connect 9 0 12 0;
#X connect 9 1 11 0;
#X connect 9 2 10 0;
#X connect 15 0 1 0;
#X restore 158 444 pd \$0-nunchuck-stuff;
#X obj 579 406 cnv 15 275 230 empty empty Nunchuk: 10 15 0 14 -228992
-355 0;
#X floatatom 756 470 7 0 0 1 _X #0-nc-accX-set #0-nc-accX;
#X floatatom 756 484 7 0 0 1 _Y #0-nc-accY-set #0-nc-accY;
#X floatatom 756 498 7 0 0 1 _Z #0-nc-accZ-set #0-nc-accZ;
#X obj 626 470 hsl 128 14 -1 1 0 0 \$0-nc-accX \$0-nc-accX-set empty
-2 -8 0 10 -261681 -1 -1 0 1;
#X obj 626 484 hsl 128 14 -1 1 0 0 \$0-nc-accY \$0-nc-accY-set empty
-2 -8 0 10 -261681 -1 -1 0 1;
#X obj 626 498 hsl 128 14 -1 1 0 0 \$0-nc-accZ \$0-nc-accZ-set empty
-2 -8 0 10 -261681 -1 -1 0 1;
#X obj 792 429 nbx 3 16 -1e+37 1e+37 0 0 empty \$0-nc-btn-set empty
-80 8 0 10 -261681 -1 -1 0 256;
#X text 622 454 Acceleration:;
#N canvas 154 209 610 221 NC-stick 0;
#X obj 39 34 struct NC-stick float x float y;
#X obj 44 71 filledpolygon 900 20 0 5 -5 0 -20 -5 -5 -20 0 -5 5 0 20
5 5 20 0;
#X restore 681 614 pd NC-stick;
#X text 783 411 Buttons:;
#X text 698 518 Stick:;
#X obj 579 5 cnv 15 275 400 empty empty Wiimote: 10 15 0 14 -261689
-143491 0;
#X floatatom 742 80 7 0 0 1 _X #0-wii-accX-set #0-wii-accX;
#X floatatom 742 94 7 0 0 1 _Y #0-wii-accY-set #0-wii-accY;
#X floatatom 742 108 7 0 0 1 _Z #0-wii-accZ-set #0-wii-accZ;
#X obj 612 80 hsl 128 14 -1 1 0 0 \$0-wii-accX \$0-wii-accX-set empty
-2 -8 0 10 -225271 -1 -1 0 1;
#X obj 612 94 hsl 128 14 -1 1 0 0 \$0-wii-accY \$0-wii-accY-set empty
-2 -8 0 10 -225271 -1 -1 0 1;
#X obj 612 108 hsl 128 14 -1 1 0 0 \$0-wii-accZ \$0-wii-accZ-set empty
-2 -8 0 10 -225271 -1 -1 0 1;
#N canvas 525 243 481 416 IR-data 0;
#X scalar IR-blobs 909 63 blob1 \;;
#X scalar IR-blobs 250.25 49 blob2 \;;
#X scalar IR-blobs 145.5 182.25 blob3 \;;
#X scalar IR-blobs 491.008 468.615 blob4 \;;
#X coords 0 0 1024 768 256 196 1;
#X restore 590 183 pd IR-data;
#N canvas 631 449 342 204 IR-blobs 0;
#X obj 39 34 struct IR-blobs float x float y symbol s;
#X obj 39 71 filledcurve 9 30 0 0 -30 -30 0 0 30 30 0;
#X obj 48 112 drawsymbol s -60 -75 0 1 blob;
#X restore 767 379 pd IR-blobs;
#X text 648 166 IR Blobs (1024x768):;
#X floatatom 742 128 7 0 0 1 _PITCH #0-wii-pitch-set #0-wii-pitch;
#X obj 612 128 hsl 128 14 -3.14156 3.14159 0 0 \$0-wii-pitch \$0-wii-pitch-set
empty -2 -8 0 10 -225280 -1 -1 0 1;
#X floatatom 742 142 7 0 0 1 _ROLL #0-wii-roll-set #0-wii-roll;
#X obj 612 142 hsl 128 14 -3.14156 3.14159 0 0 \$0-wii-roll \$0-wii-roll-set
empty -2 -8 0 10 -225280 -1 -1 0 1;
#X text 608 64 Acceleration (-1 to 1):;
#X obj 779 23 nbx 2 16 -1e+37 1e+37 0 0 empty \$0-wii-btn01-set empty
-100 10 0 12 -225280 -1 -1 0 256;
#X obj 814 23 nbx 2 16 -1e+37 1e+37 0 0 empty \$0-wii-btn02-set empty
0 10 0 12 -225280 -1 -1 0 256;
#N canvas 0 0 330 216 \$0-button-stuff 0;
#X obj 41 33 inlet;
#X obj 41 86 unpack 0 0;
#X obj 41 140 s \$0-wii-btn01-set;
#X obj 106 120 s \$0-wii-btn02-set;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 1 1 3 0;
#X restore 122 507 pd \$0-button-stuff;
#X text 783 5 Buttons:;
#N canvas 185 133 481 416 NC-data 0;
#X scalar NC-stick 130 133 \;;
#X coords 0 0 256 256 80 80 1;
#X restore 681 534 pd NC-data;
#X obj 161 615 print;
#X msg 36 69 connect 00:1E:35:1D:0E:15;
#N canvas 0 0 970 429 router 0;
#X obj 104 38 inlet;
#X obj 104 207 outlet button;
#X obj 232 277 outlet IR;
#X obj 378 267 outlet nunchuck-buttons;
#X obj 449 287 outlet nunchuck-acceleration;
#X obj 520 307 outlet nunchuck-stick;
#X obj 168 247 outlet acceleration;
#X obj 104 169 route button acceleration ir;
#X obj 378 245 route button acceleration stick;
#X obj 378 204 route nunchuck motionplus;
#X text 392 161 extensions;
#X text 168 138 core;
#X connect 0 0 7 0;
#X connect 7 0 1 0;
#X connect 7 1 6 0;
#X connect 7 2 2 0;
#X connect 7 3 9 0;
#X connect 8 0 3 0;
#X connect 8 1 4 0;
#X connect 8 2 5 0;
#X connect 9 0 8 0;
#X restore 122 423 pd router;
#X connect 0 0 3 0;
#X connect 1 0 4 0;
#X connect 2 0 3 0;
#X connect 3 0 62 0;
#X connect 4 0 3 0;
#X connect 5 0 7 0;
#X connect 6 0 8 0;
#X connect 7 0 3 0;
#X connect 8 0 3 0;
#X connect 11 0 3 0;
#X connect 12 0 17 0;
#X connect 13 0 17 1;
#X connect 14 0 17 2;
#X connect 15 0 17 3;
#X connect 17 0 11 0;
#X connect 18 0 60 0;
#X connect 22 0 26 0;
#X connect 26 0 3 0;
#X connect 61 0 3 0;
#X connect 62 0 57 0;
#X connect 62 1 9 0;
#X connect 62 2 10 0;
#X connect 62 3 27 0;
#X connect 62 4 27 1;
#X connect 62 5 27 2;
|