Post Reply 
Scientific RPN Calculator (with ATTINY85)
03-23-2018, 05:50 AM
Post: #42
RE: Scientific RPN Calculator (with ATTINY85)
Wow I like the idea and the ease you are experimenting.

While optimizing the code for scary I tested the replacement of the "hungry" EEPROM.put and EEPROM.get commands with a 4-byte-solution using EEPROM.write and EEPROM.read:

Code:
static void eepromput(unsigned int addr, double x) { // Put float to EEPROM bytewise
  byte n = sizeof(double);  
  union {
    double f;
    byte b[n];
  } u;
  u.f = x;

  memmove(&u.b[0], &u.f, n);
  while (n--) EEPROM.write(addr++, u.b[n - 1]);
}

static double eepromget(unsigned int addr) { // Get float from EEPROM bytewise
  byte n = sizeof(double);
  union {
    double f;
    byte b[n];
  } u;
  
  while (n--) u.b[n - 1] = EEPROM.read(addr++);
  memmove(&u.f, &u.b[0], sizeof(double));
  return (u.f);
}

This should work (and surely can be optimized) - but unfortunately this solution was more "byte hungry" than using the functions of the library.
But maybe you can use this to avoid the lack of your compiler.

Regards
deetee
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Scientific RPN Calculator (with ATTINY85) - deetee - 03-23-2018 05:50 AM



User(s) browsing this thread: 2 Guest(s)