Float voltage to int#444
Merged
JF002 merged 3 commits intoInfiniTimeOrg:developfrom Jul 2, 2021
Riksu9000:float_voltage_to_int
Merged
Float voltage to int#444JF002 merged 3 commits intoInfiniTimeOrg:developfrom Riksu9000:float_voltage_to_int
JF002 merged 3 commits intoInfiniTimeOrg:developfrom
Riksu9000:float_voltage_to_int
Conversation
Collaborator
|
Thanks for this PR!
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In all uses of the voltage variable, the ADC value is first converted to float, and then back to integer.
This PR makes it so the voltage is now in millivolts. If an app requires float for any reason, it can easily be converted in the app.
Previously the precision was limited by roundf() to 10mV, now the precision is ~6mV
The only visible change is that the about page now shows the actual value of the voltage variable, so it is now in millivolts.
In #258, the multiplication was changed from 2 to 2.04. I didn't find any explanation for this change. The *2 compensates for the hardware voltage divider. I think this might have been an error.
voltage = (static_cast<float>(p_event->data.done.p_buffer[0]) * 2.04f) / (1024 / 3.0f);