Changing the User Space

Modified on Wed, 4 Jan, 2023 at 10:29 PM

This example shows how to configure the User Spaces so that it only contains a Byte Space of 200 bytes and a Long Space of 400 bytes. In this case, the User Space will only use 600 bytes (the first 600 memory cells).


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 \ 2_UserSpaceConfig


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


We first configure the User Space using HC_eeprom.setUserSpace() so that it only holds 2 sub-spaces: The Byte Space and the Long Space. Their sizes are specified in bytes. 


Then, we retrieve the number of elements contained in these sub-spaces using HC_eeprom.getUserSpace_DataQty() and we display them in Command Panels of Analog Data 0 and 1. The number of elements contained in a sub-space depends on its data type and size.


#include <HITIComm.h>

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

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

  // display the number of elements contained in the sub-spaces
  HC_analogDataWrite(0, HC_eeprom.getUserSpace_DataQty(HC_USERSPACE_BYTE));
  HC_analogDataWrite(1, HC_eeprom.getUserSpace_DataQty(HC_USERSPACE_LONG));
}

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

  

Control Panels

1) Display the DATA Control Panels

2) We see that the Byte Space contains 200 Bytes and the Long Space contains 100 Longs.




EEPROM Panel

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



2) Display the Memory Cells.

3) Use the navigation arrows to go through the cells. After address 600, you will notice that all cells are grey which means they are not assigned to any User Space.



4) Display the Byte Space.

5) Go to the last index by using the navigation arrow. As expected, the last index is 199, which is normal since there are 200 Bytes.



6) Do the same check with the Long Space. You should find that the last index is 99.








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 at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article