Pages: [1]   Go Down
Author Topic: TFT library alters values in a struct  (Read 335 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I have the following code.

Code:
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:
//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:
void HydroponicsUI::updateInfoFromSensors( SENSOR* sensorInformation )
{
 Serial.println("sensorInformation->airTemp");
 Serial.println(sensorInformation->airTemp);
 sensorUIInfo->phLevel = sensorInformation->phLevel;
 sensorUIInfo->eCLevel = sensorInformation->eCLevel;
 sensorUIInfo->airTemp = sensorInformation->airTemp;
 sensorUIInfo->waterTemp =  sensorInformation->waterTemp;    

}

The controller does the update like this:

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

Is this an error in my code?

Thanks.
« Last Edit: February 28, 2013, 01:41:44 pm by bobo01 » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also:

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?
Logged

Pages: [1]   Go Up
Jump to: