From 6ec278e97d56b67751127bcabf0a51bb99873a1a Mon Sep 17 00:00:00 2001 From: "Tanner Collin (aider)" Date: Thu, 5 Jun 2025 11:07:19 -0600 Subject: [PATCH] fix: Fix race condition reading pulse count --- tach/tach.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tach/tach.ino b/tach/tach.ino index 5d9f687..fefdf1c 100644 --- a/tach/tach.ino +++ b/tach/tach.ino @@ -50,10 +50,10 @@ void loop() { unsigned long current_time = millis(); if (current_time - last_measurement_time >= MEASUREMENT_PERIOD_MS) { - //detachInterrupt(digitalPinToInterrupt(TACH_INTERRUPT_PIN)); + detachInterrupt(digitalPinToInterrupt(TACH_INTERRUPT_PIN)); unsigned long collected_pulses = pulse_count; pulse_count = 0; - //attachInterrupt(digitalPinToInterrupt(TACH_INTERRUPT_PIN), count_pulse, RISING); + attachInterrupt(digitalPinToInterrupt(TACH_INTERRUPT_PIN), count_pulse, RISING); // Calculate RPM // RPM = (pulses / pulses_per_revolution) / (measurement_period_ms / 1000 / 60)