mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-29 19:57:12 +08:00
multiply current measurement by -1 to force positive value for current being sunk
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user