Temperature Sensor Refactor

Related to the development libraries, released by Curt Binder
Post Reply
User avatar
bondolo
Posts: 14
Joined: Fri Nov 23, 2012 2:59 pm

Temperature Sensor Refactor

Post by bondolo »

I've done some work to refactor and document the temperature sensor code. The changes are available in:

GitHub: Pull Request : bondolo : Cleanup of DS18B20 Temperature Sensor Handling

I would appreciate any review comments or suggestions. It's smaller than the original code (That's the most important part, right? :D ) I was tempted to just import one of several DS18B20 libraries that exist for Arduino as it appears there are some subtleties and DS bugs that we might want to avoid.

Assuming this goes well, I will likely keep marching on with refactoring the rest of the temperature handling code within ReefAngel to use only Celsius units internally and have Fahrenheit units only as a display preference. To see units associated with a variable vary at runtime makes my skin crawl!

Mike
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Temperature Sensor Refactor

Post by rimai »

Awesome!!
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Temperature Sensor Refactor

Post by rimai »

I was briefly looking at the commit and saw that you resized the array to size 3.
The reason we had at 4 was to make it simpler to code, should you wanted to use numerical instead of defined variables.
For example:
ReefAngel.Params.Temp[1] would be the same as ReefAngel.Params.Temp[T1_PROBE]
The trade off is an empty spot in the array, which is the 0 index.
What do you think?
Roberto.
User avatar
bondolo
Posts: 14
Joined: Fri Nov 23, 2012 2:59 pm

Re: Temperature Sensor Refactor

Post by bondolo »

I changed the definitions for T1_PROBE, etc. as well. I guess zero based counting doesn't bother me. I don't feel strongly about this though. If you would prefer T1_PROBE to be 1 and the ReefAngel.Params.Temp to have an unused slot for the sake of clarity then I am fine with that.

Mike
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Temperature Sensor Refactor

Post by rossbryant1956 »

We like simple. Thx to all that program this wonderful product for those of us that copy, cut, and paste.
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Temperature Sensor Refactor

Post by rimai »

Hey Mike,
Did you read the comment I left on the pull request?
It is not working for me here and it also made my code larger by about 600 bytes and not smaller.
Roberto.
User avatar
bondolo
Posts: 14
Joined: Fri Nov 23, 2012 2:59 pm

Re: Temperature Sensor Refactor

Post by bondolo »

No I hadn't seen that. I will check. Perhaps I left in a debug print that is pulling something in.
Post Reply