This repository was archived by the owner on Feb 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.h
120 lines (116 loc) · 3.41 KB
/
interface.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
#pragma once
// Effective Nov 15, 2024, the portion of the code related to setting the key and rotary pins
// is moved to "hwRotary.h" and "hwKeys.h". This section is solely for interpreting
// input presses.
/*
void setupHardware() {
if (Hardware_Version == HARDWARE_V1_2) {
midiD = MIDID_USB | MIDID_SER;
audioD = AUDIO_PIEZO | AUDIO_AJACK;
menuPageSynth.addMenuItem(menuItemAudioD, 2);
globalBrightness = BRIGHT_DIM;
setLEDcolorCodes();
rotary.invertDirection(true);
}
}
*/
void interface_interpret_hexes() {
// only do this if the pingrid object is free
if (!(pinGrid.is_background_process_complete())) {
return;
}
// read in the new pin state completely first
for (auto& h : hexBoard.keys) {
h.prevState = h.btnState;
int r = pinGrid.read_key_state(h.hwKey);
h.btnState = r;
}
for (auto& h : hexBoard.commands) {
h.prevState = h.btnState;
uint r = pinGrid.read_key_state(h.hwKey);
h.btnState = r;
}
// release pingrid object
pinGrid.resume_background_process();
// then cycle each key and perform actions
for (auto& h : hexBoard.keys) {
sendToLog(
" pxl " + std::to_string(h.pixel)
+ " hw " + std::to_string(h.hwKey)
+ " hex " + std::to_string(h.coord.x) + "," + std::to_string(h.coord.y)
+ " note " + std::to_string(h.note)
+ " scal " + std::to_string(h.inScale)
+ " btn " + std::to_string((h.btnState << 1) | h.prevState)
);
//if (h.inScale || (!scaleLock)) {
switch ((h.btnState << 1) | h.prevState) {
case 2: // just pressed
//tryMIDInoteOn(h);
//trySynthNoteOn(h);
break;
case 1: // just released
//tryMIDInoteOff(h);
//trySynthNoteOff(h);
break;
}
//}
}
for (auto& h : hexBoard.commands) {
sendToLog(
" pxl " + std::to_string(h.pixel)
+ " hw " + std::to_string(h.hwKey)
+ " hex " + std::to_string(h.coord.x) + "," + std::to_string(h.coord.y)
+ " cmd " + std::to_string(h.cmd)
+ " btn " + std::to_string((h.btnState << 1) | h.prevState)
);
switch ((h.btnState << 1) | h.prevState) {
case 2: // just pressed
switch (h.cmd) {
//case CMDB + 3:
//toggleWheel = !toggleWheel;
// break;
default:
// the rest should all be taken care of within the wheelDef structure
break;
}
default: // inactive
break;
}
}
}
/*
void interface_update_wheels() {
velWheel.setTargetValue();
bool upd = velWheel.updateValue(runTime);
if (upd) {
sendToLog("vel became " + std::to_string(velWheel.curValue));
}
if (toggleWheel) {
pbWheel.setTargetValue();
upd = pbWheel.updateValue(runTime);
if (upd) {
sendMIDIpitchBendToCh1();
updateSynthWithNewFreqs();
}
} else {
modWheel.setTargetValue();
upd = modWheel.updateValue(runTime);
if (upd) {
sendMIDImodulationToCh1();
}
}
}
void interface_interpret_rotary() {
if (menu.readyForKey()) {
if (rotary.getClickFromBuffer()) {
menu.registerKeyPress(GEM_KEY_OK);
screenTime = 0;
}
int getTurn = rotary.getTurnFromBuffer();
if (getTurn != 0) {
menu.registerKeyPress((getTurn > 0) ? GEM_KEY_UP : GEM_KEY_DOWN);
screenTime = 0;
}
}
}
*/