Skip to content

Commit 5952071

Browse files
committed
fixed issue with hanging uninit ADCs
1 parent 608f2f9 commit 5952071

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pio_workspace/lib/power_custom/adc_sensors.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,27 @@ bool ADCSensors::begin(bool enableVoltage, bool enableCurrent, TwoWire* wire) {
3838
float* ADCSensors::senseVoltage() {
3939
if (voltageEnabled) {
4040
refreshVoltage();
41-
4241
voltageValues[0] = convertVoltage(computedADCVoltage[0]);
4342
voltageValues[1] = convertVoltage(computedADCVoltage[1]);
44-
45-
return voltageValues;
4643
} else {
47-
return nullptr;
44+
voltageValues[0] = -1.0;
45+
voltageValues[1] = -1.0;
4846
}
47+
return voltageValues;
4948
}
5049

5150
float* ADCSensors::senseCurrent() {
5251
if (currentEnabled) {
5352
refreshCurrent();
54-
5553
for (int i = 0; i < 8; i++) {
5654
currentValues[i] = convertCurrent(computedADCCurrent[i]);
5755
}
58-
59-
return currentValues;
6056
} else {
61-
return nullptr;
57+
for (int i = 0; i < 8; i++) {
58+
currentValues[i] = -1.0;
59+
}
6260
}
61+
return currentValues;
6362
}
6463

6564
void ADCSensors::refreshVoltage() {

0 commit comments

Comments
 (0)