Skip to content

Commit

Permalink
bug in digitecopower Sensordriver driver, better timing for i2c-th dr…
Browse files Browse the repository at this point in the history
…iver
  • Loading branch information
pat1 committed Mar 10, 2022
1 parent 425858b commit b265729
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions platformio/libraries/SensorDriver/SensorDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ void SensorDriverTh::prepare(bool is_test) {
_buffer[i++] = I2C_TH_COMMAND_CONTINUOUS_START_STOP;
}
_buffer[i] = crc8(_buffer, i);
_delay_ms = 10;
_delay_ms = 15;
}

if (is_i2c_write) {
Expand Down Expand Up @@ -1881,7 +1881,7 @@ void SensorDriverDigitecoPower::get(int32_t *values, uint8_t length) {
_start_time_ms = millis();

// There is NO CRC on DigitecoPower: workaround until it will to be implemented
if (_is_success && ((battery_voltage >= 0.0) || (battery_voltage < 50.0))) {
if (_is_success && ((battery_voltage >= 0.0) && (battery_voltage < 50.0))) {
values[0] = battery_voltage * 10;
_error_count = 0;
if (length >= 2) {
Expand Down Expand Up @@ -1918,7 +1918,7 @@ void SensorDriverDigitecoPower::get(int32_t *values, uint8_t length) {
_start_time_ms = millis();

// There is NO CRC on DigitecoPower: workaround until it will to be implemented
if (_is_success && ((input_voltage > -10.0) || (input_voltage < 50.0))) {
if (_is_success && ((input_voltage > -10.0) && (input_voltage < 50.0))) {
values[1] = input_voltage * 10;
_error_count = 0;
if (length >= 3) {
Expand Down Expand Up @@ -1956,7 +1956,7 @@ void SensorDriverDigitecoPower::get(int32_t *values, uint8_t length) {
_start_time_ms = millis();

// There is NO CRC on DigitecoPower: workaround until it will to be implemented
if (_is_success && ((battery_charge >= 0.0) || (battery_charge <= 100.0))) {
if (_is_success && ((battery_charge >= 0.0) && (battery_charge <= 100.0))) {
values[2] = battery_charge;
_error_count = 0;
if (length >= 4) {
Expand Down Expand Up @@ -1994,7 +1994,7 @@ void SensorDriverDigitecoPower::get(int32_t *values, uint8_t length) {
_start_time_ms = millis();

// There is NO CRC on DigitecoPower: workaround until it will to be implemented
if (_is_success && ((battery_current >= -5000.0) || (battery_current <= 5000.0))) {
if (_is_success && ((battery_current >= -5000.0) && (battery_current <= 5000.0))) {
values[3] = battery_current * 100.0;
_error_count = 0;
if (length >= 5) {
Expand Down Expand Up @@ -2032,7 +2032,7 @@ void SensorDriverDigitecoPower::get(int32_t *values, uint8_t length) {
_start_time_ms = millis();

// There is NO CRC on DigitecoPower: workaround until it will to be implemented
if (_is_success && ((input_current >= 0.0) || (input_current <= 5000.0))) {
if (_is_success && ((input_current >= 0.0) && (input_current <= 5000.0))) {
values[4] = input_current * 1000.0;
_error_count = 0;
if (length >= 6) {
Expand Down Expand Up @@ -2068,7 +2068,7 @@ void SensorDriverDigitecoPower::get(int32_t *values, uint8_t length) {
_is_success = DigitecoPower::de_read(_address, &output_voltage);

// There is NO CRC on DigitecoPower: workaround until it will to be implemented
if (_is_success && ((output_voltage <0.0) || (output_voltage > 50.0))){
if (_is_success && ((output_voltage <0.0) && (output_voltage > 50.0))){
values[5] = output_voltage * 10.0;
_error_count = 0;
} else {
Expand Down

0 comments on commit b265729

Please sign in to comment.