We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 11b095d commit f1a5ed6Copy full SHA for f1a5ed6
examples/Nano33BLESenseFirmware/Nano33BLESenseFirmware.ino
@@ -61,13 +61,11 @@ void readVoltage() {
61
62
uint16_t getVoltageAverage() {
63
uint16_t avg = 0;
64
- for (int i = 0; i < VOLTAGE_BUFFER_SIZE; i++) {
+ byte upperBound = voltageBufferFilled ? VOLTAGE_BUFFER_SIZE : voltageBufferIndex;
65
+ for (int i = 0; i < upperBound; i++) {
66
avg += voltageSampleBuffer[i];
67
}
- if (voltageBufferFilled) {
68
- return avg / VOLTAGE_BUFFER_SIZE;
69
- }
70
- return avg / voltageBufferIndex;
+ return avg / upperBound;
71
72
73
// String to calculate the local and device name
0 commit comments