Go Down

Topic: TFT library alters values in a struct (Read 611 times) previous topic - next topic


Feb 28, 2013, 07:30 pm Last Edit: Feb 28, 2013, 07:41 pm by bobo01 Reason: 1

I have the following code.

Code: [Select]
Serial.println("sensorUIInfo->airTemp MAIN C");
getAirTemp();  //Air Temp = 23
 //Draw pH value
 myGLCD.printNumF(sensorUIInfo->phLevel, 1, 20, 120);
 Serial.println("sensorUIInfo->airTemp MAIN D");
getAirTemp();  //Air Temp = 32

The reason is that printNumF, if I do printNumI or nothing it's OK.  Somehow that printF alters the value.

The struct is like this:

Code: [Select]
//All the data from the HW sensors.
   struct SENSOR{
   float phLevel;
   float eCLevel;
   int airTemp;
   int waterTemp;

SENSOR* sensorUIInfo;

And I update from the engine to the UI like this:

Code: [Select]
void HydroponicsUI::updateInfoFromSensors( SENSOR* sensorInformation )
sensorUIInfo->phLevel = sensorInformation->phLevel;
sensorUIInfo->eCLevel = sensorInformation->eCLevel;
sensorUIInfo->airTemp = sensorInformation->airTemp;
sensorUIInfo->waterTemp =  sensorInformation->waterTemp;    


The controller does the update like this:

Code: [Select]
//Update the UI of the latest Sensor Info
  Hydro_UI.updateInfoFromSensors( Hydro_Eng.getSensorInformation() );

Is this an error in my code?




If I pass by reference it is working OK.  Any ideas what mistake I made when using those pointers?  Are pointers the correct way to do it here?

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131