Temp sensor customization

Related to the development libraries, released by Curt Binder
Post Reply
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Temp sensor customization

Post by binder »

There has been some "issues" with the way the libraries are allowing the changing of the temp sensor used to monitor the Overheat and with the Heater & Fan/Chillers.

Currently, I was using a pointer to reference the parameter value for the sensor. The temp sensor values are stored in the Parameters structure and are labeled like this:
Temp1, Temp2, Temp3
To reference them, you use Params.Temp1, Params.Temp2, Params.Temp3.
I was using a reference to switch the parameters around. Using the reference seems to be a little problematic.

I've come up with a solution and I wanted to get some feedback before I implement it fully. I'm going to switch the temp sensor values to an array. Then we can just reference an index into the array for the value that we want and not use any pointers. This will greatly simplify the readability of the code and make the customization for the Heater & Fan/Chiller probe along with the Overheat probe much easier.
We will have 3 defines to reference the probe index:
T1_PROBE, T2_PROBE, T3_PROBE
and then the parameters structure would change to this:
Temp[3]
and referencing them would be Params.Temp[T1_PROBE], Params.Temp[T2_PROBE], Params.Temp[T3_PROBE]
Finally, to change the heater and overheat probes, you would do something like this:

Heater & Chiller/Fan probe
ReefAngel.TempProbe = T1_PROBE;
Overheat probe
ReefAngel.OverheatProbe = T2_PROBE;

This appears to make things simpler to read and work with. The downside is that it will break older PDEs that use CustomMain screens and are displaying their own temp values. Also, it would break any custom code inside PDEs that rely on temperature checks. Of course the breaks are fixed very easily (just changing the way you reference the value like above).

Any thoughts on this proposed change?

curt
wolfador
Posts: 241
Joined: Sun Sep 04, 2011 9:59 am
Location: Pittsburgh, PA

Re: Temp sensor customization

Post by wolfador »

I think an array would be better as it should be more stable and if the only downside is older PDE's breaking it should be okay since like you said they are easily fixed.
John
ReefAngel and ReefAngel-HD developer
If the RA iOS app has helped please consider a donation
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Temp sensor customization

Post by rimai »

Works for me.
Roberto.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Temp sensor customization

Post by TanksNStuff »

Was this change implemented in the new libraries? I used to have a custom main screen using reefangel.params.temp1 (to display the temp 1 value separately in a custom location) but now I kept getting an error by using that reference. Searched and found this thread and changed it to reefangel.params.temp[T1_PROBE] and the error went away.

Now my only issue seems to be file size. I've got my new .ino customized to show the same custom main screen as I had before... but had to strip out all menus and I didn't put any custom functions in the loop section yet.

Ah well, guess I'll have to make a separate thread on that tomorrow. I'm too tired to do it tonight. :(
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Temp sensor customization

Post by rimai »

Try enabling Simple Menu on RAGen.
Open RAGen
Click Features
Check Simple Menu
Hit Save
Roberto.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Temp sensor customization

Post by TanksNStuff »

I had it that way originally and the file was too long. I actually changed to "custom menu" and just didn't have any menu at all... and I just barely had it small enough to compile.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Temp sensor customization

Post by binder »

TanksNStuff wrote:Was this change implemented in the new libraries? I used to have a custom main screen using reefangel.params.temp1 (to display the temp 1 value separately in a custom location) but now I kept getting an error by using that reference. Searched and found this thread and changed it to reefangel.params.temp[T1_PROBE] and the error went away.
Yes, this was implemented.

Look at the first item under "changes to the libraries". there are code samples that show how to customize what probe monitors the heater & fans and for overheat temps.
http://forum.reefangel.com/viewtopic.php?f=7&t=725
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Temp sensor customization

Post by TanksNStuff »

Ah, I read that post and never noticed it was there. Doh! Thanks Curt!

So, those lines in the examples basically just let you assign which probe is used for the "overheat" or general "heater/fan" operation functions?

Also, the "T1_PROBE, T2_PROBE or T3_PROBE" are the new designations for probe names to be referred when getting data for other functions (like displaying on the screen or as modifiers for IF statements, etc.)?
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Temp sensor customization

Post by binder »

TanksNStuff wrote:Ah, I read that post and never noticed it was there. Doh! Thanks Curt!

So, those lines in the examples basically just let you assign which probe is used for the "overheat" or general "heater/fan" operation functions?
Yes. That is what they are for.
Also, the "T1_PROBE, T2_PROBE or T3_PROBE" are the new designations for probe names to be referred when getting data for other functions (like displaying on the screen or as modifiers for IF statements, etc.)?
Those labels are actually indices to the array that stores the temperatures. This way you don't have to "guess" what index is for what temp probe. In order to reference the temperature, you need to do:

Code: Select all

ReefAngel.Params.Temp[T1_PROBE];
and so forth for the others. You could do:

Code: Select all

ReefAngel.Params.Temp[1];
But it's discouraged in case some things change in the future. It's much more readable and understandable if you spell it out (hence why I created it that way).
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Temp sensor customization

Post by TanksNStuff »

binder wrote: You could do:

Code: Select all

ReefAngel.Params.Temp[1];
But it's discouraged in case some things change in the future. It's much more readable and understandable if you spell it out (hence why I created it that way).
Yea, I tried using ReefAngel.Params.Temp1 (which worked for me before) and that gave me an error.

I got it working with the [T1_PROBE], so I'm all good there. Just trying to understand the concept of why you created it / changed it to this... and your last reply did that for me.

Thanks again Curt.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Temp sensor customization

Post by binder »

Yeah, the ReefAngel.Params.Temp1 won't work anymore.

Another reason for putting the temperatures into an array was to make the selecting of the probes much easier. I can just store an index to the array for which probe to reference and it's super easy. Otherwise, it would be much more complicated to allow customization and selection.
Post Reply