@@ -28,7 +28,7 @@ void KeyDB::loadKeys() {
28
28
int position = 1 ;
29
29
for (int i = 0 ; i < count; i++) {
30
30
// Loop through the key char length.
31
- for (int k = 0 ; k < DB_KEY_LENGTH ; k++) {
31
+ for (int k = 0 ; k < this -> keyLength ; k++) {
32
32
// Add read char to key string.
33
33
char readChar = char (EEPROM.read (position));
34
34
this ->keys [i].concat (readChar);
@@ -46,13 +46,13 @@ void KeyDB::saveKeys() {
46
46
// Loop through the key list.
47
47
int keys = 0 ;
48
48
int position = 1 ;
49
- for (int i = 0 ; i < DB_KEY_MAX ; i++) {
49
+ for (int i = 0 ; i < this -> keyMax ; i++) {
50
50
// Break out of array if empty.
51
51
if (this ->keys [i] == " " )
52
52
break ;
53
53
54
54
// Loop through the key char length.
55
- for (int k = 0 ; k < DB_KEY_LENGTH ; k++) {
55
+ for (int k = 0 ; k < this -> keyLength ; k++) {
56
56
// Write key char to storage.
57
57
EEPROM.update (position, this ->keys [i][k]);
58
58
@@ -82,10 +82,10 @@ void KeyDB::addKey(String key) {
82
82
this ->keys [keys] = key;
83
83
84
84
// Find position for next input.
85
- int position = (keys * DB_KEY_LENGTH ) + 1 ;
85
+ int position = (keys * this -> keyLength ) + 1 ;
86
86
87
87
// Loop through the key char length.
88
- for (int k = 0 ; k < DB_KEY_LENGTH ; k++) {
88
+ for (int k = 0 ; k < this -> keyLength ; k++) {
89
89
// Write key char to storage.
90
90
EEPROM.update (position, this ->keys [keys][k]);
91
91
@@ -108,7 +108,7 @@ void KeyDB::removeKey(String key) {
108
108
109
109
// Loop through keys.
110
110
int shifting = 0 ;
111
- for (int i = 0 ; i < DB_KEY_MAX ; i++) {
111
+ for (int i = 0 ; i < this -> keyMax ; i++) {
112
112
// Shift indexes if shifting.
113
113
if (shifting)
114
114
this ->keys [i - 1 ] = this ->keys [i];
@@ -137,7 +137,7 @@ bool KeyDB::keyExists(String key) {
137
137
key = this ->keyLengthen (key);
138
138
139
139
// Loop through keys.
140
- for (int i = 0 ; i < DB_KEY_MAX ; i++) {
140
+ for (int i = 0 ; i < this -> keyMax ; i++) {
141
141
// Return out of array if empty.
142
142
if (this ->keys [i] == " " )
143
143
return false ;
@@ -157,7 +157,7 @@ bool KeyDB::keyExists(String key) {
157
157
*/
158
158
String KeyDB::keyLengthen (String key) {
159
159
// Add zeros untill correct char length.
160
- while (key.length () < DB_KEY_LENGTH ) {
160
+ while (key.length () < this -> keyLength ) {
161
161
key = ' 0' + key;
162
162
}
163
163
0 commit comments