-
Notifications
You must be signed in to change notification settings - Fork 1
/
Display.ino
419 lines (356 loc) · 11.4 KB
/
Display.ino
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
415
416
417
418
419
int color = 0;
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void displayStartup(){
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
display.clearDisplay(); // clears the screen and buffer
display.display(); // show splashscreen
display.setTextSize(4);
display.setTextColor(WHITE);
display.setCursor(6,0);
display.println("ZETA");
display.setCursor(6,32);
display.println("±OHM±");
display.display();
// display.startscrollleft(0, 15);
Serial.println("display 1");
nonBlockingRainbow(2);
delay(100);
nonBlockingRainbow(2);
delay(100);
nonBlockingRainbow(2);
delay(100);
nonBlockingRainbow(2);
delay(100);
nonBlockingRainbow(2);
delay(100);
nonBlockingRainbow(2);
delay(100);
Serial.println("display 2");
// display.invertDisplay(1);
Serial.println("display 3");
nonBlockingRainbow(1);
delay(100);
Serial.println("display 4");
// display.invertDisplay(0);
//display.clearDisplay(); // clears the screen and buffer
// display.stopscroll();
display.display();
}
void displayLoop() {
//Serial.println(F("displayStart"));
if (displayTimer > 10000) {
display.clearDisplay(); // clears the screen and buffer
if (settingMode == 0){
stepDisplay();
} else if (settingMode == 1){
sequenceMenuDisplay();
} else if (settingMode == 2){
globalMenuDisplay();
} else {
menuItem(settingMode);
}
display.display();
}
}
void menuItem(uint8_t menuItem){
uint8_t globalSkip[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
uint8_t spedSkip[] = {1,2,3,5,6,7,8,9,10,11,12,13,14,15};
uint8_t patternSkip[] = {8,9,10,11,12,13,14,15};
uint8_t generatorSkip[] = {1,2,3,5,6,7,9,10,11,12,13,14,15};
switch (menuItem){
case GLOBAL_MIDI:
nonBlockingRainbow(5, globalSkip, 15 );
display.setTextColor(WHITE);
display.setCursor(9,1);
display.setTextSize(2);
display.println("MIDI MENU" );
display.setCursor(0,24);
display.setTextSize(1);
display.print(" Midi Clock: " );
if (extClock == true){
display.println("External");
} else {
display.println("Internal");
};
break;
case SEQUENCE_SPED:
nonBlockingRainbow(5, spedSkip, 14 );
display.setTextColor(WHITE);
display.setCursor(0,1);
display.setTextSize(2);
display.println("STEP SPEED" );
display.setCursor(0,24);
display.setTextSize(1);
display.println("Speed = Steps/Beats" );
if (menuSelection == 0){
display.setTextColor(BLACK, WHITE);
}
display.print(" Steps: " );
display.println(String(sequence[selectedSequence].stepCount));
display.setTextColor(WHITE);
if (menuSelection == 1){
display.setTextColor(BLACK, WHITE);
}
display.print(" Beats: " );
display.println(String(sequence[selectedSequence].beatCount));
display.setTextColor(WHITE);
break;
case SEQUENCE_GENE:
nonBlockingRainbow(2, generatorSkip, 13 );
display.setTextColor(WHITE);
display.setCursor(0,1);
display.setTextSize(1);
display.println("Sequence Generator");
display.setCursor(0,20);
display.println("Clear All Notes");
display.println("Random some notes");
display.println("Random all notes");
display.println("delete save file");
break;
case TEMPO_SET:
nonBlockingRainbow(5, globalSkip, 16 );
display.setTextColor(WHITE);
display.setCursor(0,0);
display.setTextSize(2);
display.println("TEMPO" );
display.setCursor(30,20);
display.println(String(tempo));
display.setCursor(0,40);
display.setTextSize(1);
display.println("Manual Entry");
display.setCursor(0,50);
display.println("Tap Tempo");
break;
case PATTERN_SELECT:
nonBlockingRainbow(3, patternSkip, 8 );
display.setTextColor(WHITE);
display.setCursor(0,0);
display.setTextSize(3);
display.println("PATTERN");
display.setCursor(0,30);
display.println("SELECT" );
break;
case SEQUENCE_SELECT:
nonBlockingRainbow(3, patternSkip, 8 );
display.setTextColor(WHITE);
display.setCursor(0,0);
display.setTextSize(3);
display.println("SEQUENCE");
display.setCursor(0,30);
display.println("SELECT" );
break;
case SEQUENCE_QUAN:
nonBlockingRainbow(2, generatorSkip, 13 );
display.setTextColor(WHITE);
display.setCursor(0,1);
display.setTextSize(1);
display.println("Note Quantizer");
display.setCursor(0,20);
display.println("Quantize On - B Minor");
display.println("Quantize On - D Major");
display.println("Quantize Off");
break;
case SEQUENCE_INST:
display.setTextColor(WHITE);
display.setCursor(0,1);
display.setTextSize(1);
display.println("Instrument Select");
display.setCursor(0,20);
if (menuSelection == 0){
display.setTextColor(BLACK, WHITE);
}
display.println(instrumentNames[sequence[selectedSequence].instrument] );
if (menuSelection == 1){
display.setTextColor(BLACK, WHITE);
} else {
display.setTextColor(WHITE, BLACK);
}
display.println("volume: " + String(sequence[selectedSequence].volume) );
if (menuSelection == 2){
display.setTextColor(BLACK, WHITE);
} else {
display.setTextColor(WHITE, BLACK);
}
display.println("bank: " + String(sequence[selectedSequence].bank) );
break;
// case SEQUENCE_TRAN:
// nonBlockingRainbow(2, generatorSkip, 13 );
// display.setTextColor(WHITE);
// display.setCursor(0,1);
// display.setTextSize(1);
// display.println("Note Transposer - NOT IMPLEMENTED YET");
// display.setCursor(0,20);
// display.println("Transpose 12 notes");
// display.println("Transpose Off");
//
break;
case GLOBAL_FILE:
display.setTextColor(WHITE);
display.setCursor(0,1);
display.setTextSize(1);
display.println("Delete Save File?");
break;
default:
display.setTextColor(WHITE);
display.setCursor(0,1);
display.setTextSize(1);
display.println("settingMode " + String(menuItem) + " not yet defined");
break;
};
}
void sequenceMenuDisplay(){
uint8_t skip[] = {11,15};
nonBlockingRainbow(5, skip, 2 );
display.setTextColor(WHITE);
display.setCursor(16,1);
display.setTextSize(2);
display.println("SEQUENCE");
display.setTextSize(1);
display.setCursor(7,21);
display.print("NAME ");
display.print("SPED ");
display.print("TRAN ");
display.print("INST ");
display.setCursor(7,33);
display.print("QUAN ");
display.print("EUCL ");
display.print("GENE ");
display.print("ORDE ");
display.setCursor(7,45);
display.print("RAND ");
display.print("POSI ");
display.print("GLID ");
display.print(" ");
display.setCursor(7,57);
display.print("MIDI ");
display.print("{CV} ");
display.print("GATE ");
display.print(" ");
}
void globalMenuDisplay(){
// Second Press: Glbal Menu
// MIDI SAVE LOAD
uint8_t skip[] = {4,5,6,7,8,9,10,11,12,13,14,15};
nonBlockingRainbow(10, skip, 12 );
display.setTextColor(WHITE);
display.setCursor(16,1);
display.setTextSize(2);
display.println("~GLOBAL~");
display.setTextSize(1);
display.setCursor(7,21);
display.print("MIDI ");
display.print("SAVE ");
display.print("LOAD ");
display.print("FILE ");
display.setCursor(7,33);
}
void stepDisplay(){
// MAIN STEP DISPLAY
// display.drawTriangle( 120,0,
// 113,9,
// 127,9, WHITE);
// if (tempoBlip == true) {
// display.fillTriangle( 120,0,
// 113,9,
// 127,9, WHITE);
// }
// if (blipTimer > 20000) {
// tempoBlip = false;
// }
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(86,45);
display.println( String(selectedSequence) + "|" + String(currentPattern) );
display.setTextSize(1);
display.setCursor(86,35);
display.setTextColor(WHITE);
if (tempoBlip) { display.setTextColor(BLACK, WHITE); };
if (extClock == true) {
display.println("EXT");
} else {
display.println(String(tempo));
}
display.setTextColor(WHITE);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
if (stepMode == 0){
display.setTextColor(BLACK, WHITE);
}
display.setTextSize(3);
display.print(
midiNotes[sequence[selectedSequence].stepData[selectedStep].pitch][0]
);
display.setTextSize(2);
display.print(
midiNotes[sequence[selectedSequence].stepData[selectedStep].pitch][1]
);
display.print(
midiNotes[sequence[selectedSequence].stepData[selectedStep].pitch][2]
);
display.print(
midiNotes[sequence[selectedSequence].stepData[selectedStep].pitch][3]
);
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(50,0);
if (stepMode == 2){
display.setTextColor(BLACK, WHITE);
}
if (sequence[selectedSequence].stepData[selectedStep].gateType != 0){
display.println(" gate: " + String(sequence[selectedSequence].stepData[selectedStep].gateType));
} else {
display.println(" ~rest~");
}
display.setTextColor(WHITE);
display.setCursor(50,8);
display.println(" velo: " + String(sequence[selectedSequence].stepData[selectedStep].velocity));
if (stepMode == 1){
display.setTextColor(BLACK, WHITE);
}
display.setCursor(50,16);
display.println(" beat: " + String(sequence[selectedSequence].stepData[selectedStep].gateLength));
// display.println(String(sequence[selectedSequence].gateLength[selectedStep]) + " Steps"
display.setTextColor(WHITE);
if (playing) {
display.fillTriangle(
105,5,
105,25,
125,15,
WHITE
);
} else {
display.fillRoundRect(
105,5,
8, 20,
0, WHITE
);
display.fillRoundRect(
117,5,
8, 20,
0, WHITE
);
}
display.setCursor(0,24);
if (stepMode == 3){
display.setTextColor(BLACK, WHITE);
}
display.println("Time: " +String(sequence[selectedSequence].stepCount) + "/" + String(sequence[selectedSequence].beatCount));
display.setTextColor(WHITE);
//display.println(F("tempo:") + String(sequence[selectedSequence].tempo));
display.println( "as: " + String(sequence[selectedSequence].activeStep) + " bt: " + String(sequence[selectedSequence].beatTracker));
//display.println(F("stepCount: ") + String(sequence[selectedSequence].stepCount));
// display.println("millis: " + String(millis()));
//display.println("activeSection: " + activeSection);
//display.println("Playing: " + String(playing));
// display.println("Peak: " + String(peak1.read()) + " 2: " + String(peak2.read()));
// display.println("CPU:" + String(AudioProcessorUsage()) + " MAX:" + String(AudioProcessorUsageMax()));
// display.println("MEM:" + String(AudioMemoryUsage()) + " MAX:" + String(AudioMemoryUsageMax()));
// display.println(F("avgPeriod:") + String(avgPeriod));
// display.println(F("avgLoopTime:") + String(avgLoopTime));
// display.println(F("avgRuntime:") + String(avgRuntime));
display.println("inst: " + String(sequence[selectedSequence].instrument));
display.println("millis: " + String(millis()));
}