-
Notifications
You must be signed in to change notification settings - Fork 1
/
osc.axo
149 lines (145 loc) · 7.08 KB
/
osc.axo
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
<objdefs appVersion="1.0.12">
<obj.normal id="osc" uuid="483456af-0673-4193-bfc3-ccf29ad97a5f">
<sDescription>enable serial2( PA2/PA3 = SD2, baudrate: 115200) to communicate with esp-12 (esp8266) to recieve 16 float Osc messages : /axo1 ... /axo16</sDescription>
<author>Gael</author>
<license>BSD</license>
<inlets/>
<outlets>
<frac32.positive name="axo1"/>
<frac32.positive name="axo2"/>
<frac32.positive name="axo3"/>
<frac32.positive name="axo4"/>
<frac32.positive name="axo5"/>
<frac32.positive name="axo6"/>
<frac32.positive name="axo7"/>
<frac32.positive name="axo8"/>
<frac32.positive name="axo9"/>
<frac32.positive name="axo10"/>
<frac32.positive name="axo11"/>
<frac32.positive name="axo12"/>
<frac32.positive name="axo13"/>
<frac32.positive name="axo14"/>
<frac32.positive name="axo15"/>
<frac32.positive name="axo16"/>
</outlets>
<displays/>
<params/>
<attribs/>
<depends>
<depend>SD2</depend>
</depends>
<code.declaration><![CDATA[uint32_t axo1,axo2,axo3,axo4,axo5,axo6,axo7,axo8,axo9,axo10,axo11,axo12,axo13,axo14,axo15,axo16;
uint8_t ch; // channel code for outlet 128 + channel number
uint8_t inData[4] = { 0 }; // incomming datas for 27bit value
msg_t ThreadX2(){
#if CH_USE_REGISTRY
chRegSetThreadName("euxo button pot"); // define thread name
#endif
//sdPut(&SD2,0xFF);
while(!chThdShouldTerminate()){
while(!sdGetWouldBlock(&SD2) ){
ch = sdGet(&SD2);
switch((uint8_t) ch) {
case 129 : // axo1 start code : 128 + 1
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo1 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 130 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo2 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 131 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo3 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 132 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo4 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 133 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo5 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 134 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo6 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 135 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo7 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 136 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo8 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 137 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo9 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 138 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo10 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 139 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo11 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 140 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo12 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 141 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo13 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 142 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo14 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 143 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo15 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
case 144 :
inData[0] = sdGet(&SD2); inData[1] = sdGet(&SD2); inData[2] = sdGet(&SD2); inData[3] = sdGet(&SD2);
axo16 = (inData[0] << 21) | (inData[1] << 14) | (inData[2] << 7) | inData[3] ; //sum at 1<<27
break;
default :
break; //printf("error");
}
}
chThdSleepMilliseconds(1);
}
chThdExit((msg_t)0);
}
static msg_t EuxoButPot(void *arg) {
((attr_parent *)arg)->ThreadX2();
}
WORKING_AREA(waEuxoButPot, 256);
Thread *Thd;]]></code.declaration>
<code.init><![CDATA[palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7)|PAL_MODE_INPUT);// RX
palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));// TX
static const SerialConfig sd2Cfg = {115200, 0, 0, 0}; // set to midi baud rate but works also with higher baud rates.
sdStart(&SD2, &sd2Cfg);
Thd = chThdCreateStatic(waEuxoButPot, sizeof(waEuxoButPot),NORMALPRIO, EuxoButPot, (void *)this);]]></code.init>
<code.dispose><![CDATA[chThdTerminate(Thd);
chThdWait(Thd);
sdStop(&SD2);]]></code.dispose>
<code.krate><![CDATA[outlet_axo1 = this->axo1;
outlet_axo2 = this->axo2;
outlet_axo3 = this->axo3;
outlet_axo4 = this->axo4;
outlet_axo5 = this->axo5;
outlet_axo6 = this->axo6;
outlet_axo7 = this->axo7;
outlet_axo8 = this->axo8;
outlet_axo9 = this->axo9;
outlet_axo10 = this->axo10;
outlet_axo11 = this->axo11;
outlet_axo12 = this->axo12;
outlet_axo13 = this->axo13;
outlet_axo14 = this->axo14;
outlet_axo15 = this->axo15;
outlet_axo16 = this->axo16;]]></code.krate>
</obj.normal>
</objdefs>