Fixed EEPROM address issue

This commit is contained in:
Christoffer Martinsson 2018-02-20 10:38:56 +01:00
parent dcfd4944de
commit 9bdbf391b7

View File

@ -84,8 +84,7 @@ bool lock_disable = false;
#define RFID_STOP_BYTE 0x03 // stop byte
#define RFID_TAG_BYTES 10 // number of bytes in package that represent the tag
#define RFID_TAGS 10 // Number of tags to be supported to store in EEPROM
#define EEPROM_CURRENT_TAG_ADDRESS 0 // Addres for storing current address in the tag memory
#define EEPROM_TAG_START_ADDRESS 1 // Start addres for storing RFID tags
#define EEPROM_TAG_START_ADDRESS 0 // Start addres for storing RFID tags
int rfid_current_checksum = 0;
int rfid_package[RFID_PACKAGE_LENGHT];
int rfid_package_pos = 0;
@ -168,7 +167,7 @@ void update_rfid() {
if (rfid_read == RFID_STOP_BYTE) {
CONSOLE_SERIAL.println("RFID tag detected");
if (rfid_store_tag) {
int rfid_eeprom_pos = rfid_store_tag_nbr-1 * RFID_TAG_BYTES;
int rfid_eeprom_pos = (rfid_store_tag_nbr-1) * RFID_TAG_BYTES;
for (int i = 0; i < RFID_TAG_BYTES; i++) {
EEPROM.write(rfid_eeprom_pos, rfid_package[i + 1]);
rfid_tags[rfid_store_tag_nbr-1][i] = rfid_package[i + 1];
@ -344,7 +343,7 @@ void loop() {
// Check button status
if (btn_lock == true){
if (rfid_store_tag_nbr > 0 && rfid_store_tag == false){
int rfid_eeprom_pos = rfid_store_tag_nbr-1 * RFID_TAG_BYTES;
int rfid_eeprom_pos = (rfid_store_tag_nbr-1) * RFID_TAG_BYTES;
for (int i = 0; i < RFID_TAG_BYTES; i++) {
EEPROM.write(rfid_eeprom_pos,0xFF);
rfid_eeprom_pos++;