Skip to content

Commit

Permalink
update readme and fix minor errors
Browse files Browse the repository at this point in the history
* Update bash command for library installation.
* change: small EEPROMs (1 - 2Kbits) are not supported because pageSize = 8 < 10 (max byteNumber in MFRC522).
* change: using pages in the `EraseAllCards()` function to speed up writing.
  • Loading branch information
GogoVega committed May 24, 2022
1 parent ea1e37c commit 0368c76
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Go to the Libraries Manager on [PlatformIO](https://platformio.org/platformio-id
Or use `platformIO Core CLI` and paste the following command:

```bash
pio lib install "gogovega/RFID to EEPROM@^1.1.0"
pio pkg install --library "gogovega/RFID to EEPROM@^1.1.0"
```

## How It Works
Expand Down Expand Up @@ -58,7 +58,6 @@ void begin(twiClockFreq_t twiFreq);
Use one of the enumerations below to set EEPROM Size:
```
{
RFIDtoEEPROM_I2C::kbits_2,
RFIDtoEEPROM_I2C::kbits_4,
RFIDtoEEPROM_I2C::kbits_8,
RFIDtoEEPROM_I2C::kbits_16,
Expand Down Expand Up @@ -101,6 +100,7 @@ This library contains several functions:
## Future Features
- Support for small I2C EEPROMs (1 - 2Kbits).
- Increase the number of recordable Cards (currently set to 255).
- Improve error handling.
Expand Down
12 changes: 7 additions & 5 deletions src/Card/Card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ void Card::ClearCardNumber()
*/
void Card::EraseAllCards()
{
for (uint32_t n = 0; n < Code::length(); n++)
byte Code[_pageSize] = {};

for (uint32_t n = 0; n < (Code::length() / _pageSize); n++)
{
Code::write(n, 0);
Code::write((n * _pageSize), Code, _pageSize);
}
}

Expand All @@ -86,7 +88,7 @@ void Card::CardRestoration(uint8_t nbr)
{
/* Uncomment if you want to reset the Card
byte Code[_byteNumber] = {};
Code::Write(OFFSET(nbr), Code, _byteNumber);
Code::write(OFFSET(nbr), Code, _byteNumber);
*/

Code::write(0, nbr);
Expand Down Expand Up @@ -125,7 +127,7 @@ bool Card::SaveCard(uint8_t *Code, uint8_t size)
const uint8_t nbr = CardNumber();

// if size different from Constructor or better than 16
if ((size != _byteNumber) || (size > 16))
if ((size != _byteNumber) || (size > _pageSize))
return (NULL);

// if Number of Cards over limit!
Expand Down Expand Up @@ -160,7 +162,7 @@ bool Card::CardCheck(uint8_t *Code, uint8_t size)
byte CodeRead[_byteNumber];

// if size different from Constructor or better than 16
if ((size != _byteNumber) || (size > 16))
if ((size != _byteNumber) || (size > _pageSize))
return (NULL);

for (uint8_t i = 0; i < nbr; i++)
Expand Down
1 change: 1 addition & 0 deletions src/Card/Card.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Card : protected Code
void CardRestoration(uint8_t nbr);
uint8_t _byteNumber;
uint8_t _maxCards;
uint8_t _pageSize = 16;
};

#endif // _Card_h
1 change: 0 additions & 1 deletion src/RFIDtoEEPROM/RFIDtoEEPROM.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class RFIDtoEEPROM_I2C : public Card
//EEPROM size in kbits.
enum eeprom_size_t
{
kbits_2 = 2,
kbits_4 = 4,
kbits_8 = 8,
kbits_16 = 16,
Expand Down

0 comments on commit 0368c76

Please sign in to comment.