Page 1 of 1

Use 2d array in EEPROMStore arduino library

Posted: Thu Oct 15, 2015 2:45 pm
by mtaufiq23
Firstly, im very thankful from the bottom of my heart for making megunolink. This make my works easier than before.

My problem is when using EEPROMStore arduino library with 2d array.
For example, Im trying to put my default config in 'struct' like this in arduino ide:

struct EMFConfiguration
{
byte voltage[3][5];

void Reset()
{
byte voltage [3][5] = {
{1, 2, 3},
{4, 5, 6}
};
}
};

The thing is, the value of the default one are not use by the one i set for eeprom. The value in eeprom is zero for all array.
Am i doing this wrong? Or is there other way to do this. Any help will be appreciated.

Re: Use 2d array in EEPROMStore arduino library

Posted: Sun Oct 25, 2015 10:57 pm
by Paul
Hi,

The problem is you are create a new variable in the reset function which hides the one in the structure. You want something more like this:

Code: Select all

struct EMFConfiguration
{
  byte voltage[2][3];

  void Reset()
  {
    voltage[0][0] = 1;
    voltage[0][1] = 2;
    voltage[0][2] = 3;

    voltage[1][0] = 4;
    voltage[1][1] = 5;
    voltage[1][2] = 6;
  }
}