-
Notifications
You must be signed in to change notification settings - Fork 0
/
EEPROM.h
112 lines (99 loc) · 4.32 KB
/
EEPROM.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
void setup_EEPROM() {
EEPROM.begin(1024);
byte _byte;
for (byte layout_num = 0; layout_num < NUM_LAYOUT; layout_num++) {
for (byte i = 0; i < NUM_BUTTONS; i++) {
_byte = EEPROM.read(layout_num * 100 + i);
if (_byte != 255) b[i].short_type[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 8 + i);
if (_byte != 255) b[i].short_control[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 16 + i);
if (_byte != 255) b[i].short_ch[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 24 + i);
if (_byte != 255) b[i].short_toggle[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 32 + i);
if (_byte != 255) b[i].snap[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 40 + i);
if (_byte != 255) b[i].long_type[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 48 + i);
if (_byte != 255) b[i].long_control[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 56 + i);
if (_byte != 255) b[i].long_ch[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 64 + i);
if (_byte != 255) b[i].long_toggle[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 364 + i);
if (_byte != 255) b[i].double_type[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 372 + i);
if (_byte != 255) b[i].double_control[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 380 + i);
if (_byte != 255) b[i].double_ch[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 388 + i);
if (_byte != 255) b[i].double_toggle[layout_num] = _byte;
}
for (byte i = 0; i < NUM_LEDS; i++) {
// l[i].led_control[layout_num] = default_leds[layout_num][i];
_byte = EEPROM.read(layout_num * 100 + 72 + i);
if (_byte != 255) l[i].led_type[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 78 + i);
if (_byte != 255) l[i].led_control[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 84 + i);
if (_byte != 255) l[i].led_channel[layout_num] = _byte;
}
for (byte i = 0; i < NUM_ENCODERS; i++) {
_byte = EEPROM.read(layout_num * 100 + 90 + i);
if (_byte != 255) r[i].control[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 92 + i);
if (_byte != 255) r[i].control_hold[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 94 + i);
if (_byte != 255) r[i].channel[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 96 + i);
if (_byte != 255) r[i].channel_hold[layout_num] = _byte;
}
for (byte i = 0; i < NUM_SLIDERS; i++) {
_byte = EEPROM.read(layout_num * 100 + 98 + i);
if (_byte != 255) a[i].control[layout_num] = _byte;
_byte = EEPROM.read(layout_num * 100 + 100 + i);
if (_byte != 255) a[i].channel[layout_num] = _byte;
}
_byte = EEPROM.read(layout_num * 100 + 102);
if (_byte != 255) disp.display_control[layout_num] = _byte;
_byte = EEPROM.read(layout_num + 304);
if (_byte != 255) linked_page[layout_num] = _byte;
}
for (byte i = 0; i < 2; i++) {
// Retrieve Options and send them to Live
_byte = EEPROM.read(350 + i);
if (_byte != 255) options[i] = _byte;
}
for (byte i = 0; i < 10; i++) {
// Retrieve External MIDI
_byte = EEPROM.read(310 + i);
if (_byte != 255) external_MIDI_type[i] = _byte;
_byte = EEPROM.read(320 + i);
if (_byte != 255) external_MIDI_control[i] = _byte;
_byte = EEPROM.read(330 + i);
if (_byte != 255) external_MIDI_channel[i] = _byte;
}
_byte = EEPROM.read(340);
if (_byte != 255) matrix_brightness = _byte; // Retrieve Display Brightness
_byte = EEPROM.read(341);
if (_byte != 255) BRIGHTNESS = _byte; // Retrieve LED Brightness
pixels.setBrightness(BRIGHTNESS);
_byte = EEPROM.read(342);
if (_byte != 255) USB_thru = _byte; // Retrieve USB_thru
_byte = EEPROM.read(343);
if (_byte != 255) SERIAL_thru = _byte; // Retrieve SERIAL_thru
for (byte i = 0; i < NUM_SLIDERS; i++) {
_byte = EEPROM.read(360 + i);
if (_byte != 255) a[i].pedal_min = _byte;
_byte = EEPROM.read(362 + i);
if (_byte != 255) a[i].pedal_max = _byte;
}
}
void clear_EEPROM() {
EEPROM.begin(512);
for (byte i = 0; i < 350; i++) {
EEPROM.write(i, 255);
EEPROM.commit();
}
}