-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMemory_Functions_teensy.ino
82 lines (75 loc) · 1.5 KB
/
Memory_Functions_teensy.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
/**
* TeensyBoy
* 1.2.3
* ArduinoBoy Firmware for Teensy 2.0
*
* noizeinabox@gmail.com
* http://noizeinabox.blogspot.com/2012/12/teensyboy.htm
*
*
* Original ArduinoBoy
* Timothy Lamb (trash80@gmail.com)
* https://github.com/trash80/Arduinoboy
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*/
boolean checkMemory()
{
byte chk;
for (int m = 0; m < 4; m++)
{
chk = EEPROM.read(MEM_CHECK + m);
if (chk != defaultMemoryMap[MEM_CHECK + m])
{
return false;
}
}
return true;
}
void initMemory(boolean reinit)
{
if (!alwaysUseDefaultSettings)
{
if (reinit || !checkMemory())
{
for (int m = (MEM_MAX); m >= 0; m--)
{
EEPROM.write(m, defaultMemoryMap[m]);
}
}
loadMemory();
}
else
{
for (int m = 0; m <= MEM_MAX; m++)
{
memory[m] = defaultMemoryMap[m];
}
}
changeTasks();
}
void loadMemory()
{
for (int m = (MEM_MAX); m >= 0; m--)
{
memory[m] = EEPROM.read(m);
}
changeTasks();
}
void saveMemory()
{
for (int m = (MEM_MAX - 1); m >= 0; m--)
{
EEPROM.write(m, memory[m]);
}
changeTasks();
}
void changeTasks()
{
midioutByteDelay = memory[MEM_MIDIOUT_BYTE_DELAY] * memory[MEM_MIDIOUT_BYTE_DELAY + 1];
midioutBitDelay = memory[MEM_MIDIOUT_BIT_DELAY] * memory[MEM_MIDIOUT_BIT_DELAY + 1];
}