multiply current measurement by -1 to force positive value for current being sunk

This commit is contained in:
Jake Dahl
2018-07-19 12:07:32 -06:00
committed by Lorenz Meier
parent b9a60f0f29
commit 58e81ef66b
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -185,7 +185,7 @@ void BATT_SMBUS::cycle()
// Read current.
if (read_word(BATT_SMBUS_CURRENT, &tmp) == PX4_OK) {
new_report.current_a = ((float)(*(int16_t *)&tmp)) / 1000.0f;
new_report.current_a = (-1.0f * ((float)(*(int16_t *)&tmp)) / 1000.0f);
new_report.current_filtered_a = new_report.current_a;
} else {
@@ -194,7 +194,7 @@ void BATT_SMBUS::cycle()
// Read average current.
if (read_word(BATT_SMBUS_AVERAGE_CURRENT, &tmp) == PX4_OK) {
new_report.average_current_a = ((float)(*(int16_t *)&tmp)) / 1000.0f;
new_report.average_current_a = (-1.0f * ((float)(*(int16_t *)&tmp)) / 1000.0f);
} else {
success = false;
+1 -1
View File
@@ -54,7 +54,7 @@ struct batt_smbus_bus_option {
const char *devpath;
BATT_SMBUS_constructor interface_constructor;
uint8_t busnum;
BATT_SMBUS *dev;
BATT_SMBUS *dev;
} bus_options[] = {
{ BATT_SMBUS_BUS_I2C_EXTERNAL, "/dev/batt_smbus_ext", &BATT_SMBUS_I2C_interface, PX4_I2C_BUS_EXPANSION, nullptr },
#ifdef PX4_I2C_BUS_ONBOARD