@@ -28,7 +28,7 @@ void KeyDB::loadKeys() {
2828 int position = 1 ;
2929 for (int i = 0 ; i < count; i++) {
3030 // 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++) {
3232 // Add read char to key string.
3333 char readChar = char (EEPROM.read (position));
3434 this ->keys [i].concat (readChar);
@@ -46,13 +46,13 @@ void KeyDB::saveKeys() {
4646 // Loop through the key list.
4747 int keys = 0 ;
4848 int position = 1 ;
49- for (int i = 0 ; i < DB_KEY_MAX ; i++) {
49+ for (int i = 0 ; i < this -> keyMax ; i++) {
5050 // Break out of array if empty.
5151 if (this ->keys [i] == " " )
5252 break ;
5353
5454 // 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++) {
5656 // Write key char to storage.
5757 EEPROM.update (position, this ->keys [i][k]);
5858
@@ -82,10 +82,10 @@ void KeyDB::addKey(String key) {
8282 this ->keys [keys] = key;
8383
8484 // Find position for next input.
85- int position = (keys * DB_KEY_LENGTH ) + 1 ;
85+ int position = (keys * this -> keyLength ) + 1 ;
8686
8787 // 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++) {
8989 // Write key char to storage.
9090 EEPROM.update (position, this ->keys [keys][k]);
9191
@@ -108,7 +108,7 @@ void KeyDB::removeKey(String key) {
108108
109109 // Loop through keys.
110110 int shifting = 0 ;
111- for (int i = 0 ; i < DB_KEY_MAX ; i++) {
111+ for (int i = 0 ; i < this -> keyMax ; i++) {
112112 // Shift indexes if shifting.
113113 if (shifting)
114114 this ->keys [i - 1 ] = this ->keys [i];
@@ -137,7 +137,7 @@ bool KeyDB::keyExists(String key) {
137137 key = this ->keyLengthen (key);
138138
139139 // Loop through keys.
140- for (int i = 0 ; i < DB_KEY_MAX ; i++) {
140+ for (int i = 0 ; i < this -> keyMax ; i++) {
141141 // Return out of array if empty.
142142 if (this ->keys [i] == " " )
143143 return false ;
@@ -157,7 +157,7 @@ bool KeyDB::keyExists(String key) {
157157 */
158158String KeyDB::keyLengthen (String key) {
159159 // Add zeros untill correct char length.
160- while (key.length () < DB_KEY_LENGTH ) {
160+ while (key.length () < this -> keyLength ) {
161161 key = ' 0' + key;
162162 }
163163
0 commit comments