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;
|
static unsigned long lastInterruptTime = 0;
|
||||||
unsigned long interruptTime = micros();
|
unsigned long interruptTime = micros();
|
||||||
|
|
||||||
if (interruptTime - lastInterruptTime > 200) {
|
if ((interruptTime - lastInterruptTime) > 200) {
|
||||||
cardData <<= 1;
|
if (bitCount < 34) {
|
||||||
cardData |= bitValue;
|
cardData <<= 1;
|
||||||
newDataAvailable = true;
|
cardData |= bitValue;
|
||||||
bitCount++; // Increment the bit count
|
newDataAvailable = true;
|
||||||
|
bitCount++; // Increment the bit count
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastInterruptTime = interruptTime;
|
if (bitCount <= 34) {
|
||||||
lastDataTime = millis(); // Update the time of last received data
|
lastInterruptTime = interruptTime;
|
||||||
|
lastDataTime = millis(); // Update the time of last received data
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleData0Interrupt() {
|
void handleData0Interrupt() {
|
||||||
handleInterrupt(0);
|
handleInterrupt(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue