Page 1 of 1

Temperature Sensor Refactor

Posted: Sun Jan 13, 2013 6:47 pm
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

Re: Temperature Sensor Refactor

Posted: Sun Jan 13, 2013 7:46 pm
by rimai
Awesome!!

Re: Temperature Sensor Refactor

Posted: Mon Jan 14, 2013 1:44 pm
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?

Re: Temperature Sensor Refactor

Posted: Mon Jan 14, 2013 6:05 pm
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

Re: Temperature Sensor Refactor

Posted: Mon Jan 14, 2013 6:28 pm
by rossbryant1956
We like simple. Thx to all that program this wonderful product for those of us that copy, cut, and paste.

Re: Temperature Sensor Refactor

Posted: Fri Jan 25, 2013 6:13 pm
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.

Re: Temperature Sensor Refactor

Posted: Sun Jan 27, 2013 4:46 pm
by bondolo
No I hadn't seen that. I will check. Perhaps I left in a debug print that is pulling something in.