Closed tochinet closed 11 years ago
I like your correction, but you are repeating the code of setDeltaT (float) into setDeltaT(int) and this IS BAD! a good solution is that your int function does that:
setDeltaT(int a){ setDeltaT(a/10.0); //force to be float, and divide by 10 }
that way correction in setDeltaT code are to be made in one point only. skecth size should aldo decrease.
BUT
because float are evil with precision, and because in the variable delta we take in account only for the first decimal, maybe is better to do the contrary: leave your setDeltaT as it is and change (and deprecate)
/@DEPRECATE! it is here only for backcompatibility. use setDeltaT(int a) setDeltaT(float a){ setDeltaT( int(a*10) ); //force to be int with decimal of second }
at we should encurage the use of your function because we are sure decimal is the right value... and this is not possible useing float.
2013/3/28 Tochinet notifications@github.com
I really love swRTC, but I was annoyed that I couldn't read back the DeltaT correction. Also I felt that using floats only for that was a disservice to the library, because an int with tenths of seconds would fits more easily in integer only Arduino sketches.
However, my first try using the forked library seems to indicate an increase of compiled size instead of a decrease. Maybe I did forget some
class specific stuff for overloaded methods ?
You can merge this Pull Request by running
git pull https://github.com/tochinet/swRTC master
Or view, comment on, or merge it at:
https://github.com/leomil72/swRTC/pull/1 Commit Summary
- Update README.md
- Update swRTC.h
- Update swRTC.cpp
- Update swRTC.cpp
File Changes
- M README.md https://github.com/leomil72/swRTC/pull/1/files#diff-0(1)
- M swRTC.cpp https://github.com/leomil72/swRTC/pull/1/files#diff-1(25)
- M swRTC.h https://github.com/leomil72/swRTC/pull/1/files#diff-2(3)
Patch Links:
Agree. I didn't want to break it... And I think that the gcc anyway would throw away the version that is never used at compile time, so it may be better than usign teh same code in the end...
OK for the deprecation of float, makes sense.
BUT what I can't understand is why when going from float to int my sketch size actually increases !!! That is contrary to the logic.
You are right about function not used, but those are method, I don't know if the same rule apply Il giorno 29/mar/2013 15:39, "Tochinet" notifications@github.com ha scritto:
Agree. I didn't want to break it... And I think that the gcc anyway would throw away the version that is never used at compile time, so it may be better than usign teh same code in the end...
OK for the deprecation of float, makes sense.
BUT what I can't understand is why when going from float to int my sketch size actually increases !!! That is contrary to the logic.
— Reply to this email directly or view it on GitHubhttps://github.com/leomil72/swRTC/pull/1#issuecomment-15643468 .
I've modified the code of the library including the new method getDeltaT. I've also reviewed the method setDeltaT. Now it accepts integers from -8,400 to +8,400 tenths of seconds. At the moment this method is still compatible with the old syntax that uses floats but I think that I'll drop it off the lib so I marked it as deprecated and I suggest, in the README file, to use the new one.
I really love swRTC, but I was annoyed that I couldn't read back the DeltaT correction. Also I felt that using floats only for that was a disservice to the library, because an int with tenths of seconds would fits more easily in integer only Arduino sketches.
However, my first try using the forked library seems to indicate an increase of compiled size instead of a decrease. Maybe I did forget some class specific stuff for overloaded methods ?