Skip to main content
Senior III
November 13, 2025
Solved

What's the best location for request read from EEPROM for init

  • November 13, 2025
  • 3 replies
  • 147 views

I would like to read some data from the EEPROM on initialization to use in the TouchGFX application.

I currently have an API that can request read/write operations from TouchGFX to the backend.

At the moment, I've implemented it in the Model.hpp

 void bind(ModelListener* listener)
 {
 modelListener = listener;

 if (!storageInitialized) {
 initializeFromStorage();
 storageInitialized = true;
 }
 }

with

void Model::initializeFromStorage()
{
 #ifndef SIMULATOR
 StorageResponse_t wr = Storage_Request(STORAGE_CMD_READ,
 EEPROM_ADDR_STRUCT_2,
 &struct2,
 sizeof(struct2));
 
 wr = Storage_Request(STORAGE_CMD_READ,
 EEPROM_ADDR_STRUCT_1,
 &struct1,
 sizeof(struct1));
 #endif
}

but I'm not sure if it's the correct location.

I just want to send the read EEPROM command on the first load of TouchGFX and never again

Best answer by Osman SOYKURT

Hello @nico23 ,

Are you trying to read purely GUI-related data, such as variables to be stored in the model later? If so, using the bind method seems appropriate. However, if the data pertains to TouchGFX initialization—like determining which screen to start with—you may need to call initializeFromStorage() beforehand.

3 replies

Osman SOYKURT
Osman SOYKURTBest answer
Technical Moderator
November 18, 2025

Hello @nico23 ,

Are you trying to read purely GUI-related data, such as variables to be stored in the model later? If so, using the bind method seems appropriate. However, if the data pertains to TouchGFX initialization—like determining which screen to start with—you may need to call initializeFromStorage() beforehand.

Osman SOYKURTST Software Developer | TouchGFX
nico23Author
Senior III
November 18, 2025

Hi @Osman SOYKURT 

Yes, they are data purely stored in the model and used only for the GUI to display (or not) certain things when moving to the various views.

Out of curiosity, what's the location in case I want to run initializeFromStorage() beforehand?

Thanks

Osman SOYKURT
Technical Moderator
November 18, 2025

Ok actually the example I took (determining which screen to start with) might not be the the best because you could also handle this in the model easily. I think everything that is related to your TouchGFX application can be handled inside of it. 

Osman SOYKURTST Software Developer | TouchGFX