Use 2d array in EEPROMStore arduino library

Support forum for MegunoLink
Post Reply
mtaufiq23
Posts: 5
Joined: Thu Oct 15, 2015 2:30 pm

Thu Oct 15, 2015 2:45 pm

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.
Paul
Posts: 33
Joined: Wed Jun 10, 2015 10:35 pm

Sun Oct 25, 2015 10:57 pm

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;
  }
}
Post Reply