Skip to content

Commit b16a67a

Browse files
committed
minor fixes in for() loops
1 parent 758edf5 commit b16a67a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ESP8266-Power-Monitor.ino

+7-7
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ BLYNK_WRITE(vPIN_BUTTON_HOLD) {
181181
}
182182
}
183183

184-
// this function only runs when in HOLD mode and select AUTO-RANGE
184+
// this function only runs when in HOLD mode and select AUTO-RANGE. just shows latest values on demand
185185
void updateINA219eXtraValues() {
186186
Blynk.virtualWrite(vPIN_VOLTAGE_PEAK, String(loadvoltageMax, 3) + String(" V") );
187187
if (current_AVG_total > 1000 && autoRange == 1) {
@@ -206,19 +206,19 @@ BLYNK_WRITE(vPIN_BUTTON_AUTORANGE) {
206206
updateINA219eXtraValues();
207207
}
208208

209-
// RESET AVERAGES
209+
// RESET AVERAGES (short) & RESET STOPWATCH (long)
210210
BLYNK_WRITE(vPIN_BUTTON_RESET_AVG) {
211211
if (param.asInt()) {
212212
Blynk.virtualWrite(vPIN_VOLTAGE_AVG, "--- V");
213213
Blynk.virtualWrite(vPIN_CURRENT_AVG, "--- mA");
214214
Blynk.virtualWrite(vPIN_POWER_AVG, "--- mW");
215-
for (int i = 0; i < AVG_DEPTH_VOLTAGE; i++) {
215+
for (int i = 0; i < (AVG_DEPTH_VOLTAGE - 1); i++) {
216216
loadvoltage_AVG[i] = loadvoltage;
217217
}
218-
for (int i = 0; i < AVG_DEPTH_CURRENT; i++) {
218+
for (int i = 0; i < (AVG_DEPTH_CURRENT - 1); i++) {
219219
current_AVG[i] = current_mA;
220220
}
221-
for (int i = 0; i < AVG_DEPTH_POWER; i++) {
221+
for (int i = 0; i < (AVG_DEPTH_POWER - 1); i++) {
222222
power_AVG[i] = power;
223223
}
224224
delay(50);
@@ -237,7 +237,7 @@ void countdownResetConCallback() {
237237
energyPrevious = 0;
238238
}
239239

240-
// RESET PEAKS
240+
// RESET PEAKS (short) & RESET CONSUMTION (long)
241241
BLYNK_WRITE(vPIN_BUTTON_RESET_MAX) {
242242
if (param.asInt()) {
243243
Blynk.virtualWrite(vPIN_VOLTAGE_PEAK, "--- V");
@@ -289,7 +289,7 @@ void stopwatchCounter() {
289289

290290
// This section is for setting the kWh price from your electric company.
291291
// I use a SPOT rate which means I need to update it all the time.
292-
// If you know your set price per kWh (in cents), then enter the price at the top of the sketch: FIXED_ENERGY_PRICE
292+
// If you know your set price per kWh (in cents), then enter the price in settings: FIXED_ENERGY_PRICE
293293
void getPrice() {
294294
Blynk.virtualWrite(vPIN_ENERGY_API, ENERGY_API); // local API Server to get current power price per mWh
295295
}

0 commit comments

Comments
 (0)