GithubHelp home page GithubHelp logo

tgolla / eepromtyped Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 11 KB

The EEPROM Typed Library is a lightweight static library for reading and writing standard Arduino data types to the EEPROM.

Home Page: https://terencegolla.com/

License: MIT License

C++ 100.00%
arduino arduino-library

eepromtyped's Introduction

EEPROMTyped Library for Arduino Version 1.0.0

Written by: Terence F. Golla.
Copyright: 2021, Terence F. Golla, Released under MIT licence.

About

The EEPROM Typed Library is a lightweight static library for reading and writing standard Arduino data types to the EEPROM.

The library provides a write and read method call that takes a memory address and standard data type variable which is deconstructed into or reconstructed from byte values written or read from the EEPROM memory. The library also provides a sizeof used to return the variable size in bytes which can be used to calculate memory addresses. The library works with array, bool, byte, char, double, float, int, long, short, size_t, string, unsigned char, unsigned int, unsigned long and word data types.

Usage

write(address, variable)

The write method takes the memory address where it begins to write the value of the variable broken into bytes. The memory usage depends on the sizeof the variable data type.

int blinkFrequency = 5500;

EEPROMTyped.write(0, blinkFrequency);

read(address, variable)

The read method takes the memory address where it begins to read the value of the variable broken into bytes. The memory usage depends on the sizeof the variable data type.

int blinkFrequency;

EEPROMTyped.read(0, blinkFrequency);

Serial.print("The blink frequency is ");
Serial.println(blinkFrequency);

sizeOf(variable)

The sizeOf method returns the size of the variable's data type in bytes. The method is provided to assist in calculating memory addresses.

char message[] = "Hello World!";
int blinkFrequency;

byte messageEEPROMAddress = 0;
byte blinkFrequencyEEPROMAddress = messageEEPROMAddress + EEPROMTyped.sizeOf(message);

EEPROMTyped.write(messageEEPROMAddress, message);
EEPROMTyped.write(blinkFrequencyEEPROMAddress, blinkFrequency);

char messageRead[13];
int blinkFrequencyRead;

EEPROMTyped.write(messageEEPROMAddress, messageRead);
EEPROMTyped.write(blinkFrequencyEEPROMAddress, blinkFrequencyRead);

Serial.print("The message in memory is... ");
Serial.println(messageRead);

Serial.print("The blink frequency in memory is ");
Serial.println(blinkFrequency);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.