├── extras ├── Documentation │ ├── html │ │ ├── bc_s.png │ │ ├── open.png │ │ ├── closed.png │ │ ├── doxygen.png │ │ ├── nav_f.png │ │ ├── nav_h.png │ │ ├── tab_a.png │ │ ├── tab_b.png │ │ ├── tab_h.png │ │ ├── tab_s.png │ │ ├── tabs.css │ │ ├── index.html │ │ ├── files.html │ │ ├── annotated.html │ │ ├── classes.html │ │ ├── class_e_e_p_r_o_m_var-members.html │ │ ├── functions_func.html │ │ ├── functions.html │ │ ├── class_e_e_p_r_o_m_var.html │ │ ├── _e_e_p_r_o_m_var_8h_source.html │ │ ├── class_e_e_p_r_o_m_class_ex-members.html │ │ ├── doxygen.css │ │ ├── _e_e_p_r_o_mex_8h_source.html │ │ └── class_e_e_p_r_o_m_class_ex.html │ └── Documentation.html └── EEPROM wear calculations.ods ├── library.properties ├── library.json ├── .travis.yml ├── LICENSE.md ├── keywords.txt ├── EEPROMVar.h ├── examples ├── EEPROMVar │ └── EEPROMVar.ino └── EEPROMEx │ └── EEPROMEx.ino ├── EEPROMex.h ├── README.md └── EEPROMex.cpp /extras/Documentation/html/bc_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/Documentation/html/bc_s.png -------------------------------------------------------------------------------- /extras/Documentation/html/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/Documentation/html/open.png -------------------------------------------------------------------------------- /extras/Documentation/html/closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/Documentation/html/closed.png -------------------------------------------------------------------------------- /extras/Documentation/html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/Documentation/html/doxygen.png -------------------------------------------------------------------------------- /extras/Documentation/html/nav_f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/Documentation/html/nav_f.png -------------------------------------------------------------------------------- /extras/Documentation/html/nav_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/Documentation/html/nav_h.png -------------------------------------------------------------------------------- /extras/Documentation/html/tab_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/Documentation/html/tab_a.png -------------------------------------------------------------------------------- /extras/Documentation/html/tab_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/Documentation/html/tab_b.png -------------------------------------------------------------------------------- /extras/Documentation/html/tab_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/Documentation/html/tab_h.png -------------------------------------------------------------------------------- /extras/Documentation/html/tab_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/Documentation/html/tab_s.png -------------------------------------------------------------------------------- /extras/EEPROM wear calculations.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thijse/Arduino-EEPROMEx/HEAD/extras/EEPROM wear calculations.ods -------------------------------------------------------------------------------- /extras/Documentation/Documentation.html: -------------------------------------------------------------------------------- 1 |

EEPROMEx documentation

2 |

Browse the EEPROMEx documentation

3 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=EEPROMEx 2 | version=1.0.0 3 | author=Thijs Elenbaas 4 | maintainer=Thijs Elenbaas 5 | sentence=Extension of the standard Arduino EEPROM library. 6 | paragraph=Extended for reading and writing basic types, structs, strings, arrays and more. 7 | category=Data Storage 8 | url=http://playground.arduino.cc/Code/EEPROMex 9 | architectures=* 10 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "EEPROMEx", 3 | "keywords": "eeprom", 4 | "description": "Extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.", 5 | "authors": 6 | [ 7 | { 8 | "name": "Thijs Elenbaas" 9 | } 10 | ], 11 | "repository": 12 | { 13 | "type": "git", 14 | "url": "https://github.com/thijse/Arduino-EEPROMEx.git" 15 | }, 16 | "frameworks": "arduino" 17 | } 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | before_install: 3 | - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16" 4 | - sleep 3 5 | - export DISPLAY=:1.0 6 | - wget http://downloads.arduino.cc/arduino-1.8.1-linux64.tar.xz 7 | - tar xf arduino-1.8.1-linux64.tar.xz 8 | - sudo mv arduino-1.8.1 /usr/local/share/arduino 9 | - sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino 10 | install: 11 | - ln -s $PWD /usr/local/share/arduino/libraries/EEPROMEx 12 | script: 13 | - arduino --verify --board arduino:avr:uno $PWD/examples/EEPROMEx/EEPROMEx.ino 14 | notifications: 15 | email: 16 | on_success: change 17 | on_failure: change 18 | 19 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # LGPL License 2 | -------------- 3 | Copyright (c) 2012 4 | Thijs Elenbaas 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For EEPROMEx 3 | ####################################### 4 | 5 | ####################################### 6 | # Methods and Functions EEPROMEx (KEYWORD2) 7 | ####################################### 8 | 9 | isReady KEYWORD2 10 | setMemPool KEYWORD2 11 | setMaxAllowedWrites KEYWORD2 12 | getAddress KEYWORD2 13 | 14 | read KEYWORD2 15 | readByte KEYWORD2 16 | readInt KEYWORD2 17 | readLong KEYWORD2 18 | readFloat KEYWORD2 19 | readDouble KEYWORD2 20 | readBlock KEYWORD2 21 | 22 | write KEYWORD2 23 | writeByte KEYWORD2 24 | writeInt KEYWORD2 25 | writeLong KEYWORD2 26 | writeFloat KEYWORD2 27 | writeDouble KEYWORD2 28 | writeBlock KEYWORD2 29 | 30 | update KEYWORD2 31 | updateByte KEYWORD2 32 | updateInt KEYWORD2 33 | updateLong KEYWORD2 34 | updateFloat KEYWORD2 35 | updateDouble KEYWORD2 36 | updateBlock KEYWORD2 37 | 38 | ####################################### 39 | # Instances (KEYWORD2) 40 | ####################################### 41 | 42 | EEPROMEx KEYWORD2 43 | 44 | ####################################### 45 | # Constants (LITERAL1) 46 | ####################################### 47 | 48 | -------------------------------------------------------------------------------- /extras/Documentation/html/tabs.css: -------------------------------------------------------------------------------- 1 | .tabs, .tabs2, .tabs3 { 2 | background-image: url('tab_b.png'); 3 | width: 100%; 4 | z-index: 101; 5 | font-size: 13px; 6 | } 7 | 8 | .tabs2 { 9 | font-size: 10px; 10 | } 11 | .tabs3 { 12 | font-size: 9px; 13 | } 14 | 15 | .tablist { 16 | margin: 0; 17 | padding: 0; 18 | display: table; 19 | } 20 | 21 | .tablist li { 22 | float: left; 23 | display: table-cell; 24 | background-image: url('tab_b.png'); 25 | line-height: 36px; 26 | list-style: none; 27 | } 28 | 29 | .tablist a { 30 | display: block; 31 | padding: 0 20px; 32 | font-weight: bold; 33 | background-image:url('tab_s.png'); 34 | background-repeat:no-repeat; 35 | background-position:right; 36 | color: #283A5D; 37 | text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); 38 | text-decoration: none; 39 | outline: none; 40 | } 41 | 42 | .tabs3 .tablist a { 43 | padding: 0 10px; 44 | } 45 | 46 | .tablist a:hover { 47 | background-image: url('tab_h.png'); 48 | background-repeat:repeat-x; 49 | color: #fff; 50 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 51 | text-decoration: none; 52 | } 53 | 54 | .tablist li.current a { 55 | background-image: url('tab_a.png'); 56 | background-repeat:repeat-x; 57 | color: #fff; 58 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 59 | } 60 | -------------------------------------------------------------------------------- /extras/Documentation/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: Main Page 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 |
47 |
48 |
49 |
EEPROMEx Documentation
50 |
51 |
52 |
53 | 54 | 55 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /EEPROMVar.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | EEPROMvar.h - EEPROM variable library 5 | Copyright (c) 2012 Thijs Elenbaas. All right reserved. 6 | 7 | based on class by AlphaBeta 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef EEPROMVAR_h 25 | #define EEPROMVAR_h 26 | 27 | template class EEPROMVar 28 | { 29 | public: 30 | EEPROMVar(const T& init): 31 | var(init), 32 | address(EEPROM.getAddress(sizeof(T))) 33 | { 34 | } 35 | 36 | operator T () { 37 | return var; 38 | } 39 | EEPROMVar &operator=(const T& val) { 40 | var = val; 41 | return *this; 42 | } 43 | 44 | void operator+=(T val) { 45 | var += T(val); 46 | } 47 | void operator-=(T val) { 48 | var -= T(val); 49 | } 50 | void operator++(int) { 51 | var += T(1); 52 | } 53 | void operator--(int) { 54 | var -= T(1); 55 | } 56 | void operator++() { 57 | var += T(1); 58 | } 59 | void operator--() { 60 | var -= T(1); 61 | } 62 | template 63 | void operator /= (V divisor) { 64 | var = var / divisor; 65 | } 66 | template 67 | void operator *= (V multiplicator) { 68 | var = var * multiplicator; 69 | } 70 | void save(){ 71 | EEPROM.writeBlock(address, var); 72 | } 73 | 74 | void update(){ 75 | EEPROM.updateBlock(address, var); 76 | } 77 | 78 | int getAddress(){ 79 | return address; 80 | } 81 | 82 | void restore(){ 83 | EEPROM.readBlock(address, var); 84 | } 85 | protected: 86 | T var; 87 | int address; 88 | }; 89 | 90 | #endif //EEPROMVAR_h 91 | -------------------------------------------------------------------------------- /examples/EEPROMVar/EEPROMVar.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * EEPROMVar 3 | * 4 | * Demonstrates the usage of EEPROMvar. A c++ OOP approach 5 | * where a variable can store and restore itself from EEPROM 6 | * This example code is in the public domain. 7 | * Thijs Elenbaas, 2012-2017 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | // start reading from the first byte (address 120) of the EEPROM 14 | 15 | const int maxAllowedWrites = 20; 16 | const int memBase = 120; 17 | 18 | void readAndWriteVar(EEPROMVar &floatVar) { 19 | Serial.println("----------------------------------------------"); 20 | Serial.println("writing and retreiving EEPROMVar of type float"); 21 | Serial.println("----------------------------------------------"); 22 | 23 | floatVar = 10.5; // EEPROMVar supports = operator 24 | floatVar++; // EEPROMVar supports ++ operator 25 | floatVar+=8.5; // EEPROMVar supports += operator 26 | floatVar/=2; // EEPROMVar supports /= operator 27 | 28 | float input = floatVar; 29 | floatVar.save(); // store EEPROMVar to EEPROM 30 | 31 | floatVar = 0.0; // reset 32 | floatVar.restore(); // restore EEPROMVar to EEPROM 33 | 34 | Serial.print("adress: "); 35 | Serial.println(floatVar.getAddress()); 36 | Serial.print("input: "); 37 | Serial.println(input); 38 | Serial.print("output: "); 39 | Serial.println(floatVar); 40 | Serial.println(); 41 | } 42 | 43 | void setup() 44 | { 45 | Serial.begin(9600); 46 | while (!Serial) { 47 | ; // wait for serial port to connect. Needed for Leonardo only 48 | } 49 | 50 | delay(100); 51 | Serial.println(); 52 | 53 | // start reading from position memBase (address 0) of the EEPROM. Set maximumSize to EEPROMSizeUno 54 | // Writes before membase or beyond EEPROMSizeUno will only give errors when _EEPROMEX_DEBUG is set 55 | EEPROM.setMemPool(memBase, EEPROMSizeUno); 56 | 57 | // Set maximum allowed writes to maxAllowedWrites. 58 | // More writes will only give errors when _EEPROMEX_DEBUG is set 59 | EEPROM.setMaxAllowedWrites(maxAllowedWrites); 60 | 61 | // Create Eeprom variables first and in the same order 62 | EEPROMVar eepromFloat(5.5); // initial value 5.5 63 | 64 | readAndWriteVar(eepromFloat); 65 | } 66 | 67 | void loop() 68 | { 69 | // Nothing to do during loop 70 | } 71 | 72 | -------------------------------------------------------------------------------- /extras/Documentation/html/files.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: File List 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 51 |
52 |
53 |
54 |
File List
55 |
56 |
57 |
Here is a list of all documented files with brief descriptions:
58 | 59 | 60 |
D:/My Documents/Github/Arduino/Own Arduino libraries/EEPROMEx/Arduino-EEPROMEx/EEPROMex.h [code]
D:/My Documents/Github/Arduino/Own Arduino libraries/EEPROMEx/Arduino-EEPROMEx/EEPROMVar.h [code]
61 |
62 | 63 | 64 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /extras/Documentation/html/annotated.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: Class List 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 53 |
54 |
55 |
56 |
Class List
57 |
58 |
59 |
Here are the classes, structs, unions and interfaces with brief descriptions:
60 | 61 | 62 |
EEPROMClassEx
EEPROMVar< T >
63 |
64 | 65 | 66 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /extras/Documentation/html/classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: Class Index 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 53 |
54 |
55 |
56 |
Class Index
57 |
58 |
59 | 60 | 61 | 63 | 64 | 65 | 66 |
  E  
