Using the User Space

Data read/write

The following functions let you easily read or write data in the sub-spaces. The index is the data index inside the sub-spaces (min value = 0, max value = number of elements – 1).

Note that writing to a cell is only performed if the data inside this cell needs being updated.

Boolean

  • HC_eeprom.writeBoolean(index, value)   => write value (bool)
  • HC_eeprom.readBoolean(index)                => return value (bool)

Byte

  • HC_eeprom.writeByte(index, value)          => write value (byte)
  • HC_eeprom.readByte(index)                       => return value (byte)

Integer

  • HC_eeprom.writeInteger(index, value)     => write value (int)
  • HC_eeprom.readInteger(index)                  => return value (int)

Long

  • HC_eeprom.writeLong(index, value)          => write value (long)
  • HC_eeprom.readLong(index)                       => return value (long)

Float

  • HC_eeprom.writeFloat(index, value)         => write value (float)
  • HC_eeprom.readFloat(index)                      => return value (float)

String

  • HC_eeprom.writeString(index, value)        => write value (char*)
  • HC_eeprom.readString(index)                     => return value (char*)

Refer to this example : Accessing the User Space.

Sub-spaces configuration details

You can read details about the configuration of a sub-space. To specify which sub-space, use either:

  • The enum HC_USERSPACE_xxxxxx
  • The sub-space index : Boolean (0), Byte (1), Integer (2), Long (3), Float (4), String (5)

Address

  • HC_eeprom.getUserSpace_Address(HC_USERSPACE_xxxxxx)
  • HC_eeprom.getUserSpace_Address(index)

Size (in bytes)

  • HC_eeprom.getUserSpace_Size(HC_USERSPACE_xxxxxx)
  • HC_eeprom.getUserSpace_Size(index)

Number of elements

This is the number of elements contained inside each sub-space.

  • HC_eeprom.getDataQty(HC_USERSPACE_xxxxxx)
  • HC_eeprom.getDataQty(index)
void setup()
{
  // initialize library
  HC_begin();

  // element quantities
  HC_analogDataWrite(0, HC_eeprom.getDataQty(HC_USERSPACE_BOOLEAN));
  HC_analogDataWrite(1, HC_eeprom.getDataQty(HC_USERSPACE_BYTE));
  HC_analogDataWrite(2, HC_eeprom.getDataQty(HC_USERSPACE_INTEGER));
  HC_analogDataWrite(3, HC_eeprom.getDataQty(HC_USERSPACE_LONG));
  HC_analogDataWrite(4, HC_eeprom.getDataQty(HC_USERSPACE_FLOAT));
  HC_analogDataWrite(5, HC_eeprom.getDataQty(HC_USERSPACE_STRING));
}

In the above example, the default configuration is applied. For the Arduino Uno, the number of elements in each sub-space is as follows:

  • Boolean Space : 50 bytes. Each byte contains 8 bits                => 50*8     =  400 Booleans
  • Byte Space        : 100 bytes                                                         =>               100 Bytes 
  • Integer Space   : 200 bytes. Each integer contains 2 bytes      => 200/2    =  100 Integers 
  • Long Space       : 200 bytes. Each long contains 4 bytes          => 200/4   =   50 Longs 
  • Float Space       : 250 bytes. Each float contains 4 bytes           => 200/4   =   50 Floats
  • String Space     : 130 bytes. Default max String length is 30      => 130/30 =   4 Strings
CONTENTS

HITISoftware

Control and Monitoring Software for Arduino