-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCheck_Edit_Button.ino
More file actions
326 lines (283 loc) · 10.2 KB
/
Copy pathCheck_Edit_Button.ino
File metadata and controls
326 lines (283 loc) · 10.2 KB
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
void Check_Edit_Button_Pattern_Edit()
{
// read the state of the buttons
byte reading= SR.Button_SR_Read(2);//stock l'etat des boutons
if (reading!=old_edit_button_state){
millis_debounce_edit_button=millis();
//Serial.println("ok");
}
if((millis()-millis_debounce_edit_button)>=DEBOUNCE){
if(reading!=edit_button_state){
edit_button_state=reading;
switch (edit_button_state){
//----------------------
//check le bouton play
case 1:
if(old_selected_mode==0 || old_selected_mode==3){
button_play_count++;
if(button_play_count==1){
play=1;
// allow the first step to play
first_play=1;//permet de jouer le premier pas (cf interrupt)
// second flag of play the first (???)
first_play_A=1;//un deuxime flag de jouer le premier (cf interrupt)
}
else if (button_play_count==2){
play=0;
button_play_count=0;
first_stop=1;
}
}
//Serial.println(play,DEC);//DEBUGG
break;
//-------------------------
//check bouton scale
case 4:
// indicates that the scale of the pattern has changed
pattern_scale_changed=1;//indique que la scale du pattern achanger
button_scale_count++;
if(button_scale_count==4) button_scale_count=0;
// send the scale corresponding in the variable pattern scale
//envoi la scale correspondante dans la variable pattern scale
switch (button_scale_count){
case 0:
pattern_scale[pattern_buffer]=12;// 1/32 de temps
break;
case 1:
pattern_scale[pattern_buffer]=24;// 1/16 de temps
break;
case 2:
pattern_scale[pattern_buffer]=16;// 1/16t de temps
break;
case 3:
pattern_scale[pattern_buffer]=32;// 1/8t de temsp
break;
}
//Serial.println(button_scale_count,DEC);//DEBUGG
break;
//-------------------------
// check which part is selected - either 1-16 or 17-32
//check quel part est selectionner soit 1a16 ou 17a32
case 8:
button_pattern_part=1;//section 17 a 32 selectionner
break;
case 16:
button_pattern_part=0;// section 1 a 16 selectionner
break;
}
// the two buttons 1-16 and 17-32 pressed
//les deux boutons 1-16 et 17-32 appuyer
if (edit_button_state==24){
button_part_switch =!button_part_switch;
}
//Bouton Shift
if (edit_button_state==2) button_shift=1;//bouton shift appuyer
else button_shift=0;//bouton shift relacher
if (edit_button_state==32) button_encoder=1;
else button_encoder=0;
// Serial.println(button_encoder);//DEBUGG
//Serial.println(button_init,DEC);//DEBUGG
}
}
// we retain the state of the buttons
old_edit_button_state= reading;// on retient l'etat des boutons
}
//=============================================================================
void Check_Edit_Button_Pattern()
{
//-----------------------------------------------------
if (sync_mode != MASTER)
{
// check the status play in DIN_SYNC mode
//Check la statut play en mdoe DIN_SYNC
boolean din_start_state = PIND & (1<<5);
if (din_start_state != old_din_start_state){
if(din_start_state){//si l'entrée DIN Start est HIGH
first_play=1;// indiquer le premier play
play=1;
}
else if (!din_start_state){//si l'entrée DIN Start est LOW
play=0;
first_stop=1;
}
old_din_start_state = din_start_state;
}
}
//-------------------------------------------------------
byte reading= SR.Button_SR_Read(2);//stock l'etat des boutons
if (reading!=old_edit_button_state){
millis_debounce_edit_button=millis();
//Serial.println("ok");
}
if((millis()-millis_debounce_edit_button)>=DEBOUNCE){
if(reading!=edit_button_state){
edit_button_state=reading;
switch (edit_button_state){
//----------------------
//check le bouton play
case 1:
if(sync_mode == MASTER){//selected_mode==0 || selected_mode==3){
button_play_count++;
if(button_play_count==1){
//ppqn_count=0;
play=1;
first_play=1;//permet de jouer le premier pas (cf interrupt)
first_play_A=1;//un deuxime flag de jouer le premier (cf interrupt)
first_play_C=1;//idem
}
else if (button_play_count==2){
play=0;
button_play_count=0;
first_stop=1;
}
}
//Serial.println(play,DEC);//DEBUGG
break;
//-------------------------
//check bouton scale
case 4:
break;
//-------------------------
//check quel bouton de la part est selectionner soit 1a16 ou 17a3
case 8:
roll_mode=1;//indique qu'on est rentré dans le mode roll
mute_mode=0;
break;
case 16:
mute_mode=1;//indique qu'on est dans le mute mode
roll_mode=0;
break;
}
if((mute_mode==1||roll_mode==1) && button_shift==1) {
// we come out of the mode with the shift button
mute_mode=0;//on sort du mode mode avec le bouton shift
roll_mode=0;
}
//-------------------------
//Bouton Shift
if (edit_button_state==2) button_shift=1;//bouton shift appuyer
else button_shift=0;//bouton shift relacher
//Bouton encoder
if (edit_button_state==32) button_encoder=1;
else button_encoder=0;
//Bouton Solo mode
if (edit_button_state==16 && mute_mode==1) solo_mode=1;
else solo_mode=0;
}
}
old_edit_button_state= reading;// on retient l'etat des boutons
}
//==================================================================
void Check_Edit_Button_Setup()
{
byte reading= SR.Button_SR_Read(2);//stock l'etat des boutons
if (reading!=old_edit_button_state){
millis_debounce_edit_button=millis();
//Serial.println("ok");
}
if((millis()-millis_debounce_edit_button)>=DEBOUNCE){
if(reading!=edit_button_state){
edit_button_state=reading;
//-------------------------
//Bouton play
if (edit_button_state==1) button_play=1;//bouton play appuyer
else button_play=0;//bouton play relacher
//-------------------------
//Bouton Shift
if (edit_button_state==2) button_shift=1;//bouton shift appuyer
else button_shift=0;//bouton shift relacher
//-------------------------
//Check si les boutons play et shift sont apuyer
if(edit_button_state== 3) button_init=1;// bouton init correspond au bouton shift et play appuyer
else button_init=0;
//--------------------
//Bouton reset
if (edit_button_state==16) button_reset=1;//bouton shift appuyer
else button_reset=0;//bouton shift relacher
}
}
old_edit_button_state= reading;// on retient l'etat des boutons
}
//==================================================================
void Check_Edit_Button_Song()
{
//-------------------------------------------------------------------------------------
if (selected_mode ==5 || selected_mode ==6){//le mode selectionne est il SONG_DIN_SLAVe ou SONG_MIDI_SLAVE
//Check la statut play en mdoe DIN_SYNC
boolean din_start_state = PIND & (1<<5);
if (din_start_state != old_din_start_state){
if(din_start_state){//si l'entrée DIN Start est HIGH
first_play=1;// indiquer le premier play
first_play_A=1;//un deuxime flag de jouer le premier (cf interrupt)
first_play_B=1;
play=1;
}
else if (!din_start_state){//si l'entrée DIN Start est LOW
play=0;
first_stop=1;
}
old_din_start_state = din_start_state;
}
}
byte reading= SR.Button_SR_Read(2);//stock l'etat des boutons
if (reading!=old_edit_button_state){
millis_debounce_edit_button=millis();
}
if((millis()-millis_debounce_edit_button)>=DEBOUNCE){
if(reading!=edit_button_state){
edit_button_state=reading;
//---------------------------------------------------------------------------------
if (selected_mode== 4 || selected_mode==7){//le mode selectionne est il SONG_MIDI_MASTER
switch (edit_button_state){
//----------------------
//check le bouton play
case 1:
button_play_count++;
if(button_play_count==1){
play=1;
first_play=1;//permet de jouer le premier pas (cf interrupt)
first_play_A=1;//un deuxime flag de jouer le premier (cf interrupt)
first_play_B=1;
}
else if (button_play_count==2){
play=0;
button_play_count=0;
first_stop=1;
}
break;
}
}
//--------------------
//Bouton Shift
if (edit_button_state==2) button_shift=1;//bouton shift appuyer
else button_shift=0;//bouton shift relacher
//--------------------
//Bouton Next
if (edit_button_state==4){
button_next=1;//bouton shift appuyer
}
else{
button_next=0;//bouton shift relacher
first_push_next=0;//flag que le bouton next a été relacher
}
//--------------------
//Bouton End
if (edit_button_state==8){
button_end=1;//bouton shift appuyer
}
else {
button_end=0;//bouton shift relacher
first_push_end=0;//flag que le bouton end a ete relacher
}
//--------------------
//Bouton reset
if (edit_button_state==16) button_reset=1;//bouton shift appuyer
else button_reset=0;//bouton shift relacher
//Bouton encoder
if (edit_button_state==32) button_encoder=1;
else button_encoder=0;
}
}
old_edit_button_state= reading;// on retient l'etat des boutons
//Serial.println(button_reset);
}