Skip to content

Commit e181e84

Browse files
Copilotdorkmo
andcommitted
Use dynamic initialization for gRpmLastPinState in setup() and remove unused gRpmPulseCount
Co-authored-by: dorkmo <1923070+dorkmo@users.noreply.github.com>
1 parent bd84821 commit e181e84

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

TankAlarm-112025-Client-BluesOpta/TankAlarm-112025-Client-BluesOpta.ino

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,9 @@ static bool gRelayActiveForTank[MAX_TANKS] = {false};
271271

272272
// RPM sensor state for Hall effect pulse counting
273273
// We track pulses per tank that uses an RPM sensor
274-
static uint32_t gRpmPulseCount[MAX_TANKS] = {0};
275274
static unsigned long gRpmLastSampleMillis[MAX_TANKS] = {0};
276275
static float gRpmLastReading[MAX_TANKS] = {0.0f};
277-
static int gRpmLastPinState[MAX_TANKS] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH};
276+
static int gRpmLastPinState[MAX_TANKS]; // Initialized dynamically in setup()
278277

279278
// RPM sampling duration in milliseconds (sample for a few seconds each period)
280279
#ifndef RPM_SAMPLE_DURATION_MS
@@ -349,6 +348,13 @@ void setup() {
349348
Serial.println(F("Warning: Watchdog timer not available on this platform"));
350349
#endif
351350

351+
// Initialize RPM sensor state arrays dynamically
352+
for (uint8_t i = 0; i < MAX_TANKS; ++i) {
353+
gRpmLastPinState[i] = HIGH;
354+
gRpmLastSampleMillis[i] = 0;
355+
gRpmLastReading[i] = 0.0f;
356+
}
357+
352358
for (uint8_t i = 0; i < gConfig.tankCount; ++i) {
353359
gTankState[i].currentInches = 0.0f;
354360
gTankState[i].lastReportedInches = -9999.0f;

0 commit comments

Comments
 (0)