From d821b54fd4d7fe65d079cf0c38484e1f90ab0dc2 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Mon, 8 Aug 2022 20:42:02 +1200 Subject: [PATCH] special case one ISR period, remove unused vars. --- CRIO.cpp | 6 ++---- CRIO.h | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CRIO.cpp b/CRIO.cpp index 7972951..ad92b0e 100644 --- a/CRIO.cpp +++ b/CRIO.cpp @@ -15,7 +15,7 @@ DigitalPin _coilOutPin(OUTPUT, LOW); DigitalPin _diagOutPin(OUTPUT, LOW); DigitalPin _speakerOutPin(OUTPUT, LOW); -CRIO::CRIO() : scheduled(false), _remainingPulseUs(0), _pulseState(0), pw(pulseWindowUs), maxPitch(maxMidiPitch), breakoutUs(minBreakoutUs), _ticksSinceLastPulse(0), handlePulsePtr(&CRIO::handleNoPulse) { +CRIO::CRIO() : _remainingPulseUs(0), pw(pulseWindowUs), maxPitch(maxMidiPitch), breakoutUs(minBreakoutUs), _ticksSinceLastPulse(0), handlePulsePtr(&CRIO::handleNoPulse) { } bool CRIO::percussionEnabled() { @@ -30,14 +30,12 @@ inline void CRIO::pulseOn() { _speakerOutPin.high(); _diagOutPin.high(); _coilOutPin.high(); - _pulseState = true; } inline void CRIO::pulseOff() { _coilOutPin.low(); _diagOutPin.low(); _speakerOutPin.low(); - _pulseState = false; } bool CRIO::handlePulse() { @@ -86,7 +84,7 @@ void CRIO::schedulePulse(cr_fp_t pulseUs) { return; } _remainingPulseUs = cr_pulse_t(roundFixed(pulseUs)); - if (_remainingPulseUs > masterClockPeriodUs) { + if (_remainingPulseUs >= masterClockPeriodUs) { handlePulsePtr = &CRIO::handleLongPulse; } else { handlePulsePtr = &CRIO::handleShortPulse; diff --git a/CRIO.h b/CRIO.h index 661acbc..2302e85 100644 --- a/CRIO.h +++ b/CRIO.h @@ -40,7 +40,6 @@ class CRIO { virtual void updateLcdCoeff(); virtual bool percussionEnabled(); virtual bool fixedPulseEnabled(); - bool scheduled; cr_fp_t pw; uint8_t maxPitch; cr_fp_t breakoutUs; @@ -51,7 +50,6 @@ class CRIO { bool handleNoPulse(); void pulseOff(); void pulseOn(); - bool _pulseState; bool (CRIO::*handlePulsePtr)(void); cr_pulse_t _remainingPulseUs; uint16_t _ticksSinceLastPulse;