Giter Club home page Giter Club logo

eewrap's People

Contributors

chris--a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

eewrap's Issues

The same funcionality for external SPI SRAM?

Hello,

great job! Thank you for such a library!

Recently I have added SPI SRAM (128 Kb) to my Arduino shield board. It works. But after I saw your library immediately I started to think - is it possible to modify the lib to work with external SRAM in a similar way? It could bring a lot of possibilities.

Best regards!

A Lot of issues with your library

Hi, nice idea of a library with some design flaws. The major problems are the pointer (address) and using char type when it needs to be an unsigned char like a byte really is. Get mixed results with this library but overall pretty unreliable for now.

The pointer address you are using is too large to use as EEPROM storage address because most build-in EEPROM's are pretty small, like 1024 bytes (1Kb) or lower. Also there can be huge gaps between locations of variables that makes it very inefficient. Made a debug function and most of the time it is above the limit of the EEPROM size and overflows and overwriting other data. Another problem is that the pointer can change when you upload a new compiled sketch with modifications, so the address changes and produces 'wrong' indexes. In fact all stored values are lost.

The char issue, for example in these functions you are using a char* pointer and not a unsigned char pointer or better an uint8_t* pointer. The EEPROM function/routine expect a byte value, not a char value. So strange things may happen when a larger value than 127 or less than zero is passed thru the update function or a byte retrieved that is larger than 127.

inline void EEReadBlockElement(  char *out, uint8_t *addr, const unsigned int len ){
            for( unsigned int i = 0 ; i < len ; ++i ) *out-- = EEPROM[int(addr++)];
        }

        inline void EEWriteBlockElement(  const char *in, uint8_t *addr, const unsigned int len ){
            for( unsigned int i = 0 ; i < len ; i++ ){
                const char b = *in;
                EEPROM[int(addr++)].update(b);
                --in;
            }
}

Did you test this library anyway, or did you test this library only with low values and with a few declarations? You have to test your library better before posting great achievements, I don't think you are able to fix this pointer/address problem because of the way it is designed. There is no unique and stable identifier.

Also have some doubts about the EEMEM usage, see this example you provide at the project page:

//Use the xxx_e types rather than the standard types like uint8_t
struct Foo{
  uint8_e a;
  int16_e b;
  float_e c;
};

Foo foo EEMEM; //EEMEM tells the compiler that the object resides in the EEPROM 

By using uint8_e etc instead of uint8_t you already notice the compiler to use the class you designed and it's value will be stored or retrieved from EEPROM. Again, did you test this library anyway, it doesn't make any sense and doesn't work either.

Using EEWrapto store array in EEPROM

Hi!
I'm doing a project where I want to store some parameters to the EEPROM in case of power loss. The data is JSON formatted, and stores data for an audio DSP.

I created this simple program as a test. However, the microcontroller (ATmega32, doesn't really matter) hangs before it gets to the printing part. If I comment out dsp.vol and dsp.eq_band1 strcyp part, it works fine.

I'm sure I'm doing something wrong here, but I can't figure out what. Do you have any idea whats wrong?

Thanks ๐Ÿ˜ƒ

#include <EEPROM.h>
#include <EEWrap.h>

//Struct to store DSP data
struct dspData {
  char* eq_band1;
  char* vol;
  char* mux;
};

dspData dsp EEMEM; //EEMEM tells the compiler that the object resides in the EEPROM

void setup(){
  // Init
  Serial.begin(9600);
  Serial.println("Begin!");

  // Store data to EEPROM
  strcpy(dsp.mux, "{\"address\":24,\"mux_data\":1}");
  strcpy(dsp.vol, "{\"address\":1,\"volume\":1900000,\"slew\":2048}");
  strcpy(foo.eq_band1, "{\"b0\": 8425988,\"b1\":-16712212,\"b2\":8288286,\"a1\":16712212,\"a2\":-8325666}");
  
  // Print data
  Serial.println(dsp.eq_band1);
  Serial.println(dsp.vol);
  Serial.println(dsp.mux);
}

void loop() {}

Implement functionality like this to external i2c EEPROMs

First I was to say thank you for your excellent work on this an many other libraries. I see myself as a "skilled amateur programmer" so I wonder; how can I learn to write so compact (and so hard to understand ;-) ) libraries like this? I mean, the super "high level" EEPROM library you've written compile Wil less than a kilobyte on the UNO. Hands down, I'm impressed.

But enough with the worshipping. Would it be possible to create a library like this to work with external i2c EEPROMs (24c32, 24c16, they exist from 128B to 2048kB)? IIRC they're also bye orientated. I think the whole community would benefit from a library like that! I'd love to be able to write something like this myself, but I doesn't got what it takes (yet!)

EEMEM causes an error in Platform IO

Error is on the "Settings setting EEMEM; " line "Expecting ";" instead of EEMEM
//Declare eeprom variables.
struct Settings{
uint8_e deviceNo;
float_e longitude;
float_e latitude;
uint8_e timezone;
uint16_e doorOpenValue; // 1023 external limit sensor, 1 = Read limit switch pin
uint16_e doorClosedValue; // Zero external limit sensor, 1 = Read limit switch pin
uint16_e closeDelay; // Minutes
uint16_e openDelay; // Minutes
uint16_e cycleTime; // Zero = No shelf/door installed
float_e rechargeTarget;
float_e rechargeMin;
float_e rechargeMax;
uint8_e motorRunMax;
uint16_e pressureTarget;
uint16_e pressureMin;
uint16_e pressureMax;
};
Settings setting EEMEM;
//EEMEM tells the compiler that the object resides in the EEPROM

EEWrap.h won't compile in Arduino Script

Error Message is as shown below

" /Arduino/libraries/EEWrap/EEWrap.h:71:122: error: template argument 2 is invalid
value = is_number::value || is_bool::value || is_same< T, wchar_t >::value || is_same< T, char16_t >::value
^
Error compiling. "

placed in file with only #include <EEPROM.h> and #include <EEWrap.h> and still had issue.

Also won't compile in basic test provided

Possible incompatibility with sprintf

Hello! Thank you for your excellent library!

I slightly modified your example to highlight this strange behaviour:
sprintf( tmpString, "foo.a=%02d" , foo.a ); prints 26350 instead of 45
meanwhile
sprintf( tmpString, "foo.a=%02d" , uint8_t(foo.a) ); works well

=============================================

#include <EEPROM.h>
#include <EEWrap.h>

//Use the xxx_e types rather than the standard types like uint8_t
struct Foo{
uint8_e a;
int16_e b;
float_e c;
};

Foo foo EEMEM; //EEMEM tells the compiler that the object resides in the EEPROM

void setup(){

//Write to values stored in EEPROM
foo.a = 45;
foo.b = 12345;
foo.c = 3.1415;

//Print values from EEPROM
Serial.begin(9600);
Serial.println(foo.a);
Serial.println(foo.b);
Serial.println(foo.c);

char tmpString[20] = {0};
sprintf( tmpString, "foo.a=%02d" , foo.a );
Serial.println( tmpString ); // it prints " foo.a=26350 "
}

void loop() {}

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.