Quantcast
Channel: Seeedstudio Forum
Viewing all articles
Browse latest Browse all 6612

Music Shield 2.0. and IRSendRev

$
0
0
Problem solved.
First:

#define IRpin_PIN PIND //add this
#define IRpin 2 //and this in your sketch

Second:

ISR(TIMER_INTR_NAME)
{
//Serial.println(micros());
TIMER_RESET;

//uint8_t irdata = (uint8_t)digitalRead(irparams.recvpin);
uint8_t irdata = (uint8_t)(IRpin_PIN & (1 << IRpin)); //add this string in the IRSendRev.cpp


Third:

ISR(TIMER_INTR_NAME)
{
//Serial.println(micros());
TIMER_RESET;

//uint8_t irdata = (uint8_t)digitalRead(irparams.recvpin);
uint8_t irdata = (uint8_t)(IRpin_PIN & (1 << IRpin));
irparams.timer++; // One more 50us tick
if (irparams.rawlen >= RAWBUF) {
// Buffer overflow
irparams.rcvstate = STATE_STOP;
TIMSK1 = _BV(TOIE1); //add this string in the IRSendRev.cpp
}
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.
irparams.timer = 0;
}
else {
// gap just ended, record duration and start recording transmission
TIMSK1=0; //and this string in the IRSendRev.cpp
irparams.rawlen = 0;
irparams.rawbuf[irparams.rawlen++] = irparams.timer;
irparams.timer = 0;
irparams.rcvstate = STATE_MARK;
}
}
break;

Fourth:

void IRSendRev::Clear() {
irparams.rcvstate = STATE_IDLE;
irparams.rawlen = 0;
TIMSK1 = _BV(TOIE1); //add this string in the IRSendRev.cpp
}

Solution:
When IR start receive data we disable Timer1 interrupt and enable this after transmission is end and decoded. I think we can use cli() and sei() too.

Statistics : Posted by spawn2death • on Tue Sep 09, 2014 2:24 pm • Replies 2 • Views 177

Viewing all articles
Browse latest Browse all 6612

Trending Articles