Accessing the User Space

Modified on Thu, 05 Jan 2023 at 02:04 PM

This example shows how to access data in the User Space from your program (e.g. Float 17). We will use 2 Buttons to trigger the reading and writing of data in the User 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 \ 4_UserSpaceAccess


When the “WRITE” Button is clicked, we save the value of Analog Data 0 in Float 17 using HC_eeprom.writeFloat(index, value). And when the “READ” 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 (Buttons)
const byte DD_Write = 0; // Write value to EEPROM
const byte DD_Read  = 1; // Read value from EEPROM

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

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

  // If the “WRITE” Button is activated from HITIPanel
  if (HC_digitalDataRead(DD_Write) == HIGH)
  {
    // immediately deactivate Button
    HC_digitalDataWrite(DD_Write, LOW);

    // Analog Data 0 value is written to Float 17 (EEPROM)
    HC_eeprom.writeFloat(17, HC_analogDataRead(0));
  }

  // If the “READ” Button is activated from HITIPanel
  else if (HC_digitalDataRead(DD_Read) == HIGH)
  {
    // immediately deactivate Button
    HC_digitalDataWrite(DD_Read, LOW);

    // Float 17 (EEPROM) is put in Analog Data 1
    HC_analogDataWrite(1, HC_eeprom.readFloat(17));
  }
}



Control Panels 

1) Display the DATA Control Panels

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.




EEPROM Panel

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?

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