Configuring the User Space

The library supplies a variable called “HC_eeprom” to manage the User Space from your program.

The User Space configuration is usually performed during the setup(). It is done by setting the size (in bytes) of each sub-space using the following function:

  • HC_eeprom.setUserSpace(Boolean, Byte, Integer, Long, Float, String)

 

1) Keeping all sub-spaces

void setup()
{
  // initialize library
  HC_begin();

  // configure User Space (sub-spaces sizes)
  HC_eeprom.setUserSpace(
    20,    // Boolean space : default 50 bytes
    100,   // Byte space    : default 100 bytes
    100,   // Integer space : default 200 bytes
    100,   // Long space    : default 250 bytes
    300,   // Float space   : default 250 bytes
    4096); // String space  : default 4096 bytes
}

In this example, we ask the sub-spaces to have the following sizes:

  • Boolean : 20 bytes
  • Byte        : 100 bytes
  • Integer   : 100 bytes
  • Long       : 100 bytes
  • Float       : 300 bytes
  • String     : 4096 bytes

Note that the String Space size is set to a high value so that it fills the remaining free space. Its true size will depend on the available memory space:

blobid1.png

 

2) Removing sub-spaces (1)

If you want to remove a sub-space, set its size to 0.

Space allocation is done in a specific order, starting with Boolean Space, and ending with String Space. If the first allocated sub-spaces are too big, the remaining non-allocated sub-spaces are either shortened or removed (size set to 0).

Refer to this example : Configuring the User Space.

void setup()
{
  // initialize library
  HC_begin();

  // configure User Space (sub-spaces sizes)
  HC_eeprom.setUserSpace(
    0,    // Boolean space : default 50
    500,  // Byte space    : default 100
    0,    // Integer space : default 200
    4096, // Long space    : default 250
    0,    // Float space   : default 250
    0);   // String space  : default 4096
}

blobid2.png

 

3) Removing sub-spaces (2)

You are not required to allocate all the memory space. The remaining non-allocated space will just be unused by the library.

Refer to this example : Configuring the User Space.

void setup()
{
  // initialize library
  HC_begin();

  // configure User Space (sub-spaces sizes)
  HC_eeprom.setUserSpace(
    0,    // Boolean space : default 50
    500,  // Byte space    : default 100
    0,    // Integer space : default 200
    0,    // Long space    : default 250
    0,    // Float space   : default 250
    0);   // String space  : default 4096
}

blobid3.png

 

4) Configuring the String Space

String Space configuration is done by setting the max length of all the Strings stored inside (this length does not include the terminating char ‘\0’), using the following function:

  • HC_eeprom.setMaxStringLength(length) =>  possible length values : 1 to 30, default 30.

You can retrieve this configuration parameter with:

  • HC_eeprom.getMaxStringLength() =>  return length (byte)

Refer to this example : Configuring the String Space.

void setup()
{
  // initialize library
  HC_begin();

  // configure String Space
  HC_eeprom.setMaxStringLength(15); // 1 to 30, default 30
}

In this example, the default configuration is applied, except that the max String length is 15.

This length impacts on the number of String which can be recorded in the String Space. For the Arduino Uno, the default String Space size is 130. So, the number of String which can be contained in the String Space here is 130/15 = 8 Strings.

 

5) Using the default configuration

Refer to this example : Using the EEPROM Panel.

#include <HITIComm.h>


// run once at power on
void setup()
{
  // initialize library
  HC_begin();
}


// run repeatedly after setup()
void loop()
{
  // communicate with HITIPanel
  HC_communicate();
}

In the default configuration, we ask the sub-spaces to have the following sizes:

  • Boolean : 50 bytes
  • Byte       : 100 bytes
  • Integer   : 200 bytes
  • Long      : 250 bytes
  • Float      : 250 bytes
  • String    : 4096

Note that the String Space size is set to a high value so that it fills the remaining free space. Its true size will depend on the available memory space:

blobid0.png

 

 

Was this article helpful?
0 out of 0 found this helpful