GithubHelp home page GithubHelp logo

eerecordsystem's Introduction

EERecordSystem

Trivial EEPROM-based tinyfilesystem for Arduino

Highlights:

  • Minimalist efficiency. It's a single header file containing only template code.
  • File system holds records, let's not call them files.
  • Designed for storing configuration choices. It's friendlier than having fixed locations for things. Makes it easy to provide a minimal configuration editor in-sketch (e.g. via serial).
  • Minimalist in EEPROM consumption. Five EEPROM byte overhead for entire filesystem, plus two bytes per record (one byte per key, one byte for length, plus your data)
  • Longer keys and record lengths supported. Just use something other than byte in the constructor (this is a C++ template class)
  • Each record has an character or integer "key" ** Example: using uint16_t as a key suitable for a multicharacter character constant (e.g. 'ab' == 0x6162)
  • There's no deleting or resizing records in this implementation, but you can add new records and overwrite records where size is the same.

List feature:

  • Designed for also maintaining a list. The prototypical use case is as an access control database of valid 32-bit user ID numbers that occasionally get added or removed. (The size of 32-bits is fixed and isn't templated).
  • You can add/remove ID numbers. You can query if ID numbers are in the list.
  • ID 0xFFFFFFFF is reserved for free space. Removing ID's sets them to this value. Space from deleted IDs remains reserved for new IDs within the same list.
  • There can be more than one ID list. Each whole list is accessed by a single key.

Usage

Example usage with 16-bit keys (two characters) and byte-lengths (so, max record payload size 253 bytes)

#include <EEPROM.h>
#include "EERecordSystem.h"
EERecordSystem<uint16_t,byte> EERS;

uint64_t our_serial_number;


void setup() {
  // Formats the whole EEPROM for use with this class, if not already done.
  // See alternative overload for begin() to use partial EEPROM
  EERS.begin();
  
  // Let's pretend that serial baud is changeable in configuration, but
  // otherwise defaults to 9600.  
  Serial.begin(EERS.getRecordData<uint32_t>('SB', 9600));
  
  // Let's pretend the same for the serial number, but also pretend we want
  // to ask the user (via the serial port) to provide it, rather than accept a default.
  int location_of_serial_number = EERS.getRecordAddress('SN', sizeof(our_serial_number));
  if (location_of_serial_number == -1) {
    Serial.println("Serial number is not set.  Enter it now");
    our_serial_number = get_entry_of_serial_number_from_serial();
    EERS.updateRecord('SN', &our_serial_number, sizeof(our_serial_number));
  } else {
    EEPROM.get(location_of_serial_number, our_serial_number);
  }

Caveats

  • There's currently no functionality for deleting or resizing records. Saving a record with a new size creates a new record.
  • This readme could use a good example of how to use the list functionality, which does allow deletions.

eerecordsystem's People

Contributors

chipguyhere avatar

Watchers

 avatar

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.