stop runaway bits

This commit is contained in:
Matthew Frost 2023-12-26 17:00:00 +01:00
parent 8f3154b6d7
commit ed39c215d0

View file

@ -112,17 +112,20 @@ void handleInterrupt(int bitValue) {
static unsigned long lastInterruptTime = 0;
unsigned long interruptTime = micros();
if (interruptTime - lastInterruptTime > 200) {
cardData <<= 1;
cardData |= bitValue;
newDataAvailable = true;
bitCount++; // Increment the bit count
if ((interruptTime - lastInterruptTime) > 200) {
if (bitCount < 34) {
cardData <<= 1;
cardData |= bitValue;
newDataAvailable = true;
bitCount++; // Increment the bit count
}
}
lastInterruptTime = interruptTime;
lastDataTime = millis(); // Update the time of last received data
if (bitCount <= 34) {
lastInterruptTime = interruptTime;
lastDataTime = millis(); // Update the time of last received data
}
}
void handleData0Interrupt() {
handleInterrupt(0);
}