stop runaway bits
This commit is contained in:
parent
8f3154b6d7
commit
ed39c215d0
1 changed files with 11 additions and 8 deletions
19
src/main.cpp
19
src/main.cpp
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue