-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LCD Display: Display Energy formatted to significant figures instead of decimal digits. #341
base: master
Are you sure you want to change the base?
Conversation
…lue() so that it can be re-used in other methods.
… figures rather than decimals after the decima point.
…of digits after the decimal point.
@rbsexton thanks for the contribution, been something I have been meaning to do this for a while. Will check it over. |
"m", | ||
"g", | ||
"t", | ||
"p" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened another PR before seeing this one to correct the capitalization of these units - might be worth updating it here since you're moving these around? #344
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one has been laying around! I'd forgotten all about it. I'll update this so that it can get pulled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'm pretty sure that the merge of PR#344 made mine unmergable. I'm going to start over and I'll fix the rounding error while I'm at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, this is something I have been meaning to do for ages. I have added a few comments
"m", | ||
"g", | ||
"t", | ||
"p" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// of significant figures eg, for 4: 1.00598kWh appears as 1.005 rather than 1.0 | ||
// Overloaded on displayScaledNumberValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this example highlights a flaw with the implementation. 1.00598kWh
should be rounded up to 1.006kWh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. printf() doesn't round. I'll add that.
The existing FW scales energy to SI notation and then places one digit after the decimal point.
This doesn't work so well for low values in kWh, ie 1.3kWh.
The ADCs in the system deliver about 3 significant figures, so display this number to a total of four - ie: