Skip to content

Conversation

@shellixyz
Copy link
Collaborator

Fixes #3124

int32_t currentSensorToCentiamps(uint16_t src)
{
int32_t microvolts = ((uint32_t)src * ADCVREF * 1000) / 0xFFF - (int32_t)batteryConfig()->current.offset * 1000;
int32_t microvolts = ((uint32_t)src * ADCVREF * 100) / 0xFFF * 10 - (int32_t)batteryConfig()->current.offset * 1000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I didn't realize that after a certain point multiplication result won't fit into 32 bits any more. Since ADCVREF is 3300 we are not loosing any percision with this change.

@digitalentity digitalentity merged commit 969e8e2 into iNavFlight:development Apr 27, 2018
@digitalentity digitalentity added this to the 2.0 milestone Apr 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants