Configuring the String Space

This example describes how to define the max length of the Strings stored inside the String Space. Here, the User Space is configured so that the String Space fills all the Global Space.

 

1) Sketch: 4_EEPROM \ 3_StringSpaceConfig

In this program, we use the variable “HC_eeprom” supplied by the library to configure the specialized spaces during the setup().

We first configure the User Space using HC_eeprom.setUserSpace() so that it only holds the String Space. Its size is specified in bytes.

Finally, we set the max length of the Strings to 20. This length does not include the terminating char ‘\0’.

#include <HITIComm.h>


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

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

  // set max String length (does not include the terminating char '\0')
  HC_eeprom.setMaxStringLength(20); // 1 to 30, default 30 
}


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

 

2) EEPROM Panel (User Space)

  1. Open the EEPROM Panel (CTRL+E or Tools\EEPROM). As you can see, the User Space only contains the String Space.

    image312.png

  2. Display the String Space (“String” button).
  3. Go to the last index by using the navigation arrow. The last String index is 50, which means there are 51 Strings.

    image315.png

  4. Enter a string value for String 46 whose length is smaller than 20. For instance, enter “I love HITIPanel !” (length = 18).

    image316.png

  5. As the max String length has been set to 20, each String uses 20 memory cells to store its value. Point your mouse cursor over the index of String 46 to find its main cell address. The tooltip indicates address 920.

    image317.png

  6. Go back to the Global Space (“Global” button) and find cell 920 using the address selector. The main cell is in Purple and the 19 others are in Black.

    image319.png

 

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

Comments

0 comments

Please sign in to leave a comment.