mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-11 08:56:14 +00:00
ISR Commenting
This commit is contained in:
38
irISR.cpp
38
irISR.cpp
@@ -27,14 +27,14 @@ ISR (TIMER_INTR_NAME)
|
||||
if (irparams.rawlen >= RAWBUF) irparams.rcvstate = STATE_OVERFLOW ; // Buffer overflow
|
||||
|
||||
switch(irparams.rcvstate) {
|
||||
//......................................................................
|
||||
case STATE_IDLE: // In the middle of a gap
|
||||
if (irdata == MARK) {
|
||||
if (irparams.timer < GAP_TICKS) {
|
||||
// Not big enough to be a gap.
|
||||
if (irparams.timer < GAP_TICKS) { // Not big enough to be a gap.
|
||||
irparams.timer = 0;
|
||||
|
||||
} else {
|
||||
// gap just ended, record duration and start recording transmission
|
||||
// Gap just ended; Record duration; Start recording transmission
|
||||
irparams.overflow = false;
|
||||
irparams.rawlen = 0;
|
||||
irparams.rawbuf[irparams.rawlen++] = irparams.timer;
|
||||
@@ -43,43 +43,43 @@ ISR (TIMER_INTR_NAME)
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_MARK: // timing MARK
|
||||
if (irdata == SPACE) { // MARK ended, record time
|
||||
//......................................................................
|
||||
case STATE_MARK: // Timing Mark
|
||||
if (irdata == SPACE) { // Mark ended; Record time
|
||||
irparams.rawbuf[irparams.rawlen++] = irparams.timer;
|
||||
irparams.timer = 0;
|
||||
irparams.rcvstate = STATE_SPACE;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SPACE: // timing SPACE
|
||||
if (irdata == MARK) { // SPACE just ended, record it
|
||||
//......................................................................
|
||||
case STATE_SPACE: // Timing Space
|
||||
if (irdata == MARK) { // Space just ended; Record time
|
||||
irparams.rawbuf[irparams.rawlen++] = irparams.timer;
|
||||
irparams.timer = 0;
|
||||
irparams.rcvstate = STATE_MARK;
|
||||
|
||||
} else if (irparams.timer > GAP_TICKS) { // SPACE
|
||||
// big SPACE, indicates gap between codes
|
||||
// Mark current code as ready for processing
|
||||
} else if (irparams.timer > GAP_TICKS) { // Space
|
||||
// A long Space, indicates gap between codes
|
||||
// Flag the current code as ready for processing
|
||||
// Switch to STOP
|
||||
// Don't reset timer; keep counting space width
|
||||
// Don't reset timer; keep counting Space width
|
||||
irparams.rcvstate = STATE_STOP;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_STOP: // waiting, measuring gap
|
||||
if (irdata == MARK) irparams.timer = 0 ; // reset gap timer
|
||||
//......................................................................
|
||||
case STATE_STOP: // Waiting; Measuring Gap
|
||||
if (irdata == MARK) irparams.timer = 0 ; // Reset gap timer
|
||||
break;
|
||||
|
||||
case STATE_OVERFLOW: // Flag up a read overflow
|
||||
//......................................................................
|
||||
case STATE_OVERFLOW: // Flag up a read overflow; Stop the State Machine
|
||||
irparams.overflow = true;
|
||||
irparams.rcvstate = STATE_STOP;
|
||||
break;
|
||||
}
|
||||
|
||||
// If requested, flash LED L (D13) while receiving IR data
|
||||
if (irparams.blinkflag) {
|
||||
if (irdata == MARK) BLINKLED_ON() ; // turn pin 13 LED on
|
||||
else BLINKLED_OFF() ; // turn pin 13 LED off
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user