62 |
EEPROMVar   
EEPROMClassEx   
67 | 68 |
69 | 70 | 71 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /extras/Documentation/html/class_e_e_p_r_o_m_var-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: Member List 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 53 |
54 |
55 |
56 |
EEPROMVar< T > Member List
57 |
58 |
59 | This is the complete list of members for EEPROMVar< T >, including all inherited members. 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
address (defined in EEPROMVar< T >)EEPROMVar< T > [protected]
EEPROMVar(T init) (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
getAddress() (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
operator T() (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
operator*=(V multiplicator) (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
operator++(int) (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
operator++() (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
operator+=(T val) (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
operator--(int) (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
operator--() (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
operator-=(T val) (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
operator/=(V divisor) (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
operator=(T val) (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
restore() (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
save() (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
update() (defined in EEPROMVar< T >)EEPROMVar< T > [inline]
var (defined in EEPROMVar< T >)EEPROMVar< T > [protected]
78 | 79 | 80 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /EEPROMex.h: -------------------------------------------------------------------------------- 1 | /* 2 | EEPROMEx.h - Extended EEPROM library 3 | Copyright (c) 2012 Thijs Elenbaas. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef EEPROMEX_h 21 | #define EEPROMEX_h 22 | 23 | #if ARDUINO >= 100 24 | #include 25 | #else 26 | #include 27 | #endif 28 | #include 29 | #include 30 | 31 | #define EEPROMSize1k 1024 32 | #define EEPROMSize2k 2048 33 | #define EEPROMSize4k 4096 34 | #define EEPROMSize8k 8192 35 | #define EEPROMSize16k 16384 36 | #define EEPROMSize32k 32768 37 | #define EEPROMSize64k 65536 38 | 39 | #define EEPROMSizeATmega168 512 40 | #define EEPROMSizeATmega328 1024 41 | #define EEPROMSizeATmega1280 4096 42 | #define EEPROMSizeATmega32u4 1024 43 | #define EEPROMSizeAT90USB1286 4096 44 | #define EEPROMSizeMK20DX128 2048 45 | #define EEPROMSizeMK20DX256 2048 46 | #define EEPROMSizeATSAMD21G18 16384 47 | 48 | #define EEPROMSizeUno EEPROMSizeATmega328 49 | #define EEPROMSizeUnoSMD EEPROMSizeATmega328 50 | #define EEPROMSizeLilypad EEPROMSizeATmega328 51 | #define EEPROMSizeDuemilanove EEPROMSizeATmega328 52 | #define EEPROMSizePro EEPROMSizeATmega328 53 | #define EEPROMSizeFio EEPROMSizeATmega328 54 | #define EEPROMSizeMega EEPROMSizeATmega1280 55 | #define EEPROMSizeDiecimila EEPROMSizeATmega168 56 | #define EEPROMSizeNano EEPROMSizeATmega168 57 | #define EEPROMSizeTeensy2 EEPROMSizeATmega32u4 58 | #define EEPROMSizeLeonardo EEPROMSizeATmega32u4 59 | #define EEPROMSizeMicro EEPROMSizeATmega32u4 60 | #define EEPROMSizeEsplora EEPROMSizeATmega32u4 61 | #define EEPROMSizeYun EEPROMSizeATmega32u4 62 | #define EEPROMSizeTre EEPROMSizeATmega32u4 63 | #define EEPROMSizeZero EEPROMSizeATSAMD21G18 64 | #define EEPROMSizeTeensy2pp EEPROMSizeAT90USB1286 65 | #define EEPROMSizeTeensy3 EEPROMSizeMK20DX128 66 | #define EEPROMSizeTeensy31 EEPROMSizeMK20DX256 67 | class EEPROMClassEx 68 | { 69 | 70 | public: 71 | EEPROMClassEx(); 72 | bool isReady(); 73 | int writtenBytes(); 74 | void setMemPool(int base, int memSize); 75 | void setMaxAllowedWrites(int allowedWrites); 76 | int getAddress(int noOfBytes); 77 | 78 | uint8_t read(int); 79 | bool readBit(int, byte); 80 | uint8_t readByte(int); 81 | uint16_t readInt(int); 82 | uint32_t readLong(int); 83 | float readFloat(int); 84 | double readDouble(int); 85 | 86 | bool write(int, uint8_t); 87 | bool writeBit(int , uint8_t, bool); 88 | bool writeByte(int, uint8_t); 89 | bool writeInt(int, uint16_t); 90 | bool writeLong(int, uint32_t); 91 | bool writeFloat(int, float); 92 | bool writeDouble(int, double); 93 | 94 | bool update(int, uint8_t); 95 | bool updateBit(int , uint8_t, bool); 96 | bool updateByte(int, uint8_t); 97 | bool updateInt(int, uint16_t); 98 | bool updateLong(int, uint32_t); 99 | bool updateFloat(int, float); 100 | bool updateDouble(int, double); 101 | 102 | 103 | // Use template for other data formats 104 | 105 | /** 106 | * Template function to read multiple items of any type of variable, such as structs 107 | */ 108 | template int readBlock(int address, const T value[], int items) 109 | { 110 | unsigned int i; 111 | for (i = 0; i < (unsigned int)items; i++) 112 | readBlock(address+(i*sizeof(T)),value[i]); 113 | return i; 114 | } 115 | 116 | /** 117 | * Template function to read any type of variable, such as structs 118 | */ 119 | template int readBlock(int address, const T& value) 120 | { 121 | eeprom_read_block((void*)&value, (const void*)address, sizeof(value)); 122 | return sizeof(value); 123 | } 124 | 125 | /** 126 | * Template function to write multiple items of any type of variable, such as structs 127 | */ 128 | template int writeBlock(int address, const T value[], int items) 129 | { 130 | if (!isWriteOk(address+items*sizeof(T))) return 0; 131 | unsigned int i; 132 | for (i = 0; i < (unsigned int)items; i++) 133 | writeBlock(address+(i*sizeof(T)),value[i]); 134 | return i; 135 | } 136 | 137 | /** 138 | * Template function to write any type of variable, such as structs 139 | */ 140 | template int writeBlock(int address, const T& value) 141 | { 142 | if (!isWriteOk(address+sizeof(value))) return 0; 143 | eeprom_write_block((void*)&value, (void*)address, sizeof(value)); 144 | return sizeof(value); 145 | } 146 | 147 | /** 148 | * Template function to update multiple items of any type of variable, such as structs 149 | * The EEPROM will only be overwritten if different. This will reduce wear. 150 | */ 151 | template int updateBlock(int address, const T value[], int items) 152 | { 153 | int writeCount=0; 154 | if (!isWriteOk(address+items*sizeof(T))) return 0; 155 | unsigned int i; 156 | for (i = 0; i < (unsigned int)items; i++) 157 | writeCount+= updateBlock(address+(i*sizeof(T)),value[i]); 158 | return writeCount; 159 | } 160 | 161 | /** 162 | * Template function to update any type of variable, such as structs 163 | * The EEPROM will only be overwritten if different. This will reduce wear. 164 | */ 165 | template int updateBlock(int address, const T& value) 166 | { 167 | int writeCount=0; 168 | if (!isWriteOk(address+sizeof(value))) return 0; 169 | const byte* bytePointer = (const byte*)(const void*)&value; 170 | for (unsigned int i = 0; i < (unsigned int)sizeof(value); i++) { 171 | if (read(address)!=*bytePointer) { 172 | write(address, *bytePointer); 173 | writeCount++; 174 | } 175 | address++; 176 | bytePointer++; 177 | } 178 | return writeCount; 179 | } 180 | 181 | 182 | 183 | private: 184 | //Private variables 185 | static int _base; 186 | static int _memSize; 187 | static int _nextAvailableaddress; 188 | static int _writeCounts; 189 | int _allowedWrites; 190 | bool checkWrite(int base,int noOfBytes); 191 | bool isWriteOk(int address); 192 | bool isReadOk(int address); 193 | }; 194 | 195 | extern EEPROMClassEx EEPROM; 196 | 197 | #endif 198 | 199 | -------------------------------------------------------------------------------- /extras/Documentation/html/functions_func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: Class Members - Functions 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 53 | 59 | 69 |
70 |
71 |   72 | 73 |

- g -

78 | 79 | 80 |

- i -

85 | 86 | 87 |

- r -

113 | 114 | 115 |

- s -

123 | 124 | 125 |

- u -

151 | 152 | 153 |

- w -

179 |
180 | 181 | 182 | 187 | 188 | 189 | 190 | -------------------------------------------------------------------------------- /extras/Documentation/html/functions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: Class Members 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 53 | 59 | 69 |
70 |
71 |
Here is a list of all documented class members with links to the class documentation for each member:
72 | 73 |

- g -

78 | 79 | 80 |

- i -

85 | 86 | 87 |

- r -

113 | 114 | 115 |

- s -

123 | 124 | 125 |

- u -

151 | 152 | 153 |

- w -

179 |
180 | 181 | 182 | 187 | 188 | 189 | 190 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Arduino EEPROMEx library 2 | [![Build Status](https://travis-ci.org/thijse/Arduino-EEPROMEx.svg?branch=master)](https://travis-ci.org/thijse/Arduino-EEPROMEx) 3 | [![License: LGPL v21](https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg)](https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg) 4 | 5 | The EEPROMex library is an extension of the standard Arduino EEPROM library. It extends the functionality of the original Arduino EEPROM library with: 6 | 7 | * Reading, writing to basic types. This includes bytes, longs, ints, floats and doubles. 8 | * Reading, writing to single bits. This helps efficient usage of the limited EEPROM memory. 9 | * Reading, writing of any data format. This can be for example structs, strings, etc. 10 | * Reading, writing of arrays of any format. By storing, for example, arrays of structs one can create a database like structure. 11 | * Update functions. The function similar to write functions, but only update changed bytes. If structures have only changed partly, updating instead of writing can save a lot EEPROM wear and significantly increase speed. 12 | * Basic memory allocation functionality. This is basically a counter of the first unallocated byte, and helps giving unique addresses to variables. 13 | * Enabling write limitation: In theory one can burn out a memory cell in a few minutes: a write/erase cycle takes approximately 4 ms, so writing 100.000 times to a single cell takes 6 1/2 min. Limiting the number of writes during the debug phase helps prevent this. 14 | * Debugging of writing out of memory range. 15 | 16 | 17 | And find detailed explanation and samples of the functionality here: 18 | [http://thijs.elenbaas.net/2012/07/extended-eeprom-library-for-arduino](http://thijs.elenbaas.net/2012/07/extended-eeprom-library-for-arduino) 19 | 20 | ## Downloading 21 | 22 | This package can be downloaded in different manners 23 | 24 | 25 | - The Arduino Library Manager: [see here how to use it](http://www.arduino.cc/en/guide/libraries#toc3). 26 | - The PlatformIO Library Manager: [see here how to use it](http://docs.platformio.org/en/latest/ide/arduino.html). 27 | - By directly loading fetching the Archive from GitHub: 28 | 1. Go to [https://github.com/thijse/Arduino-EEPROMEx](https://github.com/thijse/Arduino-EEPROMEx) 29 | 2. Click the DOWNLOAD ZIP button in the panel on the 30 | 3. Rename the uncompressed folder **Arduino-EEPROMEx-master** to **EEPROMEx**. 31 | 4. You may need to create the libraries subfolder if its your first library. 32 | 5. Place the **EEPROMEx** library folder in your **arduinosketchfolder/libraries/** folder. 33 | 5. Restart the IDE. 34 | 6. For more information, [read this extended manual](http://thijs.elenbaas.net/2012/07/installing-an-arduino-library/) 35 | - If you want to have a package that includes all referenced libraries, use the pre-packaged library 36 | 1. Download the package as a zipfile [here](https://github.com/thijse/Zipballs/blob/master/EEPROMEx/EEPROMEx.zip?raw=true) or as a tarball [here ](https://github.com/thijse/Zipballs/blob/master/EEPROMEx/EEPROMEx.tar.gz?raw=true). 37 | 2. Copy the folders inside the **libraries** folder to you your **arduinosketchfolder/libraries/** folder. 38 | 3. Restart the IDE. 39 | 3. For more information, [read this extended manual](http://thijs.elenbaas.net/2012/07/installing-an-arduino-library/) 40 | 41 | 42 | 43 | ### Using different data formats 44 | 45 | The aim of the library is to also support other standard data types: it currently implements writing and reading to int, long, float and double. 46 | 47 | ### For reading: 48 | ``` 49 | uint8_t read(int address); 50 | bool readBit(int address, byte bit) 51 | uint8_t readByte(int address); 52 | uint16_t readInt(int address); 53 | uint32_t readLong(int address); 54 | float readFloat(int address); 55 | double readDouble(int address); 56 | ``` 57 | 58 | Where address is the starting position in EEPROM, and the return value the value read from EEPROM. 59 | 60 | ### For writing: 61 | ``` 62 | bool write(int address, uint8_t value); 63 | bool writeByte(int address, uint8_t value); 64 | bool writeInt(int address, uint16_t value); 65 | bool writeLong(int address, uint32_t value); 66 | bool writeFloat(int address, float value); 67 | bool writeDouble(int address, double value); 68 | ``` 69 | The update functions are different from the write functions: they will check per byte if the current value differs and only update the the cell with a different value. This will not only reduce wear, and can also significantly reduce write time. 70 | 71 | ``` 72 | bool update(int address, uint8_t value); 73 | bool updateByte(int address, uint8_t value); 74 | bool updateInt(int address, uint16_t value); 75 | bool updateLong(int address, uint32_t value); 76 | bool updateFloat(int address, float value); 77 | bool updateDouble(int address, double); 78 | ``` 79 | 80 | ### Manipulating Single bits 81 | 82 | The following functions implements reading and writing single bits: 83 | 84 | ``` 85 | bool readBit(int address, byte bit) 86 | ``` 87 | Where bit is the write position in the byte, ranging from [0..7], with bit 0 being the right-most. The return value is the read bit. 88 | 89 | ``` 90 | bool writeBit(int address, uint8_t bit, bool value) 91 | bool updateBit(int address, uint8_t bit, bool value) 92 | ``` 93 | 94 | ### Data blocks 95 | 96 | Using the block functions any data can be read, written and updated: 97 | 98 | ``` 99 | int readBlock(int address, const T& value) 100 | int writeBlock(int address, const T& value) 101 | int updateBlock(int address, const T& value) 102 | ``` 103 | 104 | where T is the type of the data to read/write/update. This can be a basic type, but also a more complex type like a struct. The return value gives the number of bytes that have been read, written or updated. 105 | 106 | One can also read/write arrays of data-blocks: 107 | 108 | ``` 109 | int readBlock(int address, const T[]; value, int items) 110 | int writeBlock(int address, const T[]; value, int items) 111 | int updateBlock(int address, const T[]; value, int items) 112 | ``` 113 | 114 | ### Debugging EEPROM applications 115 | 116 | It is easy to burn out a memory cell in few minutes, so during debugging it would be very useful to limit the number of allowed writes. It is easy to put a bracket at the wrong location, and placing an EEPROM write inside of a loop, rather than outside, and introduce extensive writing causing wear. The following function helps limit the number of writes. 117 | 118 | ``` 119 | setMaxAllowedWrites(int allowedWrites); 120 | ``` 121 | 122 | More writes than allowed will be refused and result in an error message. You can also set the address range used by the library: 123 | 124 | ``` 125 | setMemPool(int base, int memSize); 126 | ``` 127 | 128 | The lower value is used by the getAddress function, the upper value is used for setting the EEPROM size. Writing outside the maximum size will result in an error message. The following EEPROM sizes are predefined 129 | 130 | Based on processor: 131 | ``` 132 | *EEPROMSizeATmega168 133 | *EEPROMSizeATmega328 134 | *EEPROMSizeATmega1280 135 | *EEPROMSizeATmega32u4 136 | *EEPROMSizeAT90USB1286 137 | *EEPROMSizeMK20DX128 138 | ``` 139 | Based on board: 140 | ``` 141 | *EEPROMSizeUno 142 | *EEPROMSizeUnoSMD 143 | *EEPROMSizeLilypad 144 | *EEPROMSizeDuemilanove 145 | *EEPROMSizeMega 146 | *EEPROMSizeDiecimila 147 | *EEPROMSizeNano 148 | *EEPROMSizeTeensy2 149 | *EEPROMSizeLeonardo 150 | *EEPROMSizeMicro 151 | *EEPROMSizeYun 152 | *EEPROMSizeTeensy2pp 153 | *EEPROMSizeTeensy3 154 | ``` 155 | 156 | ### EEPROM performance 157 | 158 | All of the read/write functions make sure the EEPROM is ready to be accessed. Since this may cause a delay of max 4ms, time-critical applications should first poll the EEPROM e. g. using the isReady function before attempting any actual I/O: 159 | 160 | ``` 161 | bool isReady(); 162 | ``` 163 | 164 | ## On using and modifying libraries 165 | 166 | - [http://www.arduino.cc/en/Main/Libraries](http://www.arduino.cc/en/Main/Libraries) 167 | - [http://www.arduino.cc/en/Reference/Libraries](http://www.arduino.cc/en/Reference/Libraries) 168 | 169 | 170 | ## Copyright 171 | 172 | EEPROMEx is provided Copyright © 2013-2017 under LGPL License. 173 | -------------------------------------------------------------------------------- /extras/Documentation/html/class_e_e_p_r_o_m_var.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: EEPROMVar< T > Class Template Reference 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 53 |
54 |
55 | 58 |
59 |
EEPROMVar< T > Class Template Reference
60 |
61 |
62 | 63 |

List of all members.

64 | 65 | 67 | 69 | 71 | 73 | 75 | 77 | 79 | 81 | 83 | 85 | 87 | 88 | 90 | 91 | 93 | 95 | 97 | 99 | 101 | 103 | 105 |

66 | Public Member Functions

68 |  EEPROMVar (T init)
70 |  operator T ()
72 | EEPROMVaroperator= (T val)
74 | void operator+= (T val)
76 | void operator-= (T val)
78 | void operator++ (int)
80 | void operator-- (int)
82 | void operator++ ()
84 | void operator-- ()
86 | template<typename V >
void operator/= (V divisor)
89 | template<typename V >
void operator*= (V multiplicator)
92 | void save ()
94 | void update ()
96 | int getAddress ()
98 | void restore ()

100 | Protected Attributes

102 | T var
104 | int address
106 |

template<typename T>
107 | class EEPROMVar< T >

108 | 109 |
The documentation for this class was generated from the following file:
    110 |
  • D:/My Documents/Github/Arduino/Own Arduino libraries/EEPROMEx/Arduino-EEPROMEx/EEPROMVar.h
  • 111 |
112 |
113 | 114 | 115 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /extras/Documentation/html/_e_e_p_r_o_m_var_8h_source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: D:/My Documents/Github/Arduino/Own Arduino libraries/EEPROMEx/Arduino-EEPROMEx/EEPROMVar.h Source File 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 51 |
52 |
53 |
54 |
D:/My Documents/Github/Arduino/Own Arduino libraries/EEPROMEx/Arduino-EEPROMEx/EEPROMVar.h
55 |
56 |
57 |
00001 #include <EEPROMex.h>
 58 | 00002 
 59 | 00003 /*
 60 | 00004   EEPROMvar.h - EEPROM variable library
 61 | 00005   Copyright (c) 2012 Thijs Elenbaas.  All right reserved.
 62 | 00006   
 63 | 00007   based on class by AlphaBeta
 64 | 00008 
 65 | 00009   This library is free software; you can redistribute it and/or
 66 | 00010   modify it under the terms of the GNU Lesser General Public
 67 | 00011   License as published by the Free Software Foundation; either
 68 | 00012   version 2.1 of the License, or (at your option) any later version.
 69 | 00013 
 70 | 00014   This library is distributed in the hope that it will be useful,
 71 | 00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
 72 | 00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 73 | 00017   Lesser General Public License for more details.
 74 | 00018 
 75 | 00019   You should have received a copy of the GNU Lesser General Public
 76 | 00020   License along with this library; if not, write to the Free Software
 77 | 00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 78 | 00022 */
 79 | 00023 
 80 | 00024 template<typename T> class EEPROMVar 
 81 | 00025 {
 82 | 00026     public:
 83 | 00027       EEPROMVar(T init) {
 84 | 00028         address = EEPROM.getAddress(sizeof(T)); 
 85 | 00029         var = init;
 86 | 00030       }
 87 | 00031       operator T () { 
 88 | 00032         return var; 
 89 | 00033       }
 90 | 00034       EEPROMVar &operator=(T val) {
 91 | 00035         var = val;
 92 | 00036         return *this;
 93 | 00037       }
 94 | 00038       
 95 | 00039       void operator+=(T val) {
 96 | 00040         var += T(val); 
 97 | 00041       }
 98 | 00042       void operator-=(T val) {
 99 | 00043         var -= T(val); 
100 | 00044       }       
101 | 00045       void operator++(int) {
102 | 00046         var += T(1); 
103 | 00047       }
104 | 00048       void operator--(int) {
105 | 00049         var -= T(1); 
106 | 00050       }
107 | 00051       void operator++() {
108 | 00052         var += T(1); 
109 | 00053       }
110 | 00054       void operator--() {
111 | 00055         var -= T(1); 
112 | 00056       }
113 | 00057       template<typename V>
114 | 00058         void operator /= (V divisor) {
115 | 00059         var = var / divisor;
116 | 00060       }
117 | 00061       template<typename V>
118 | 00062         void operator *= (V multiplicator) {
119 | 00063         var = var * multiplicator;
120 | 00064       }
121 | 00065       void save(){         
122 | 00066         EEPROM.writeBlock<T>(address, var);
123 | 00067       }
124 | 00068       
125 | 00069       void update(){           
126 | 00070         EEPROM.updateBlock<T>(address, var);
127 | 00071       }
128 | 00072       
129 | 00073       int getAddress(){        
130 | 00074         return address;
131 | 00075       }
132 | 00076       
133 | 00077       void restore(){
134 | 00078         EEPROM.readBlock<T>(address, var);
135 | 00079       }
136 | 00080     protected:  
137 | 00081       T var;
138 | 00082       int address;
139 | 00083 };
140 | 
141 | 142 | 143 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /extras/Documentation/html/class_e_e_p_r_o_m_class_ex-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: Member List 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 53 |
54 |
55 |
56 |
EEPROMClassEx Member List
57 |
58 |
59 | This is the complete list of members for EEPROMClassEx, including all inherited members. 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |
EEPROMClassEx() (defined in EEPROMClassEx)EEPROMClassEx
getAddress(int noOfBytes)EEPROMClassEx
isReady()EEPROMClassEx
read(int)EEPROMClassEx
readBit(int, byte)EEPROMClassEx
readBlock(int address, const T value[], int items)EEPROMClassEx [inline]
readBlock(int address, const T &value)EEPROMClassEx [inline]
readByte(int)EEPROMClassEx
readDouble(int)EEPROMClassEx
readFloat(int)EEPROMClassEx
readInt(int)EEPROMClassEx
readLong(int)EEPROMClassEx
setMaxAllowedWrites(int allowedWrites)EEPROMClassEx
setMemPool(int base, int memSize)EEPROMClassEx
update(int, uint8_t)EEPROMClassEx
updateBit(int, uint8_t, bool)EEPROMClassEx
updateBlock(int address, const T value[], int items)EEPROMClassEx [inline]
updateBlock(int address, const T &value)EEPROMClassEx [inline]
updateByte(int, uint8_t)EEPROMClassEx
updateDouble(int, double)EEPROMClassEx
updateFloat(int, float)EEPROMClassEx
updateInt(int, uint16_t)EEPROMClassEx
updateLong(int, uint32_t)EEPROMClassEx
write(int, uint8_t)EEPROMClassEx
writeBit(int, uint8_t, bool)EEPROMClassEx
writeBlock(int address, const T value[], int items)EEPROMClassEx [inline]
writeBlock(int address, const T &value)EEPROMClassEx [inline]
writeByte(int, uint8_t)EEPROMClassEx
writeDouble(int, double)EEPROMClassEx
writeFloat(int, float)EEPROMClassEx
writeInt(int, uint16_t)EEPROMClassEx
writeLong(int, uint32_t)EEPROMClassEx
writtenBytes() (defined in EEPROMClassEx)EEPROMClassEx
94 | 95 | 96 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /EEPROMex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | EEPROMEx.cpp - Extended EEPROM library 3 | Copyright (c) 2012 Thijs Elenbaas. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /****************************************************************************** 21 | * Includes 22 | ******************************************************************************/ 23 | #include "EEPROMex.h" 24 | 25 | /****************************************************************************** 26 | * Definitions 27 | ******************************************************************************/ 28 | 29 | #define _EEPROMEX_VERSION 1_0_0 // software version of this library 30 | //#define _EEPROMEX_DEBUG // Enables logging of maximum of writes and out-of-memory 31 | /****************************************************************************** 32 | * Constructors 33 | ******************************************************************************/ 34 | 35 | // Boards with ATmega328, Duemilanove, Uno, Uno SMD, Lilypad - 1024 bytes (1 kilobyte) 36 | // Boards with ATmega1280 or 2560, Arduino Mega series – 4096 bytes (4 kilobytes) 37 | // Boards with ATmega168, Lilypad, old Nano, Diecimila – 512 bytes 38 | // By default we choose conservative settings 39 | EEPROMClassEx::EEPROMClassEx() 40 | : _allowedWrites(100) 41 | { 42 | } 43 | 44 | /****************************************************************************** 45 | * User API 46 | ******************************************************************************/ 47 | 48 | /** 49 | * Set starting position and memory size that EEPROMEx may manage 50 | */ 51 | void EEPROMClassEx::setMemPool(int base, int memSize) { 52 | //Base can only be adjusted if no addresses have already been issued 53 | if (_nextAvailableaddress == _base) 54 | _base = base; 55 | _nextAvailableaddress=_base; 56 | 57 | //Ceiling can only be adjusted if not below issued addresses 58 | if (memSize >= _nextAvailableaddress ) 59 | _memSize = memSize; 60 | 61 | #ifdef _EEPROMEX_DEBUG 62 | if (_nextAvailableaddress != _base) 63 | Serial.println("Cannot change base, addresses have been issued"); 64 | 65 | if (memSize < _nextAvailableaddress ) 66 | Serial.println("Cannot change ceiling, below issued addresses"); 67 | #endif 68 | 69 | } 70 | 71 | /** 72 | * Set global maximum of allowed writes 73 | */ 74 | void EEPROMClassEx::setMaxAllowedWrites(int allowedWrites) { 75 | #ifdef _EEPROMEX_DEBUG 76 | _allowedWrites = allowedWrites; 77 | #endif 78 | } 79 | 80 | /** 81 | * Get a new starting address to write to. Adress is negative if not enough space is available 82 | */ 83 | int EEPROMClassEx::getAddress(int noOfBytes){ 84 | int availableaddress = _nextAvailableaddress; 85 | _nextAvailableaddress += noOfBytes; 86 | 87 | #ifdef _EEPROMEX_DEBUG 88 | if (_nextAvailableaddress > _memSize) { 89 | Serial.println("Attempt to write outside of EEPROM memory"); 90 | return -availableaddress; 91 | } else { 92 | return availableaddress; 93 | } 94 | #endif 95 | return availableaddress; 96 | } 97 | 98 | /** 99 | * Check if EEPROM memory is ready to be accessed 100 | */ 101 | bool EEPROMClassEx::isReady() { 102 | return eeprom_is_ready(); 103 | } 104 | 105 | /** 106 | * Read a single byte 107 | * This function performs as readByte and is added to be similar to the EEPROM library 108 | */ 109 | uint8_t EEPROMClassEx::read(int address) 110 | { 111 | return readByte(address); 112 | } 113 | 114 | /** 115 | * Read a single bit 116 | */ 117 | bool EEPROMClassEx::readBit(int address, byte bit) { 118 | if (bit> 7) return false; 119 | if (!isReadOk(address+sizeof(uint8_t))) return false; 120 | byte byteVal = eeprom_read_byte((unsigned char *) address); 121 | byte bytePos = (1 << bit); 122 | return (byteVal & bytePos); 123 | } 124 | 125 | /** 126 | * Read a single byte 127 | */ 128 | uint8_t EEPROMClassEx::readByte(int address) 129 | { 130 | if (!isReadOk(address+sizeof(uint8_t))) return 0; 131 | return eeprom_read_byte((unsigned char *) address); 132 | } 133 | 134 | /** 135 | * Read a single 16 bits integer 136 | */ 137 | uint16_t EEPROMClassEx::readInt(int address) 138 | { 139 | if (!isReadOk(address+sizeof(uint16_t))) return 0; 140 | return eeprom_read_word((uint16_t *) address); 141 | } 142 | 143 | /** 144 | * Read a single 32 bits integer 145 | */ 146 | uint32_t EEPROMClassEx::readLong(int address) 147 | { 148 | if (!isReadOk(address+sizeof(uint32_t))) return 0; 149 | return eeprom_read_dword((unsigned long *) address); 150 | } 151 | 152 | /** 153 | * Read a single float value 154 | */ 155 | float EEPROMClassEx::readFloat(int address) 156 | { 157 | if (!isReadOk(address+sizeof(float))) return 0; 158 | float _value; 159 | readBlock(address, _value); 160 | return _value; 161 | } 162 | 163 | /** 164 | * Read a single double value (size will depend on board type) 165 | */ 166 | double EEPROMClassEx::readDouble(int address) 167 | { 168 | if (!isReadOk(address+sizeof(double))) return 0; 169 | double _value; 170 | readBlock(address, _value); 171 | return _value; 172 | } 173 | 174 | /** 175 | * Write a single byte 176 | * This function performs as writeByte and is added to be similar to the EEPROM library 177 | */ 178 | bool EEPROMClassEx::write(int address, uint8_t value) 179 | { 180 | return writeByte(address, value); 181 | } 182 | 183 | /** 184 | * Write a single bit 185 | */ 186 | bool EEPROMClassEx::writeBit(int address, uint8_t bit, bool value) { 187 | updateBit(address, bit, value); 188 | return true; 189 | } 190 | 191 | /** 192 | * Write a single byte 193 | */ 194 | bool EEPROMClassEx::writeByte(int address, uint8_t value) 195 | { 196 | if (!isWriteOk(address+sizeof(uint8_t))) return false; 197 | eeprom_write_byte((unsigned char *) address, value); 198 | return true; 199 | } 200 | 201 | /** 202 | * Write a single 16 bits integer 203 | */ 204 | bool EEPROMClassEx::writeInt(int address, uint16_t value) 205 | { 206 | if (!isWriteOk(address+sizeof(uint16_t))) return false; 207 | eeprom_write_word((uint16_t *) address, value); 208 | return true; 209 | } 210 | 211 | /** 212 | * Write a single 32 bits integer 213 | */ 214 | bool EEPROMClassEx::writeLong(int address, uint32_t value) 215 | { 216 | if (!isWriteOk(address+sizeof(uint32_t))) return false; 217 | eeprom_write_dword((unsigned long *) address, value); 218 | return true; 219 | } 220 | 221 | /** 222 | * Write a single float value 223 | */ 224 | bool EEPROMClassEx::writeFloat(int address, float value) 225 | { 226 | return (writeBlock(address, value)!=0); 227 | } 228 | 229 | /** 230 | * Write a single double value (size will depend on board type) 231 | */ 232 | bool EEPROMClassEx::writeDouble(int address, double value) 233 | { 234 | return (writeBlock(address, value)!=0); 235 | } 236 | 237 | /** 238 | * Update a single byte 239 | * The EEPROM will only be overwritten if different. This will reduce wear. 240 | * This function performs as updateByte and is added to be similar to the EEPROM library 241 | */ 242 | bool EEPROMClassEx::update(int address, uint8_t value) 243 | { 244 | return (updateByte(address, value)); 245 | } 246 | 247 | /** 248 | * Update a single bit 249 | * The EEPROM will only be overwritten if different. This will reduce wear. 250 | */ 251 | bool EEPROMClassEx::updateBit(int address, uint8_t bit, bool value) 252 | { 253 | if (bit> 7) return false; 254 | 255 | byte byteValInput = readByte(address); 256 | byte byteValOutput = byteValInput; 257 | // Set bit 258 | if (value) { 259 | byteValOutput |= (1 << bit); //Set bit to 1 260 | } else { 261 | byteValOutput &= ~(1 << bit); //Set bit to 0 262 | } 263 | // Store if different from input 264 | if (byteValOutput!=byteValInput) { 265 | writeByte(address, byteValOutput); 266 | } 267 | return true; 268 | } 269 | 270 | 271 | /** 272 | * Update a single byte 273 | * The EEPROM will only be overwritten if different. This will reduce wear. 274 | */ 275 | bool EEPROMClassEx::updateByte(int address, uint8_t value) 276 | { 277 | return (updateBlock(address, value)!=0); 278 | } 279 | 280 | /** 281 | * Update a single 16 bits integer 282 | * The EEPROM will only be overwritten if different. This will reduce wear. 283 | */ 284 | bool EEPROMClassEx::updateInt(int address, uint16_t value) 285 | { 286 | return (updateBlock(address, value)!=0); 287 | } 288 | 289 | /** 290 | * Update a single 32 bits integer 291 | * The EEPROM will only be overwritten if different. This will reduce wear. 292 | */ 293 | bool EEPROMClassEx::updateLong(int address, uint32_t value) 294 | { 295 | return (updateBlock(address, value)!=0); 296 | } 297 | 298 | /** 299 | * Update a single float value 300 | * The EEPROM will only be overwritten if different. This will reduce wear. 301 | */ 302 | bool EEPROMClassEx::updateFloat(int address, float value) 303 | { 304 | return (updateBlock(address, value)!=0); 305 | } 306 | 307 | /** 308 | * Update a single double value (size will depend on board type) 309 | * The EEPROM will only be overwritten if different. This will reduce wear. 310 | */ 311 | bool EEPROMClassEx::updateDouble(int address, double value) 312 | { 313 | return (updateBlock(address, value)!=0); 314 | } 315 | 316 | /** 317 | * Performs check to see if writing to a memory address is allowed 318 | */ 319 | bool EEPROMClassEx::isWriteOk(int address) 320 | { 321 | #ifdef _EEPROMEX_DEBUG 322 | _writeCounts++; 323 | if (_allowedWrites == 0 || _writeCounts > _allowedWrites ) { 324 | Serial.println("Exceeded maximum number of writes"); 325 | return false; 326 | } 327 | 328 | if (address > _memSize) { 329 | Serial.println("Attempt to write outside of EEPROM memory"); 330 | return false; 331 | } else { 332 | return true; 333 | } 334 | #endif 335 | return true; 336 | } 337 | 338 | /** 339 | * Performs check to see if reading from a memory address is allowed 340 | */ 341 | bool EEPROMClassEx::isReadOk(int address) 342 | { 343 | #ifdef _EEPROMEX_DEBUG 344 | if (address > _memSize) { 345 | Serial.println("Attempt to write outside of EEPROM memory"); 346 | return false; 347 | } else { 348 | return true; 349 | } 350 | #endif 351 | return true; 352 | } 353 | 354 | int EEPROMClassEx::_base= 0; 355 | int EEPROMClassEx::_memSize= 512; 356 | int EEPROMClassEx::_nextAvailableaddress= 0; 357 | int EEPROMClassEx::_writeCounts =0; 358 | 359 | EEPROMClassEx EEPROM; 360 | -------------------------------------------------------------------------------- /examples/EEPROMEx/EEPROMEx.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * EEPROMEx 3 | * ) 4 | * Demonstrates reading, writing and updating data in the EEPROM 5 | * to the computer. 6 | * Thijs Elenbaas, 2012-2017 7 | * This example code is in the public domain. 8 | */ 9 | 10 | #include 11 | 12 | #include "Arduino.h" 13 | void issuedAdresses(); 14 | void readAndWriteByte(); 15 | void readAndWriteInt(); 16 | void readAndWriteLong(); 17 | void readAndWriteFloat(); 18 | void updateAndReadDouble(); 19 | void writeAndReadCharArray(); 20 | void writeAndReadByteArray(); 21 | void waitUntilReady(); 22 | void errorChecking(int adress); 23 | void setup(); 24 | void loop(); 25 | const int maxAllowedWrites = 80; 26 | const int memBase = 350; 27 | 28 | int addressByte; 29 | int addressInt; 30 | int addressLong; 31 | int addressFloat; 32 | int addressDouble; 33 | int addressByteArray; 34 | int addressCharArray; 35 | 36 | 37 | void issuedAdresses() { 38 | Serial.println("-----------------------------------"); 39 | Serial.println("Following adresses have been issued"); 40 | Serial.println("-----------------------------------"); 41 | 42 | Serial.println("adress \t\t size"); 43 | Serial.print(addressByte); Serial.print(" \t\t "); Serial.print(sizeof(byte)); Serial.println(" (byte)"); 44 | Serial.print(addressInt); Serial.print(" \t\t "); Serial.print(sizeof(int)); Serial.println(" (int)"); 45 | Serial.print(addressLong); Serial.print(" \t\t "); Serial.print(sizeof(long)); Serial.println(" (long)"); 46 | Serial.print(addressFloat); Serial.print(" \t\t "); Serial.print(sizeof(float)); Serial.println(" (float)"); 47 | Serial.print(addressDouble); Serial.print(" \t\t "); Serial.print(sizeof(double)); Serial.println(" (double)"); 48 | Serial.print(addressByteArray); Serial.print(" \t\t "); Serial.print(sizeof(byte)*7); Serial.println(" (array of 7 bytes)"); 49 | Serial.print(addressCharArray); Serial.print(" \t\t "); Serial.print(sizeof(char)*7); Serial.println(" (array of 7 chars)"); 50 | } 51 | 52 | // Test reading and writing byte to EEPROM 53 | void readAndWriteByte() { 54 | Serial.println("---------------------------"); 55 | Serial.println("storing and retreiving byte"); 56 | Serial.println("---------------------------"); 57 | 58 | byte input = 120; 59 | byte output = 0; 60 | EEPROM.write(addressByte,input); // same function as writeByte 61 | output = EEPROM.read(addressByte); // same function as readByte 62 | 63 | Serial.print("adress: "); 64 | Serial.println(addressByte); 65 | Serial.print("input: "); 66 | Serial.println(input); 67 | Serial.print("output: "); 68 | Serial.println(output); 69 | Serial.println(""); 70 | 71 | } 72 | 73 | // Test reading and writing int to EEPROM 74 | void readAndWriteInt() { 75 | Serial.println("--------------------------"); 76 | Serial.println("writing and retreiving int"); 77 | Serial.println("--------------------------"); 78 | 79 | int input = 30000; 80 | int output = 0; 81 | EEPROM.writeInt(addressInt,input); 82 | output = EEPROM.readInt(addressInt); 83 | 84 | Serial.print("adress: "); 85 | Serial.println(addressInt); 86 | Serial.print("input: "); 87 | Serial.println(input); 88 | Serial.print("output: "); 89 | Serial.println(output); 90 | Serial.println(""); 91 | } 92 | 93 | // Test reading and writing long to EEPROM 94 | void readAndWriteLong() { 95 | Serial.println("----------------------------"); 96 | Serial.println("writing and retreiving Long"); 97 | Serial.println("----------------------------"); 98 | 99 | long input = 200000000; 100 | long output = 0; 101 | EEPROM.writeLong(addressLong,input); 102 | output = EEPROM.readLong(addressLong); 103 | 104 | Serial.print("adress: "); 105 | Serial.println(addressLong); 106 | Serial.print("input: "); 107 | Serial.println(input); 108 | Serial.print("output: "); 109 | Serial.println(output); 110 | Serial.println(""); 111 | } 112 | 113 | // Test reading and writing float to EEPROM 114 | void readAndWriteFloat() { 115 | Serial.println("----------------------------"); 116 | Serial.println("writing and retreiving float"); 117 | Serial.println("----------------------------"); 118 | 119 | double input = 1010102.50; 120 | double output = 0.0; 121 | EEPROM.writeFloat(addressFloat,input); 122 | output = EEPROM.readFloat(addressFloat); 123 | 124 | Serial.print("adress: "); 125 | Serial.println(addressFloat); 126 | Serial.print("input: "); 127 | Serial.println(input); 128 | Serial.print("output: "); 129 | Serial.println(output); 130 | Serial.println(""); 131 | } 132 | 133 | // Test reading and updating double to EEPROM 134 | void updateAndReadDouble() { 135 | Serial.println("------------------------------"); 136 | Serial.println("updating and retreiving double"); 137 | Serial.println("------------------------------"); 138 | 139 | double input = 1000002.50; 140 | double output = 0.0; 141 | EEPROM.updateDouble(addressDouble,input); 142 | output = EEPROM.readDouble(addressDouble); 143 | 144 | Serial.print("adress: "); 145 | Serial.println(addressDouble); 146 | Serial.print("input: "); 147 | Serial.println(input); 148 | Serial.print("output: "); 149 | Serial.println(output); 150 | Serial.println(""); 151 | } 152 | 153 | // Test reading and updating a string (char array) to EEPROM 154 | void writeAndReadCharArray() { 155 | Serial.println("---------------------------------"); 156 | Serial.println("writing and reading a char array"); 157 | Serial.println("---------------------------------"); 158 | 159 | char input[] = "Arduino"; 160 | char output[] = " "; 161 | 162 | EEPROM.writeBlock(addressCharArray, input, 7); 163 | EEPROM.readBlock(addressCharArray, output, 7); 164 | 165 | Serial.print("adress: "); 166 | Serial.println(addressCharArray); 167 | Serial.print("input: "); 168 | Serial.println(input); 169 | Serial.print("output: "); 170 | Serial.println(output); 171 | Serial.println(""); 172 | } 173 | 174 | void writeAndReadByteArray() { 175 | 176 | Serial.println("---------------------------------"); 177 | Serial.println("updating and reading a byte array"); 178 | Serial.println("---------------------------------"); 179 | 180 | int itemsInArray = 7; 181 | byte initial[] = {1, 0, 4, 0, 16, 0 , 64 }; 182 | byte input[] = {1, 2, 4, 8, 16, 32, 64 }; 183 | byte output[sizeof(input)]; 184 | 185 | EEPROM.writeBlock(addressByteArray, initial, itemsInArray); 186 | int writtenBytes = EEPROM.updateBlock(addressByteArray, input, itemsInArray); 187 | EEPROM.readBlock(addressByteArray, output, itemsInArray); 188 | 189 | Serial.print("input: "); 190 | for(int i=0;i(addressByteArray, array7, itemsInArray); 258 | endMillis = millis(); 259 | Serial.print("Time to write 7 byte array (ms) : "); 260 | Serial.println(endMillis-startMillis); 261 | 262 | // Time to update 7 byte array with 7 new values 263 | startMillis = millis(); 264 | EEPROM.updateBlock(addressByteArray, arraydif7, itemsInArray); 265 | endMillis = millis(); 266 | Serial.print("Time to update 7 byte array with 7 new values (ms): "); 267 | Serial.println(endMillis-startMillis); 268 | 269 | // Time to update 7 byte array with 3 new values 270 | startMillis = millis(); 271 | EEPROM.updateBlock(addressByteArray, arrayDif3, itemsInArray); 272 | endMillis = millis(); 273 | Serial.print("Time to update 7 byte array with 3 new values (ms): "); 274 | Serial.println(endMillis-startMillis); 275 | 276 | // Time to read 7 byte array 277 | startMillis = millis(); 278 | EEPROM.readBlock(addressByteArray, output, itemsInArray); 279 | endMillis = millis(); 280 | Serial.print("Time to read 7 byte array (ms) : "); 281 | Serial.println(endMillis-startMillis); 282 | } 283 | 284 | // Check if we get errors when writing too much or out of bounds 285 | void errorChecking(int adress) { 286 | Serial.println("-------------------------------------------------------------"); 287 | Serial.println("Check if we get errors when writing too much or out of bounds"); 288 | Serial.println("-------------------------------------------------------------"); 289 | // Be sure that _EEPROMEX_DEBUG is enabled 290 | 291 | Serial.println("Write outside of EEPROM memory"); 292 | EEPROM.writeLong(EEPROMSizeUno+10,1000); 293 | Serial.println(); 294 | 295 | Serial.println("Trying to exceed number of writes"); 296 | for(int i=1;i<=20; i++) 297 | { 298 | if (!EEPROM.writeLong(adress,1000)) { return; } 299 | } 300 | Serial.println(); 301 | } 302 | 303 | 304 | void setup() 305 | { 306 | Serial.begin(9600); 307 | while (!Serial) { 308 | ; // wait for serial port to connect. Needed for Leonardo only 309 | } 310 | 311 | // start reading from position memBase (address 0) of the EEPROM. Set maximumSize to EEPROMSizeUno 312 | // Writes before membase or beyond EEPROMSizeUno will only give errors when _EEPROMEX_DEBUG is set 313 | EEPROM.setMemPool(memBase, EEPROMSizeUno); 314 | 315 | // Set maximum allowed writes to maxAllowedWrites. 316 | // More writes will only give errors when _EEPROMEX_DEBUG is set 317 | EEPROM.setMaxAllowedWrites(maxAllowedWrites); 318 | delay(100); 319 | Serial.println(""); 320 | 321 | // Always get the adresses first and in the same order 322 | addressByte = EEPROM.getAddress(sizeof(byte)); 323 | addressInt = EEPROM.getAddress(sizeof(int)); 324 | addressLong = EEPROM.getAddress(sizeof(long)); 325 | addressFloat = EEPROM.getAddress(sizeof(float)); 326 | addressDouble = EEPROM.getAddress(sizeof(double)); 327 | addressByteArray = EEPROM.getAddress(sizeof(byte)*7); 328 | addressCharArray = EEPROM.getAddress(sizeof(char)*7); 329 | 330 | // Show adresses that have been issued 331 | issuedAdresses(); 332 | 333 | // Read and write different data primitives 334 | readAndWriteByte(); 335 | readAndWriteInt(); 336 | readAndWriteLong(); 337 | readAndWriteFloat(); 338 | updateAndReadDouble(); 339 | 340 | // Read and write different data arrays 341 | writeAndReadCharArray(); 342 | writeAndReadByteArray(); 343 | 344 | // Test EEPROM access time 345 | waitUntilReady(); 346 | 347 | // Test error checking 348 | errorChecking(addressLong); 349 | } 350 | 351 | void loop() 352 | { 353 | // Nothing to do during loop 354 | } 355 | 356 | 357 | -------------------------------------------------------------------------------- /extras/Documentation/html/doxygen.css: -------------------------------------------------------------------------------- 1 | /* The standard CSS for doxygen */ 2 | 3 | body, table, div, p, dl { 4 | font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; 5 | font-size: 13px; 6 | line-height: 1.3; 7 | } 8 | 9 | /* @group Heading Levels */ 10 | 11 | h1 { 12 | font-size: 150%; 13 | } 14 | 15 | .title { 16 | font-size: 150%; 17 | font-weight: bold; 18 | margin: 10px 2px; 19 | } 20 | 21 | h2 { 22 | font-size: 120%; 23 | } 24 | 25 | h3 { 26 | font-size: 100%; 27 | } 28 | 29 | dt { 30 | font-weight: bold; 31 | } 32 | 33 | div.multicol { 34 | -moz-column-gap: 1em; 35 | -webkit-column-gap: 1em; 36 | -moz-column-count: 3; 37 | -webkit-column-count: 3; 38 | } 39 | 40 | p.startli, p.startdd, p.starttd { 41 | margin-top: 2px; 42 | } 43 | 44 | p.endli { 45 | margin-bottom: 0px; 46 | } 47 | 48 | p.enddd { 49 | margin-bottom: 4px; 50 | } 51 | 52 | p.endtd { 53 | margin-bottom: 2px; 54 | } 55 | 56 | /* @end */ 57 | 58 | caption { 59 | font-weight: bold; 60 | } 61 | 62 | span.legend { 63 | font-size: 70%; 64 | text-align: center; 65 | } 66 | 67 | h3.version { 68 | font-size: 90%; 69 | text-align: center; 70 | } 71 | 72 | div.qindex, div.navtab{ 73 | background-color: #EBEFF6; 74 | border: 1px solid #A3B4D7; 75 | text-align: center; 76 | } 77 | 78 | div.qindex, div.navpath { 79 | width: 100%; 80 | line-height: 140%; 81 | } 82 | 83 | div.navtab { 84 | margin-right: 15px; 85 | } 86 | 87 | /* @group Link Styling */ 88 | 89 | a { 90 | color: #3D578C; 91 | font-weight: normal; 92 | text-decoration: none; 93 | } 94 | 95 | .contents a:visited { 96 | color: #4665A2; 97 | } 98 | 99 | a:hover { 100 | text-decoration: underline; 101 | } 102 | 103 | a.qindex { 104 | font-weight: bold; 105 | } 106 | 107 | a.qindexHL { 108 | font-weight: bold; 109 | background-color: #9CAFD4; 110 | color: #ffffff; 111 | border: 1px double #869DCA; 112 | } 113 | 114 | .contents a.qindexHL:visited { 115 | color: #ffffff; 116 | } 117 | 118 | a.el { 119 | font-weight: bold; 120 | } 121 | 122 | a.elRef { 123 | } 124 | 125 | a.code, a.code:visited { 126 | color: #4665A2; 127 | } 128 | 129 | a.codeRef, a.codeRef:visited { 130 | color: #4665A2; 131 | } 132 | 133 | /* @end */ 134 | 135 | dl.el { 136 | margin-left: -1cm; 137 | } 138 | 139 | .fragment { 140 | font-family: monospace, fixed; 141 | font-size: 105%; 142 | } 143 | 144 | pre.fragment { 145 | border: 1px solid #C4CFE5; 146 | background-color: #FBFCFD; 147 | padding: 4px 6px; 148 | margin: 4px 8px 4px 2px; 149 | overflow: auto; 150 | word-wrap: break-word; 151 | font-size: 9pt; 152 | line-height: 125%; 153 | } 154 | 155 | div.ah { 156 | background-color: black; 157 | font-weight: bold; 158 | color: #ffffff; 159 | margin-bottom: 3px; 160 | margin-top: 3px; 161 | padding: 0.2em; 162 | border: solid thin #333; 163 | border-radius: 0.5em; 164 | -webkit-border-radius: .5em; 165 | -moz-border-radius: .5em; 166 | box-shadow: 2px 2px 3px #999; 167 | -webkit-box-shadow: 2px 2px 3px #999; 168 | -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; 169 | background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); 170 | background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); 171 | } 172 | 173 | div.groupHeader { 174 | margin-left: 16px; 175 | margin-top: 12px; 176 | font-weight: bold; 177 | } 178 | 179 | div.groupText { 180 | margin-left: 16px; 181 | font-style: italic; 182 | } 183 | 184 | body { 185 | background-color: white; 186 | color: black; 187 | margin: 0; 188 | } 189 | 190 | div.contents { 191 | margin-top: 10px; 192 | margin-left: 8px; 193 | margin-right: 8px; 194 | } 195 | 196 | td.indexkey { 197 | background-color: #EBEFF6; 198 | font-weight: bold; 199 | border: 1px solid #C4CFE5; 200 | margin: 2px 0px 2px 0; 201 | padding: 2px 10px; 202 | white-space: nowrap; 203 | vertical-align: top; 204 | } 205 | 206 | td.indexvalue { 207 | background-color: #EBEFF6; 208 | border: 1px solid #C4CFE5; 209 | padding: 2px 10px; 210 | margin: 2px 0px; 211 | } 212 | 213 | tr.memlist { 214 | background-color: #EEF1F7; 215 | } 216 | 217 | p.formulaDsp { 218 | text-align: center; 219 | } 220 | 221 | img.formulaDsp { 222 | 223 | } 224 | 225 | img.formulaInl { 226 | vertical-align: middle; 227 | } 228 | 229 | div.center { 230 | text-align: center; 231 | margin-top: 0px; 232 | margin-bottom: 0px; 233 | padding: 0px; 234 | } 235 | 236 | div.center img { 237 | border: 0px; 238 | } 239 | 240 | address.footer { 241 | text-align: right; 242 | padding-right: 12px; 243 | } 244 | 245 | img.footer { 246 | border: 0px; 247 | vertical-align: middle; 248 | } 249 | 250 | /* @group Code Colorization */ 251 | 252 | span.keyword { 253 | color: #008000 254 | } 255 | 256 | span.keywordtype { 257 | color: #604020 258 | } 259 | 260 | span.keywordflow { 261 | color: #e08000 262 | } 263 | 264 | span.comment { 265 | color: #800000 266 | } 267 | 268 | span.preprocessor { 269 | color: #806020 270 | } 271 | 272 | span.stringliteral { 273 | color: #002080 274 | } 275 | 276 | span.charliteral { 277 | color: #008080 278 | } 279 | 280 | span.vhdldigit { 281 | color: #ff00ff 282 | } 283 | 284 | span.vhdlchar { 285 | color: #000000 286 | } 287 | 288 | span.vhdlkeyword { 289 | color: #700070 290 | } 291 | 292 | span.vhdllogic { 293 | color: #ff0000 294 | } 295 | 296 | /* @end */ 297 | 298 | /* 299 | .search { 300 | color: #003399; 301 | font-weight: bold; 302 | } 303 | 304 | form.search { 305 | margin-bottom: 0px; 306 | margin-top: 0px; 307 | } 308 | 309 | input.search { 310 | font-size: 75%; 311 | color: #000080; 312 | font-weight: normal; 313 | background-color: #e8eef2; 314 | } 315 | */ 316 | 317 | td.tiny { 318 | font-size: 75%; 319 | } 320 | 321 | .dirtab { 322 | padding: 4px; 323 | border-collapse: collapse; 324 | border: 1px solid #A3B4D7; 325 | } 326 | 327 | th.dirtab { 328 | background: #EBEFF6; 329 | font-weight: bold; 330 | } 331 | 332 | hr { 333 | height: 0px; 334 | border: none; 335 | border-top: 1px solid #4A6AAA; 336 | } 337 | 338 | hr.footer { 339 | height: 1px; 340 | } 341 | 342 | /* @group Member Descriptions */ 343 | 344 | table.memberdecls { 345 | border-spacing: 0px; 346 | padding: 0px; 347 | } 348 | 349 | .mdescLeft, .mdescRight, 350 | .memItemLeft, .memItemRight, 351 | .memTemplItemLeft, .memTemplItemRight, .memTemplParams { 352 | background-color: #F9FAFC; 353 | border: none; 354 | margin: 4px; 355 | padding: 1px 0 0 8px; 356 | } 357 | 358 | .mdescLeft, .mdescRight { 359 | padding: 0px 8px 4px 8px; 360 | color: #555; 361 | } 362 | 363 | .memItemLeft, .memItemRight, .memTemplParams { 364 | border-top: 1px solid #C4CFE5; 365 | } 366 | 367 | .memItemLeft, .memTemplItemLeft { 368 | white-space: nowrap; 369 | } 370 | 371 | .memItemRight { 372 | width: 100%; 373 | } 374 | 375 | .memTemplParams { 376 | color: #4665A2; 377 | white-space: nowrap; 378 | } 379 | 380 | /* @end */ 381 | 382 | /* @group Member Details */ 383 | 384 | /* Styles for detailed member documentation */ 385 | 386 | .memtemplate { 387 | font-size: 80%; 388 | color: #4665A2; 389 | font-weight: normal; 390 | margin-left: 9px; 391 | } 392 | 393 | .memnav { 394 | background-color: #EBEFF6; 395 | border: 1px solid #A3B4D7; 396 | text-align: center; 397 | margin: 2px; 398 | margin-right: 15px; 399 | padding: 2px; 400 | } 401 | 402 | .mempage { 403 | width: 100%; 404 | } 405 | 406 | .memitem { 407 | padding: 0; 408 | margin-bottom: 10px; 409 | margin-right: 5px; 410 | } 411 | 412 | .memname { 413 | white-space: nowrap; 414 | font-weight: bold; 415 | margin-left: 6px; 416 | } 417 | 418 | .memproto, dl.reflist dt { 419 | border-top: 1px solid #A8B8D9; 420 | border-left: 1px solid #A8B8D9; 421 | border-right: 1px solid #A8B8D9; 422 | padding: 6px 0px 6px 0px; 423 | color: #253555; 424 | font-weight: bold; 425 | text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); 426 | /* opera specific markup */ 427 | box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); 428 | border-top-right-radius: 8px; 429 | border-top-left-radius: 8px; 430 | /* firefox specific markup */ 431 | -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; 432 | -moz-border-radius-topright: 8px; 433 | -moz-border-radius-topleft: 8px; 434 | /* webkit specific markup */ 435 | -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); 436 | -webkit-border-top-right-radius: 8px; 437 | -webkit-border-top-left-radius: 8px; 438 | background-image:url('nav_f.png'); 439 | background-repeat:repeat-x; 440 | background-color: #E2E8F2; 441 | 442 | } 443 | 444 | .memdoc, dl.reflist dd { 445 | border-bottom: 1px solid #A8B8D9; 446 | border-left: 1px solid #A8B8D9; 447 | border-right: 1px solid #A8B8D9; 448 | padding: 2px 5px; 449 | background-color: #FBFCFD; 450 | border-top-width: 0; 451 | /* opera specific markup */ 452 | border-bottom-left-radius: 8px; 453 | border-bottom-right-radius: 8px; 454 | box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); 455 | /* firefox specific markup */ 456 | -moz-border-radius-bottomleft: 8px; 457 | -moz-border-radius-bottomright: 8px; 458 | -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; 459 | background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F7F8FB 95%, #EEF1F7); 460 | /* webkit specific markup */ 461 | -webkit-border-bottom-left-radius: 8px; 462 | -webkit-border-bottom-right-radius: 8px; 463 | -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); 464 | background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F7F8FB), to(#EEF1F7)); 465 | } 466 | 467 | dl.reflist dt { 468 | padding: 5px; 469 | } 470 | 471 | dl.reflist dd { 472 | margin: 0px 0px 10px 0px; 473 | padding: 5px; 474 | } 475 | 476 | .paramkey { 477 | text-align: right; 478 | } 479 | 480 | .paramtype { 481 | white-space: nowrap; 482 | } 483 | 484 | .paramname { 485 | color: #602020; 486 | white-space: nowrap; 487 | } 488 | .paramname em { 489 | font-style: normal; 490 | } 491 | 492 | .params, .retval, .exception, .tparams { 493 | border-spacing: 6px 2px; 494 | } 495 | 496 | .params .paramname, .retval .paramname { 497 | font-weight: bold; 498 | vertical-align: top; 499 | } 500 | 501 | .params .paramtype { 502 | font-style: italic; 503 | vertical-align: top; 504 | } 505 | 506 | .params .paramdir { 507 | font-family: "courier new",courier,monospace; 508 | vertical-align: top; 509 | } 510 | 511 | 512 | 513 | 514 | /* @end */ 515 | 516 | /* @group Directory (tree) */ 517 | 518 | /* for the tree view */ 519 | 520 | .ftvtree { 521 | font-family: sans-serif; 522 | margin: 0px; 523 | } 524 | 525 | /* these are for tree view when used as main index */ 526 | 527 | .directory { 528 | font-size: 9pt; 529 | font-weight: bold; 530 | margin: 5px; 531 | } 532 | 533 | .directory h3 { 534 | margin: 0px; 535 | margin-top: 1em; 536 | font-size: 11pt; 537 | } 538 | 539 | /* 540 | The following two styles can be used to replace the root node title 541 | with an image of your choice. Simply uncomment the next two styles, 542 | specify the name of your image and be sure to set 'height' to the 543 | proper pixel height of your image. 544 | */ 545 | 546 | /* 547 | .directory h3.swap { 548 | height: 61px; 549 | background-repeat: no-repeat; 550 | background-image: url("yourimage.gif"); 551 | } 552 | .directory h3.swap span { 553 | display: none; 554 | } 555 | */ 556 | 557 | .directory > h3 { 558 | margin-top: 0; 559 | } 560 | 561 | .directory p { 562 | margin: 0px; 563 | white-space: nowrap; 564 | } 565 | 566 | .directory div { 567 | display: none; 568 | margin: 0px; 569 | } 570 | 571 | .directory img { 572 | vertical-align: -30%; 573 | } 574 | 575 | /* these are for tree view when not used as main index */ 576 | 577 | .directory-alt { 578 | font-size: 100%; 579 | font-weight: bold; 580 | } 581 | 582 | .directory-alt h3 { 583 | margin: 0px; 584 | margin-top: 1em; 585 | font-size: 11pt; 586 | } 587 | 588 | .directory-alt > h3 { 589 | margin-top: 0; 590 | } 591 | 592 | .directory-alt p { 593 | margin: 0px; 594 | white-space: nowrap; 595 | } 596 | 597 | .directory-alt div { 598 | display: none; 599 | margin: 0px; 600 | } 601 | 602 | .directory-alt img { 603 | vertical-align: -30%; 604 | } 605 | 606 | /* @end */ 607 | 608 | div.dynheader { 609 | margin-top: 8px; 610 | } 611 | 612 | address { 613 | font-style: normal; 614 | color: #2A3D61; 615 | } 616 | 617 | table.doxtable { 618 | border-collapse:collapse; 619 | } 620 | 621 | table.doxtable td, table.doxtable th { 622 | border: 1px solid #2D4068; 623 | padding: 3px 7px 2px; 624 | } 625 | 626 | table.doxtable th { 627 | background-color: #374F7F; 628 | color: #FFFFFF; 629 | font-size: 110%; 630 | padding-bottom: 4px; 631 | padding-top: 5px; 632 | text-align:left; 633 | } 634 | 635 | table.fieldtable { 636 | width: 100%; 637 | margin-bottom: 10px; 638 | border: 1px solid #A8B8D9; 639 | border-spacing: 0px; 640 | -moz-border-radius: 4px; 641 | -webkit-border-radius: 4px; 642 | border-radius: 4px; 643 | -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; 644 | -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); 645 | box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); 646 | } 647 | 648 | .fieldtable td, .fieldtable th { 649 | padding: 3px 7px 2px; 650 | } 651 | 652 | .fieldtable td.fieldtype, .fieldtable td.fieldname { 653 | white-space: nowrap; 654 | border-right: 1px solid #A8B8D9; 655 | border-bottom: 1px solid #A8B8D9; 656 | vertical-align: top; 657 | } 658 | 659 | .fieldtable td.fielddoc { 660 | border-bottom: 1px solid #A8B8D9; 661 | width: 100%; 662 | } 663 | 664 | .fieldtable tr:last-child td { 665 | border-bottom: none; 666 | } 667 | 668 | .fieldtable th { 669 | background-image:url('nav_f.png'); 670 | background-repeat:repeat-x; 671 | background-color: #E2E8F2; 672 | font-size: 90%; 673 | color: #253555; 674 | padding-bottom: 4px; 675 | padding-top: 5px; 676 | text-align:left; 677 | -moz-border-radius-topleft: 4px; 678 | -moz-border-radius-topright: 4px; 679 | -webkit-border-top-left-radius: 4px; 680 | -webkit-border-top-right-radius: 4px; 681 | border-top-left-radius: 4px; 682 | border-top-right-radius: 4px; 683 | border-bottom: 1px solid #A8B8D9; 684 | } 685 | 686 | 687 | .tabsearch { 688 | top: 0px; 689 | left: 10px; 690 | height: 36px; 691 | background-image: url('tab_b.png'); 692 | z-index: 101; 693 | overflow: hidden; 694 | font-size: 13px; 695 | } 696 | 697 | .navpath ul 698 | { 699 | font-size: 11px; 700 | background-image:url('tab_b.png'); 701 | background-repeat:repeat-x; 702 | height:30px; 703 | line-height:30px; 704 | color:#8AA0CC; 705 | border:solid 1px #C2CDE4; 706 | overflow:hidden; 707 | margin:0px; 708 | padding:0px; 709 | } 710 | 711 | .navpath li 712 | { 713 | list-style-type:none; 714 | float:left; 715 | padding-left:10px; 716 | padding-right:15px; 717 | background-image:url('bc_s.png'); 718 | background-repeat:no-repeat; 719 | background-position:right; 720 | color:#364D7C; 721 | } 722 | 723 | .navpath li.navelem a 724 | { 725 | height:32px; 726 | display:block; 727 | text-decoration: none; 728 | outline: none; 729 | } 730 | 731 | .navpath li.navelem a:hover 732 | { 733 | color:#6884BD; 734 | } 735 | 736 | .navpath li.footer 737 | { 738 | list-style-type:none; 739 | float:right; 740 | padding-left:10px; 741 | padding-right:15px; 742 | background-image:none; 743 | background-repeat:no-repeat; 744 | background-position:right; 745 | color:#364D7C; 746 | font-size: 8pt; 747 | } 748 | 749 | 750 | div.summary 751 | { 752 | float: right; 753 | font-size: 8pt; 754 | padding-right: 5px; 755 | width: 50%; 756 | text-align: right; 757 | } 758 | 759 | div.summary a 760 | { 761 | white-space: nowrap; 762 | } 763 | 764 | div.ingroups 765 | { 766 | margin-left: 5px; 767 | font-size: 8pt; 768 | padding-left: 5px; 769 | width: 50%; 770 | text-align: left; 771 | } 772 | 773 | div.ingroups a 774 | { 775 | white-space: nowrap; 776 | } 777 | 778 | div.header 779 | { 780 | background-image:url('nav_h.png'); 781 | background-repeat:repeat-x; 782 | background-color: #F9FAFC; 783 | margin: 0px; 784 | border-bottom: 1px solid #C4CFE5; 785 | } 786 | 787 | div.headertitle 788 | { 789 | padding: 5px 5px 5px 7px; 790 | } 791 | 792 | dl 793 | { 794 | padding: 0 0 0 10px; 795 | } 796 | 797 | dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug 798 | { 799 | border-left:4px solid; 800 | padding: 0 0 0 6px; 801 | } 802 | 803 | dl.note 804 | { 805 | border-color: #D0C000; 806 | } 807 | 808 | dl.warning, dl.attention 809 | { 810 | border-color: #FF0000; 811 | } 812 | 813 | dl.pre, dl.post, dl.invariant 814 | { 815 | border-color: #00D000; 816 | } 817 | 818 | dl.deprecated 819 | { 820 | border-color: #505050; 821 | } 822 | 823 | dl.todo 824 | { 825 | border-color: #00C0E0; 826 | } 827 | 828 | dl.test 829 | { 830 | border-color: #3030E0; 831 | } 832 | 833 | dl.bug 834 | { 835 | border-color: #C08050; 836 | } 837 | 838 | #projectlogo 839 | { 840 | text-align: center; 841 | vertical-align: bottom; 842 | border-collapse: separate; 843 | } 844 | 845 | #projectlogo img 846 | { 847 | border: 0px none; 848 | } 849 | 850 | #projectname 851 | { 852 | font: 300% Tahoma, Arial,sans-serif; 853 | margin: 0px; 854 | padding: 2px 0px; 855 | } 856 | 857 | #projectbrief 858 | { 859 | font: 120% Tahoma, Arial,sans-serif; 860 | margin: 0px; 861 | padding: 0px; 862 | } 863 | 864 | #projectnumber 865 | { 866 | font: 50% Tahoma, Arial,sans-serif; 867 | margin: 0px; 868 | padding: 0px; 869 | } 870 | 871 | #titlearea 872 | { 873 | padding: 0px; 874 | margin: 0px; 875 | width: 100%; 876 | border-bottom: 1px solid #5373B4; 877 | } 878 | 879 | .image 880 | { 881 | text-align: center; 882 | } 883 | 884 | .dotgraph 885 | { 886 | text-align: center; 887 | } 888 | 889 | .mscgraph 890 | { 891 | text-align: center; 892 | } 893 | 894 | .caption 895 | { 896 | font-weight: bold; 897 | } 898 | 899 | div.zoom 900 | { 901 | border: 1px solid #90A5CE; 902 | } 903 | 904 | dl.citelist { 905 | margin-bottom:50px; 906 | } 907 | 908 | dl.citelist dt { 909 | color:#334975; 910 | float:left; 911 | font-weight:bold; 912 | margin-right:10px; 913 | padding:5px; 914 | } 915 | 916 | dl.citelist dd { 917 | margin:2px 0; 918 | padding:5px 0; 919 | } 920 | 921 | @media print 922 | { 923 | #top { display: none; } 924 | #side-nav { display: none; } 925 | #nav-path { display: none; } 926 | body { overflow:visible; } 927 | h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } 928 | .summary { display: none; } 929 | .memitem { page-break-inside: avoid; } 930 | #doc-content 931 | { 932 | margin-left:0 !important; 933 | height:auto !important; 934 | width:auto !important; 935 | overflow:inherit; 936 | display:inline; 937 | } 938 | pre.fragment 939 | { 940 | overflow: visible; 941 | text-wrap: unrestricted; 942 | white-space: -moz-pre-wrap; /* Moz */ 943 | white-space: -pre-wrap; /* Opera 4-6 */ 944 | white-space: -o-pre-wrap; /* Opera 7 */ 945 | white-space: pre-wrap; /* CSS3 */ 946 | word-wrap: break-word; /* IE 5.5+ */ 947 | } 948 | } 949 | 950 | -------------------------------------------------------------------------------- /extras/Documentation/html/_e_e_p_r_o_mex_8h_source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: D:/My Documents/Github/Arduino/Own Arduino libraries/EEPROMEx/Arduino-EEPROMEx/EEPROMex.h Source File 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 51 |
52 |
53 |
54 |
D:/My Documents/Github/Arduino/Own Arduino libraries/EEPROMEx/Arduino-EEPROMEx/EEPROMex.h
55 |
56 |
57 |
00001 /*
 58 | 00002   EEPROMEx.h - Extended EEPROM library
 59 | 00003   Copyright (c) 2012 Thijs Elenbaas.  All right reserved.
 60 | 00004 
 61 | 00005   This library is free software; you can redistribute it and/or
 62 | 00006   modify it under the terms of the GNU Lesser General Public
 63 | 00007   License as published by the Free Software Foundation; either
 64 | 00008   version 2.1 of the License, or (at your option) any later version.
 65 | 00009 
 66 | 00010   This library is distributed in the hope that it will be useful,
 67 | 00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
 68 | 00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 69 | 00013   Lesser General Public License for more details.
 70 | 00014 
 71 | 00015   You should have received a copy of the GNU Lesser General Public
 72 | 00016   License along with this library; if not, write to the Free Software
 73 | 00017   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 74 | 00018 */
 75 | 00019 
 76 | 00020 #ifndef EEPROMEX_h
 77 | 00021 #define EEPROMEX_h
 78 | 00022 
 79 | 00023 #if ARDUINO >= 100
 80 | 00024 #include <Arduino.h> 
 81 | 00025 #else
 82 | 00026 #include <WProgram.h> 
 83 | 00027 #endif
 84 | 00028 #include <inttypes.h>
 85 | 00029 #include <avr/eeprom.h>
 86 | 00030 
 87 | 00031 
 88 | 00032 #define EEPROMSizeATmega168   512     
 89 | 00033 #define EEPROMSizeATmega328   1024     
 90 | 00034 #define EEPROMSizeATmega1280  4096     
 91 | 00035 #define EEPROMSizeATmega32u4  1024
 92 | 00036 #define EEPROMSizeAT90USB1286 4096
 93 | 00037 #define EEPROMSizeMK20DX128   2048
 94 | 00038 #define EEPROMSizeMK20DX256   2048
 95 | 00039 #define EEPROMSizeATSAMD21G18 16384          
 96 | 00040 
 97 | 00041 #define EEPROMSizeUno         EEPROMSizeATmega328     
 98 | 00042 #define EEPROMSizeUnoSMD      EEPROMSizeATmega328
 99 | 00043 #define EEPROMSizeLilypad     EEPROMSizeATmega328
100 | 00044 #define EEPROMSizeDuemilanove EEPROMSizeATmega328
101 | 00045 #define EEPROMSizePro         EEPROMSizeATmega328
102 | 00046 #define EEPROMSizeFio         EEPROMSizeATmega328
103 | 00047 #define EEPROMSizeMega        EEPROMSizeATmega1280
104 | 00048 #define EEPROMSizeDiecimila   EEPROMSizeATmega168
105 | 00049 #define EEPROMSizeNano        EEPROMSizeATmega168
106 | 00050 #define EEPROMSizeTeensy2     EEPROMSizeATmega32u4
107 | 00051 #define EEPROMSizeLeonardo    EEPROMSizeATmega32u4
108 | 00052 #define EEPROMSizeMicro       EEPROMSizeATmega32u4
109 | 00053 #define EEPROMSizeEsplora     EEPROMSizeATmega32u4
110 | 00054 #define EEPROMSizeYun         EEPROMSizeATmega32u4
111 | 00055 #define EEPROMSizeTre         EEPROMSizeATmega32u4
112 | 00056 #define EEPROMSizeZero        EEPROMSizeATSAMD21G18
113 | 00057 #define EEPROMSizeTeensy2pp   EEPROMSizeAT90USB1286
114 | 00058 #define EEPROMSizeTeensy3     EEPROMSizeMK20DX128
115 | 00059 #define EEPROMSizeTeensy31    EEPROMSizeMK20DX256
116 | 00060 class EEPROMClassEx
117 | 00061 {
118 | 00062       
119 | 00063   public:
120 | 00064     EEPROMClassEx();
121 | 00065     bool     isReady();
122 | 00066     int      writtenBytes();
123 | 00067     void     setMemPool(int base, int memSize);
124 | 00068     void     setMaxAllowedWrites(int allowedWrites);
125 | 00069     int      getAddress(int noOfBytes);
126 | 00070     
127 | 00071     uint8_t  read(int); 
128 | 00072     bool     readBit(int, byte);
129 | 00073     uint8_t  readByte(int);
130 | 00074     uint16_t readInt(int);
131 | 00075     uint32_t readLong(int);
132 | 00076     float    readFloat(int);
133 | 00077     double   readDouble(int);
134 | 00078             
135 | 00079     bool     write(int, uint8_t);
136 | 00080     bool     writeBit(int , uint8_t, bool);
137 | 00081     bool     writeByte(int, uint8_t);
138 | 00082     bool     writeInt(int, uint16_t);
139 | 00083     bool     writeLong(int, uint32_t);
140 | 00084     bool     writeFloat(int, float);
141 | 00085     bool     writeDouble(int, double);
142 | 00086 
143 | 00087     bool     update(int, uint8_t);
144 | 00088     bool     updateBit(int , uint8_t, bool);
145 | 00089     bool     updateByte(int, uint8_t);
146 | 00090     bool     updateInt(int, uint16_t);
147 | 00091     bool     updateLong(int, uint32_t);
148 | 00092     bool     updateFloat(int, float);
149 | 00093     bool     updateDouble(int, double);
150 | 00094 
151 | 00095     
152 | 00096     // Use template for other data formats
153 | 00097 
154 | 00101     template <class T> int readBlock(int address, const T value[], int items)
155 | 00102     {
156 | 00103         unsigned int i;
157 | 00104         for (i = 0; i < (unsigned int)items; i++)
158 | 00105             readBlock<T>(address+(i*sizeof(T)),value[i]);
159 | 00106         return i;
160 | 00107     }
161 | 00108 
162 | 00112     template <class T> int readBlock(int address, const T& value)
163 | 00113     {       
164 | 00114         eeprom_read_block((void*)&value, (const void*)address, sizeof(value));
165 | 00115         return sizeof(value);
166 | 00116     }
167 | 00117     
168 | 00121     template <class T> int writeBlock(int address, const T value[], int items)
169 | 00122     {   
170 | 00123         if (!isWriteOk(address+items*sizeof(T))) return 0;
171 | 00124         unsigned int i;
172 | 00125         for (i = 0; i < (unsigned int)items; i++)
173 | 00126               writeBlock<T>(address+(i*sizeof(T)),value[i]);
174 | 00127         return i;
175 | 00128     }
176 | 00129 
177 | 00133     template <class T> int writeBlock(int address, const T& value)
178 | 00134     {
179 | 00135         if (!isWriteOk(address+sizeof(value))) return 0;
180 | 00136         eeprom_write_block((void*)&value, (void*)address, sizeof(value));                         
181 | 00137         return sizeof(value);
182 | 00138     }
183 | 00139      
184 | 00144     template <class T> int updateBlock(int address, const T value[], int items)
185 | 00145     {
186 | 00146         int writeCount=0;
187 | 00147         if (!isWriteOk(address+items*sizeof(T))) return 0;
188 | 00148         unsigned int i;
189 | 00149         for (i = 0; i < (unsigned int)items; i++)
190 | 00150               writeCount+= updateBlock<T>(address+(i*sizeof(T)),value[i]);
191 | 00151         return writeCount;
192 | 00152     }
193 | 00153     
194 | 00158     template <class T> int updateBlock(int address, const T& value)
195 | 00159     {
196 | 00160         int writeCount=0;
197 | 00161         if (!isWriteOk(address+sizeof(value))) return 0;
198 | 00162         const byte* bytePointer = (const byte*)(const void*)&value;
199 | 00163         for (unsigned int i = 0; i < (unsigned int)sizeof(value); i++) {
200 | 00164             if (read(address)!=*bytePointer) {
201 | 00165                 write(address, *bytePointer);
202 | 00166                 writeCount++;       
203 | 00167             }
204 | 00168             address++;
205 | 00169             bytePointer++;
206 | 00170         }
207 | 00171         return writeCount;
208 | 00172     }
209 | 00173     
210 | 00174     
211 | 00175     
212 | 00176 private:
213 | 00177     //Private variables
214 | 00178     static int _base;
215 | 00179     static int _memSize;
216 | 00180     static int _nextAvailableaddress;   
217 | 00181     static int _writeCounts;
218 | 00182     int _allowedWrites; 
219 | 00183     bool checkWrite(int base,int noOfBytes);    
220 | 00184     bool isWriteOk(int address);
221 | 00185     bool isReadOk(int address);
222 | 00186 };
223 | 00187 
224 | 00188 extern EEPROMClassEx EEPROM;
225 | 00189 
226 | 00190 #endif
227 | 00191 
228 | 
229 | 230 | 231 | 236 | 237 | 238 | 239 | -------------------------------------------------------------------------------- /extras/Documentation/html/class_e_e_p_r_o_m_class_ex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EEPROMEx: EEPROMClassEx Class Reference 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 |
25 |
EEPROMEx 26 |  1.0.0 27 |
28 |
EEPROMEX is an extension of the standard Arduino EEPROM library for reading and writing basic types, structs, strings, arrays and more.
29 |
36 |
37 | 38 | 39 | 46 | 53 |
54 |
55 | 57 |
58 |
EEPROMClassEx Class Reference
59 |
60 |
61 | 62 |

List of all members.

63 | 64 | 66 | 67 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 |

65 | Public Member Functions

bool isReady ()
68 | int writtenBytes ()
void setMemPool (int base, int memSize)
void setMaxAllowedWrites (int allowedWrites)
int getAddress (int noOfBytes)
uint8_t read (int)
bool readBit (int, byte)
uint8_t readByte (int)
uint16_t readInt (int)
uint32_t readLong (int)
float readFloat (int)
double readDouble (int)
bool write (int, uint8_t)
bool writeBit (int, uint8_t, bool)
bool writeByte (int, uint8_t)
bool writeInt (int, uint16_t)
bool writeLong (int, uint32_t)
bool writeFloat (int, float)
bool writeDouble (int, double)
bool update (int, uint8_t)
bool updateBit (int, uint8_t, bool)
bool updateByte (int, uint8_t)
bool updateInt (int, uint16_t)
bool updateLong (int, uint32_t)
bool updateFloat (int, float)
bool updateDouble (int, double)
template<class T >
int readBlock (int address, const T value[], int items)
template<class T >
int readBlock (int address, const T &value)
template<class T >
int writeBlock (int address, const T value[], int items)
template<class T >
int writeBlock (int address, const T &value)
template<class T >
int updateBlock (int address, const T value[], int items)
template<class T >
int updateBlock (int address, const T &value)
106 |

Member Function Documentation

107 | 108 |
109 |
110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 |
int EEPROMClassEx::getAddress (int noOfBytes)
119 |
120 |
121 |

Get a new starting address to write to. Adress is negative if not enough space is available

122 | 123 |
124 |
125 | 126 |
127 |
128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 |
bool EEPROMClassEx::isReady ()
136 |
137 |
138 |

Check if EEPROM memory is ready to be accessed

139 | 140 |
141 |
142 | 143 |
144 |
145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 |
uint8_t EEPROMClassEx::read (int address)
154 |
155 |
156 |

Read a single byte This function performs as readByte and is added to be similar to the EEPROM library

157 | 158 |

References readByte().

159 | 160 |

Referenced by updateBlock().

161 | 162 |
163 |
164 | 165 |
166 |
167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 |
bool EEPROMClassEx::readBit (int address,
byte bit 
)
186 |
187 |
188 |

Read a single bit

189 | 190 |
191 |
192 | 193 |
194 |
195 |
196 | template<class T >
197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 |
int EEPROMClassEx::readBlock (int address,
const T value[],
int items 
) [inline]
222 |
223 |
224 |

Template function to read multiple items of any type of variable, such as structs

225 | 226 |
227 |
228 | 229 |
230 |
231 |
232 | template<class T >
233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 |
int EEPROMClassEx::readBlock (int address,
const T & value 
) [inline]
252 |
253 |
254 |

Template function to read any type of variable, such as structs

255 | 256 |
257 |
258 | 259 |
260 |
261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 |
uint8_t EEPROMClassEx::readByte (int address)
270 |
271 |
272 |

Read a single byte

273 | 274 |

Referenced by read(), and updateBit().

275 | 276 |
277 |
278 | 279 |
280 |
281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 |
double EEPROMClassEx::readDouble (int address)
290 |
291 |
292 |

Read a single double value (size will depend on board type)

293 | 294 |
295 |
296 | 297 |
298 |
299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 |
float EEPROMClassEx::readFloat (int address)
308 |
309 |
310 |

Read a single float value

311 | 312 |
313 |
314 | 315 |
316 |
317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 |
uint16_t EEPROMClassEx::readInt (int address)
326 |
327 |
328 |

Read a single 16 bits integer

329 | 330 |
331 |
332 | 333 |
334 |
335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 |
uint32_t EEPROMClassEx::readLong (int address)
344 |
345 |
346 |

Read a single 32 bits integer

347 | 348 |
349 |
350 | 351 |
352 |
353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 |
void EEPROMClassEx::setMaxAllowedWrites (int allowedWrites)
362 |
363 |
364 |

Set global maximum of allowed writes

365 | 366 |
367 |
368 | 369 |
370 |
371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 |
void EEPROMClassEx::setMemPool (int base,
int memSize 
)
390 |
391 |
392 |

Set starting position and memory size that EEPROMEx may manage

393 | 394 |
395 |
396 | 397 |
398 |
399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 |
bool EEPROMClassEx::update (int address,
uint8_t value 
)
418 |
419 |
420 |

Update a single byte The EEPROM will only be overwritten if different. This will reduce wear. This function performs as updateByte and is added to be similar to the EEPROM library

421 | 422 |

References updateByte().

423 | 424 |
425 |
426 | 427 |
428 |
429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 |
bool EEPROMClassEx::updateBit (int address,
uint8_t bit,
bool value 
)
454 |
455 |
456 |

Update a single bit The EEPROM will only be overwritten if different. This will reduce wear.

457 | 458 |

References readByte(), and writeByte().

459 | 460 |

Referenced by writeBit().

461 | 462 |
463 |
464 | 465 |
466 |
467 |
468 | template<class T >
469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 |
int EEPROMClassEx::updateBlock (int address,
const T value[],
int items 
) [inline]
494 |
495 |
496 |

Template function to update multiple items of any type of variable, such as structs The EEPROM will only be overwritten if different. This will reduce wear.

497 | 498 |
499 |
500 | 501 |
502 |
503 |
504 | template<class T >
505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 |
int EEPROMClassEx::updateBlock (int address,
const T & value 
) [inline]
524 |
525 |
526 |

Template function to update any type of variable, such as structs The EEPROM will only be overwritten if different. This will reduce wear.

527 | 528 |

References read(), and write().

529 | 530 |
531 |
532 | 533 |
534 |
535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 |
bool EEPROMClassEx::updateByte (int address,
uint8_t value 
)
554 |
555 |
556 |

Update a single byte The EEPROM will only be overwritten if different. This will reduce wear.

557 | 558 |

Referenced by update().

559 | 560 |
561 |
562 | 563 |
564 |
565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 |
bool EEPROMClassEx::updateDouble (int address,
double value 
)
584 |
585 |
586 |

Update a single double value (size will depend on board type) The EEPROM will only be overwritten if different. This will reduce wear.

587 | 588 |
589 |
590 | 591 |
592 |
593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 |
bool EEPROMClassEx::updateFloat (int address,
float value 
)
612 |
613 |
614 |

Update a single float value The EEPROM will only be overwritten if different. This will reduce wear.

615 | 616 |
617 |
618 | 619 |
620 |
621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 |
bool EEPROMClassEx::updateInt (int address,
uint16_t value 
)
640 |
641 |
642 |

Update a single 16 bits integer The EEPROM will only be overwritten if different. This will reduce wear.

643 | 644 |
645 |
646 | 647 |
648 |
649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 |
bool EEPROMClassEx::updateLong (int address,
uint32_t value 
)
668 |
669 |
670 |

Update a single 32 bits integer The EEPROM will only be overwritten if different. This will reduce wear.

671 | 672 |
673 |
674 | 675 |
676 |
677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 |
bool EEPROMClassEx::write (int address,
uint8_t value 
)
696 |
697 |
698 |

Write a single byte This function performs as writeByte and is added to be similar to the EEPROM library

699 | 700 |

References writeByte().

701 | 702 |

Referenced by updateBlock().

703 | 704 |
705 |
706 | 707 |
708 |
709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 |
bool EEPROMClassEx::writeBit (int address,
uint8_t bit,
bool value 
)
734 |
735 |
736 |

Write a single bit

737 | 738 |

References updateBit().

739 | 740 |
741 |
742 | 743 |
744 |
745 |
746 | template<class T >
747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 |
int EEPROMClassEx::writeBlock (int address,
const T value[],
int items 
) [inline]
772 |
773 |
774 |

Template function to write multiple items of any type of variable, such as structs

775 | 776 |
777 |
778 | 779 |
780 |
781 |
782 | template<class T >
783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 |
int EEPROMClassEx::writeBlock (int address,
const T & value 
) [inline]
802 |
803 |
804 |

Template function to write any type of variable, such as structs

805 | 806 |
807 |
808 | 809 |
810 |
811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 |
bool EEPROMClassEx::writeByte (int address,
uint8_t value 
)
830 |
831 |
832 |

Write a single byte

833 | 834 |

Referenced by updateBit(), and write().

835 | 836 |
837 |
838 | 839 |
840 |
841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 |
bool EEPROMClassEx::writeDouble (int address,
double value 
)
860 |
861 |
862 |

Write a single double value (size will depend on board type)

863 | 864 |
865 |
866 | 867 |
868 |
869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 |
bool EEPROMClassEx::writeFloat (int address,
float value 
)
888 |
889 |
890 |

Write a single float value

891 | 892 |
893 |
894 | 895 |
896 |
897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 |
bool EEPROMClassEx::writeInt (int address,
uint16_t value 
)
916 |
917 |
918 |

Write a single 16 bits integer

919 | 920 |
921 |
922 | 923 |
924 |
925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 |
bool EEPROMClassEx::writeLong (int address,
uint32_t value 
)
944 |
945 |
946 |

Write a single 32 bits integer

947 | 948 |
949 |
950 |
The documentation for this class was generated from the following files:
    951 |
  • D:/My Documents/Github/Arduino/Own Arduino libraries/EEPROMEx/Arduino-EEPROMEx/EEPROMex.h
  • 952 |
  • D:/My Documents/Github/Arduino/Own Arduino libraries/EEPROMEx/Arduino-EEPROMEx/EEPROMex.cpp
  • 953 |
954 |
955 | 956 | 957 | 962 | 963 | 964 | 965 | --------------------------------------------------------------------------------