Closed ron064 closed 10 years ago
Thanks for the suggestion.
I've coded a first try (build ok, untested with gps) (https://github.com/jay3/PebbleBike-PebbleWatchFace/commit/30bd67472f07b5d21778193eba0313c02d5b03a2) and I'm saving 1.8K of RAM.
Very nice I guess the "/10"is meant to reduce to 1 digit display right of the decimal. in case you actually have data in there, you can get a bit better accuracy by doing +5. example: s_gpsdata.distance100 / 100, (s_gpsdata.distance100 % 100 +5)/10 if you don't have data there, you can rename and use distance10. but I guess that keeping all the same way have an advantage.
I like the "+5" idea (round instead of trunc...). I will add that.
I'm storing 2 digits (distance100) because that's the precision I receive from the phone (in my optimized algorithm). But I don't display it (at least not for the moment).
Job done. We' saved a bit more than 2K with your 2 ideas (save 12% of memory).
Thanks a lot
Just to let your know, there was a bug in the "round" algorithm:
s_gpsdata.distance100 / 100, (s_gpsdata.distance100 % 100 +5)/10 should have been (s_gpsdata.distance100+5) / 100, ((s_gpsdata.distance100 + 5) % 100)/10
=> 8.96 was rounded to 8.10 instead of 9.0
Jay
Interesting. Problem with math code is that you have to test It with values when you are not sure. Sometimes I put routines inside test loops and feed them data. Sometimes I encapsulate with test rotine on PC and use debugger.
Are you interested in overlay experiment? If you will separate your screens to code that can be unloaded and reloaded, it should be easy. Data can be stored separately if you need it to be ready for next reload. (Or be saved into persistent if it's done before exit.)
Your code should be easy to convert to overlay.
JayPS notifications@github.com wrote:
Just to let your know, there was a bug in the "round" algorithm:
s_gpsdata.distance100 / 100, (s_gpsdata.distance100 % 100 +5)/10 should have been (s_gpsdata.distance100+5) / 100, ((s_gpsdata.distance100 + 5) % 100)/10
=> 8.96 was rounded to 8.10 instead of 9.0
Jay
— Reply to this email directly or view it on GitHub.
Float are not supported by processor. using them adds float library that increase the code by nearly 2K. It should be relatively easy to use integers instead of Floats. I think there are only: speed, distance and avgspeed. (+distance of friend) Just multiply by 10 or by 100 (simply skip the existing division and divide only for display.)
lines like ftoa(s_gpsdata.distance, tmp, 10, 1); snprintf(s_data.distance, sizeof(s_data.distance), "%s", tmp); can be replaces with something like snprintf(s_data.distance, sizeof(s_data.distance), "%d.%d", s_gpsdata.distance/100, s_gpsdata.distance%100 );
I don't like to do it myself because it's better to understand the application to avoid missing something