123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #ifndef EEPROMAnything_H
- #define EEPROMAnything_H
- #include <EEPROM.h>
- #include <Arduino.h> // for type definitions
- // Source: http://arduino.cc/playground/Code/EEPROMWriteAnything
- // [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
- // []
- // [] V-Strom Mk1B - An extra display for a Suzuki DL-650 ("V-Strom") that adds the following functionality:
- // [] 1. Battery Level display in Volts - e.g. 14.5V
- // [] 2. Gear Position Indicator on LCD - e.g. 1, 2, 3, 4, 5, 6, N
- // [] 3. Ambient Temperature in Farenheight or Celsius - e.g. 62.5F
- // [] 4. [Future] LED display of gear position (one led for each gear 1-6, in different colors, N will be blinking on 1)
- // [] 5. [Future] Accurate display of the fuel level (in percentage)
- // [] 6. [Future] Show Fuel consumption - MPG or KM/L, TBD: need to tap into motorcycle's speed sensor (PWM)
- // [] 7. [Future] Fix the OEM V-Strom Fuel Gauge to become linear
- // [] License: GPL V3
- /*
- Stromputer - Enhanced display for Suzuki V-Strom Motorcycles (DL-650, DL-1000, years 2004-2011)
- Copyright (C) 2011 Yuval Naveh
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /*
- .::::::.:::::::::::::::::::.. ... . :::::::::::. ... :::::::::::::::.,:::::: :::::::..
- ;;;` `;;;;;;;;'''';;;;``;;;; .;;;;;;;. ;;,. ;;;`;;;```.;;;;; ;;;;;;;;;;;'''';;;;'''' ;;;;``;;;;
- '[==/[[[[, [[ [[[,/[[[' ,[[ \[[,[[[[, ,[[[[,`]]nnn]]'[[' [[[ [[ [[cccc [[[,/[[['
- ''' $ $$ $$$$$$c $$$, $$$$$$$$$$$"$$$ $$$"" $$ $$$ $$ $$"""" $$$$$$c
- 88b dP 88, 888b "88bo,"888,_ _,88P888 Y88" 888o888o 88 .d888 88, 888oo,__ 888b "88bo,
- "YMmMY" MMM MMMM "W" "YMMMMMP" MMM M' "MMMYMMMb "YmmMMMM"" MMM """"YUMMMMMMM "W"
- */
- // Write a template value into EEPROM address [ee]
- template <class T> int EEPROM_writeAnything(int ee, const T& value)
- {
- const byte* p = (const byte*)(const void*)&value;
- unsigned int i;
- for (i = 0; i < sizeof(value); i++)
- EEPROM.write(ee++, *p++);
- return i;
- }
- // Read a template value from EEPROM address [ee]
- template <class T> int EEPROM_readAnything(int ee, T& value)
- {
- byte* p = (byte*)(void*)&value;
- unsigned int i;
- for (i = 0; i < sizeof(value); i++)
- *p++ = EEPROM.read(ee++);
- return i;
- }
- #endif
|