Configuring the String Space

Modified on Tue, 03 Jan 2023 at 06:37 PM

This example shows 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 Memory Space.


Refer to section EEPROM Panel to understand how our library and HITIPanel manage data in the EEPROM (Memory Space, User Space…).



Sketch

Upload this 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. 


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


#include <HITIComm.h>

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 
}

void loop()
{
  // communicate with HITIPanel
  HC_communicate();
}



EEPROM Panel

1) Open the EEPROM Panel. As you can see, the User Space only contains the String Space.



2) Display the String Space

3) Go to the last index by using the navigation arrow. The last String index is 50, which means there are 51 Strings.



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



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.



6) Go back to the Memory Cells and find cell 920 using the address selector. The main cell is in Purple and the 19 others are in Black.







Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article