-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhellodrum.h
414 lines (365 loc) · 9.2 KB
/
hellodrum.h
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
/*
" HELLO DRUM LIBRARY" Ver.0.7.7
by Ryo Kosaka
GitHub : https://github.com/RyoKosaka/HelloDrum-arduino-Library
Blog : https://open-e-drums.tumblr.com/
*/
#ifndef HelloDrum_h
#define HelloDrum_h
#include "Arduino.h"
#ifdef ESP32
#include "EEPROM_ESP.h"
#else
#include "EEPROM.h"
#endif
const static char *item[] = {
"SENSITIVITY", //0 0
"THRESHOLD", //1 1
"SCAN TIME", //2 2
"MASK TIME", //3 3
"CURVE TYPE", //6 4
"NOTE", //7 5
};
const static char *itemD[] = {
"SENSITIVITY", //0
"THRESHOLD", //1
"SCAN TIME", //2
"MASK TIME", //3
"RIM SENS", //4
"RIM THRE", //5
"CURVE TYPE", //6
"NOTE HEAD", //7
"NOTE RIM", //8
"NOTE CROSS", //9
};
const static char *itemCY2[] = {
"SENSITIVITY", //0 0
"THRESHOLD", //1 1
"SCAN TIME", //2 2
"MASK TIME", //3 3
"EDGE THRE", //4 4
"CURVE TYPE", //6 5
"NOTE BOW", //7 6
"NOTE EDGE", //8 7
};
const static char *itemCY3[] = {
"SENSITIVITY", //0
"THRESHOLD", //1
"SCAN TIME", //2
"MASK TIME", //3
"EDGE THRE", //4
"CUP THRE", //5
"CURVE TYPE", //6
"NOTE BOW", //7
"NOTE EDGE", //8
"NOTE CUP", //9
};
const static char *itemHH[] = {
"SENSITIVITY", //0 0
"THRESHOLD", //1 1
"SCAN TIME", //2 2
"MASK TIME", //3 3
"CURVE TYPE", //6 4
"NOTE OPEN", //7 5
"NOTE CLOSE", //8 6
};
const static char *itemHH2[] = {
"SENSITIVITY", //0 0
"THRESHOLD", //1 1
"SCAN TIME", //2 2
"MASK TIME", //3 3
"EDGE THRE", //4 4
"CURVE TYPE", //6 5
"NOTE OPEN", //7 6
"NOTE CLOSE", //8 7
};
const static char *itemHHC[] = {
"SENSITIVITY", //0 0
"THRESHOLD", //1 1
"SCAN START", //2 2
"SCAN END", //3 3
"PEDAL SENS", //4 4
"CURVE TYPE", //6 5
"NOTE PEDAL", //7 6
"NOTE OPEN E", //8 7
"NOTE CLOSE E", //9 8
};
const static char *showInstrument[] = {
"Pad 1",
"Pad 2",
"Pad 3",
"Pad 4",
"Pad 5",
"Pad 6",
"Pad 7",
"Pad 8",
"Pad 9",
"Pad 10",
"Pad 11",
"Pad 12",
"Pad 13",
"Pad 14",
"Pad 15",
"Pad 16",
"Pad 1",
"Pad 2",
"Pad 3",
"Pad 4",
"Pad 5",
"Pad 6",
"Pad 7",
"Pad 8",
"Pad 9",
"Pad 10",
"Pad 11",
"Pad 12",
"Pad 13",
"Pad 14",
"Pad 15",
"Pad 16",
};
static bool push;
static bool showLCD;
static bool showFlag;
static byte showVelocity;
static byte nameIndex;
static byte nameIndexMax;
static byte showValue = 0;
static byte padIndex = 0;
static byte muxIndex = 0;
static byte Snum = 1; //pad type number
static byte Dnum = 2;
static byte CY2num = 3;
static byte CY3num = 4;
static byte HHnum = 5;
static byte HH2num = 6;
static byte HHCnum = 7;
static byte padType[32]; //if you use more pad, add numer
static bool edit;
static bool editCheck;
static bool editdone;
static bool change;
static byte itemNumber;
static byte itemNumberShow;
static bool buttonState;
static bool buttonState_set;
static bool button_set;
static bool button_up;
static bool button_down;
static bool button_next;
static bool button_back;
static byte UP[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
#ifdef __AVR_ATmega328P__
static int rawValue[16]; //2 * 8chanel Mux
static int rawValue2[16]; //2 * 8chanel Mux
#else
static int rawValue[64]; //8 * 8chanel Mux
static int rawValue2[64]; //8 * 8chanel Mux
#endif
class HelloDrum
{
public:
HelloDrum(byte pin1, byte pin2);
HelloDrum(byte pin1);
void singlePiezoMUX(byte sens, byte thre, byte scan, byte mask);
void singlePiezoMUX2(byte sens, byte thre, byte scan, byte mask);
void singlePiezoMUX();
void dualPiezoMUX(byte sens, byte thre, byte scan, byte mask, byte rimSens, byte rimThre);
void dualPiezoMUX();
void HHMUX(byte sens, byte thre, byte scan, byte mask);
void HHMUX();
void HH2zoneMUX(byte sens, byte thre, byte scan, byte mask, byte edgeThre);
void HH2zoneMUX();
void cymbal3zoneMUX(byte sens, byte thre, byte scan, byte mask, byte edgeThre, byte cupThre);
void cymbal3zoneMUX();
void cymbal2zoneMUX(byte sens, byte thre, byte scan, byte mask, byte edgeThre);
void cymbal2zoneMUX();
void TCRT5000MUX(byte sens, byte thre1, byte thre2, byte scan);
void TCRT5000MUX();
void FSRMUX(byte sens, byte thre, byte scanStart, byte scanEnd, byte pedalSens);
void FSRMUX();
void hihatControlMUX(byte sens, byte thre, byte scanStart, byte scanEnd, byte pedalSens);
void hihatControlMUX();
void singlePiezo(byte sens, byte thre, byte scan, byte mask);
void singlePiezo();
void dualPiezo(byte sens, byte thre, byte scan, byte mask, byte rimSens, byte rimThre);
void dualPiezo();
void HH(byte sens, byte thre, byte scan, byte mask);
void HH();
void HH2zone(byte sens, byte thre, byte scan, byte mask, byte edgeThre);
void HH2zone();
void cymbal3zone(byte sens, byte thre, byte scan, byte mask, byte edgeThre, byte cupThre);
void cymbal3zone();
void cymbal2zone(byte sens, byte thre, byte scan, byte mask, byte edgeThre);
void cymbal2zone();
void TCRT5000(byte sens, byte thre1, byte thre2, byte scan);
void TCRT5000();
void FSR(byte sens, byte thre, byte scanStart, byte scanEnd, byte pedalSens);
void FSR();
void hihatControl(byte sens, byte thre, byte scanStart, byte scanEnd, byte pedalSens);
void hihatControl();
void setCurve(byte curveType);
void settingName(const char *instrumentName);
void settingEnable();
void loadMemory();
void initMemory();
int velocity;
int velocityRim;
int velocityCup;
byte pedalCC;
// int exValue;
byte exTCRT = 0;
byte exFSR = 0;
bool hit;
bool openHH = false;
bool closeHH = false;
bool hitRim;
bool hitCup;
bool choke;
bool sensorFlag;
bool moving;
bool pedalVelocityFlag = false;
bool pedalFlag = true;
bool settingHHC = false;
bool chokeFlag;
char *GetItem(byte i);
byte value;
byte padNum;
byte note;
byte noteRim;
byte noteCup;
byte noteEdge;
byte noteOpen;
byte noteClose;
byte noteOpenEdge;
byte noteCloseEdge;
byte noteCross;
byte threshold1;
byte threshold2;
byte scantime;
byte masktime;
byte sensitivity;
byte curvetype;
byte rimThreshold;
byte rimSensitivity;
private:
byte pin_1;
byte pin_2;
int piezoValue;
int RimPiezoValue;
int sensorValue;
int TCRT;
int fsr;
int firstSensorValue;
int lastSensorValue;
int loopTimes = 0;
unsigned long time_hit;
unsigned long time_end;
unsigned long time_choke;
unsigned long time_hit_pedal_1;
unsigned long time_hit_pedal_2;
void singlePiezoSensing(byte sens, byte thre, byte scanTime, byte maskTime);
void dualPiezoSensing(byte sens, byte thre, byte scanTime, byte maskTime, byte rimSens, byte rimThre);
void cymbal2zoneSensing(byte sens, byte thre, byte scanTime, byte maskTime, byte edgeThre);
void cymbal3zoneSensing(byte sens, byte thre, byte scanTime, byte maskTime, byte edgeThre, byte cupThre);
void TCRT5000Sensing(byte sens, byte thre1, byte thre2, byte scanTime);
void FSRSensing(byte sens, byte thre, byte scanStart, byte scanEnd, byte pedalSens);
int curve(int velocityRaw, int threshold, int sensRaw, byte curveType);
};
class HelloDrumMUX_4051
{
public:
HelloDrumMUX_4051(byte pin1, byte pin2, byte pin3, byte pinA);
void scan();
byte selectPins[3];
byte muxNum;
private:
byte pin_1;
byte pin_2;
byte pin_3;
byte pin_A;
};
class HelloDrumMUX_4067
{
public:
HelloDrumMUX_4067(byte pin1, byte pin2, byte pin3, byte pin4, byte pinA);
void scan();
byte selectPins[4];
byte muxNum;
private:
byte pin_1;
byte pin_2;
byte pin_3;
byte pin_4;
byte pin_A;
};
class HelloDrumMUX_40672
{
public:
HelloDrumMUX_40672(byte pin1, byte pin2, byte pin3, byte pin4, byte pinA);
void scan();
byte selectPins[4];
byte muxNum;
private:
byte pin_1;
byte pin_2;
byte pin_3;
byte pin_4;
byte pin_A;
};
class HelloDrumButton
{
public:
HelloDrumButton(byte pin1, byte pin2, byte pin3, byte pin4, byte pin5);
void readButtonState();
void readButton(bool button_set, bool button_up, bool button_down, bool button_next, bool button_back);
byte GetSettingValue();
byte GetVelocity();
bool GetEditState();
bool GetEditdoneState();
bool GetPushState();
bool GetDisplayState();
const char *GetPadName();
const char *GetSettingItem();
const char *GetHitPad();
int UPDOWN;
int NEXTBACK;
private:
byte pin_1;
byte pin_2;
byte pin_3;
byte pin_4;
byte pin_5;
};
class HelloDrumButtonLcdShield
{
public:
HelloDrumButtonLcdShield(byte pin1);
void readButtonState();
void readButton(bool button_set, bool button_up, bool button_down, bool button_next, bool button_back);
byte GetSettingValue();
byte GetVelocity();
bool GetEditState();
bool GetEditdoneState();
bool GetPushState();
bool GetDisplayState();
const char *GetPadName();
const char *GetSettingItem();
const char *GetHitPad();
int UPDOWN;
int NEXTBACK;
private:
int buttonValue;
byte pin_1;
};
class HelloDrumKnob
{
public:
HelloDrumKnob(byte pin1);
void read();
void readMUX();
int knobValue;
private:
byte pin_1;
};
#endif