Kód: Egész kijelölése
/***
Advance to the next address, when at the end restart at the beginning.
Larger AVR processors have larger EEPROM sizes, E.g:
- Arduno Duemilanove: 512b EEPROM storage.
- Arduino Uno: 1kb EEPROM storage.
- Arduino Mega: 4kb EEPROM storage.
Rather than hard-coding the length, you should use the pre-provided length function.
This will make your code portable to all AVR processors.
As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an
EEPROM address is also doable by a bitwise and of the length - 1.
++address &= EEPROM.length() - 1;
***/
boolean EEPoverflow(void){
unsigned int address = addr + bytes;
boolean error = true;
if (address >= EEPROM.length()) {
Serial.print(address);
Serial.print("! EEPROM cimzes ERROR! Max Cim: "); // jelzi a hibát
Serial.println(EEPROM.length());
error = false;
}
return error;
}
És hiba esetén? Szintén megszakad a feldolgozás!
Forráskod, majd tesztelés után!