diff options
author | Randy Mackay <rmackay9@yahoo.com> | 2015-02-19 23:28:04 +0900 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-02-20 16:57:23 +0100 |
commit | d57dd250b938c7971a7a2de702254a0a86340f1a (patch) | |
tree | 1b2c7161ede2162b2ce08827b9ef2c0288c89d3a /src/drivers/batt_smbus/batt_smbus.cpp | |
parent | 8f29a9d83ba1f7dcfaec31735217b4f1d16fef4b (diff) | |
download | px4-firmware-d57dd250b938c7971a7a2de702254a0a86340f1a.tar.gz px4-firmware-d57dd250b938c7971a7a2de702254a0a86340f1a.tar.bz2 px4-firmware-d57dd250b938c7971a7a2de702254a0a86340f1a.zip |
batt_smbus: reverse reported current
smart batteries report a negative current when being discharged
Diffstat (limited to 'src/drivers/batt_smbus/batt_smbus.cpp')
-rw-r--r-- | src/drivers/batt_smbus/batt_smbus.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/drivers/batt_smbus/batt_smbus.cpp b/src/drivers/batt_smbus/batt_smbus.cpp index 92b752a28..604ce35c5 100644 --- a/src/drivers/batt_smbus/batt_smbus.cpp +++ b/src/drivers/batt_smbus/batt_smbus.cpp @@ -368,8 +368,7 @@ BATT_SMBUS::cycle() uint8_t buff[4]; if (read_block(BATT_SMBUS_CURRENT, buff, 4, false) == 4) { - new_report.current_a = (float)((int32_t)((uint32_t)buff[3] << 24 | (uint32_t)buff[2] << 16 | (uint32_t)buff[1] << 8 | - (uint32_t)buff[0])) / 1000.0f; + new_report.current_a = -(float)((int32_t)((uint32_t)buff[3] << 24 | (uint32_t)buff[2] << 16 | (uint32_t)buff[1] << 8 | (uint32_t)buff[0])) / 1000.0f; } // publish to orb |