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? ) 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
Temperature Sensor Refactor
Re: Temperature Sensor Refactor
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?
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.
Re: Temperature Sensor Refactor
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
Mike
-
- Posts: 471
- Joined: Sat Jan 14, 2012 2:08 pm
- Location: Montgomery Village, MD
Re: Temperature Sensor Refactor
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.
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.
Re: Temperature Sensor Refactor
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.
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.
Re: Temperature Sensor Refactor
No I hadn't seen that. I will check. Perhaps I left in a debug print that is pulling something in.