Accessing the User Space

In this example, you will see how to access data in the User Space from your program (Float 17 from the Float Space). We will use 2 Virtual Buttons to trigger the reading and writing of data in the User Space.


1) Sketch: 4_EEPROM \ 4_UserSpaceAccess

As usual, we check if the Virtual Switches have been activated from HITIPanel. If so, we immediately deactivate them, so they behave like buttons, and we trigger specific actions.

When the “WRITE” Virtual Button is clicked, we save the value of Analog Data 0 in Float 17 using HC_eeprom.writeFloat(index, value). And when the “READ” Virtual Button is clicked, we read the value of Float 17 using HC_eeprom.readFloat(index, value) and we put it in Analog Data 1.

#include <HITIComm.h>

// Digital Data assignment (Virtual Switches)
const byte DD_Write = 0; // Write value to EEPROM
const byte DD_Read  = 1; // Read value from EEPROM

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

// run repeatedly after setup()
void loop()
  // communicate with HITIPanel

  // Write value
  if (HC_digitalDataRead(DD_Write) == HIGH)
    // Analog Data 0 value is written to Float 17 (EEPROM)
    HC_eeprom.writeFloat(17, HC_analogDataRead(0));

    // deactivate Virtual Switch
    HC_digitalDataWrite(DD_Write, LOW);

  // Read value
  else if (HC_digitalDataRead(DD_Read) == HIGH)
    // Float 17 (EEPROM) is put in Analog Data 1
    HC_analogDataWrite(1, HC_eeprom.readFloat(17));

    // deactivate Virtual Switch
    HC_digitalDataWrite(DD_Read, LOW);


2) Control Panels

  1. Display the ANALOG Data Control Panel.
  2. Enter the value -15.784 in Analog Data 0.

  3. Click on  “WRITE” to save the value you entered in Float 17.

  4. Now, click on “READ” to read the value of Float 17 and to put it in Analog Data 1.


3) EEPROM Panel (User Space)

  1. Open the EEPROM Panel.
  2. Display the Float Space.

  3. Refresh cells values (“Read ALL” button). This is REQUIRED because the last Eeprom reading was performed automatically at communication start-up, but you changed the value of Float 17 through the code since then, so you need to refresh the display.
  4. Check that the value of Float 17 is the one you entered.


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