Skip to content

Commit 7f8be05

Browse files
author
Ruben Jenster
committedAug 12, 2012
Disabled arduino interrupt handling and added missing constants
1 parent be41e13 commit 7f8be05

File tree

3 files changed

+8
-38
lines changed

3 files changed

+8
-38
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.o

‎RCSwitch.cpp

-36
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,13 @@ void RCSwitch::enableReceive() {
445445
if (this->nReceiverInterrupt != -1) {
446446
RCSwitch::nReceivedValue = NULL;
447447
RCSwitch::nReceivedBitlength = NULL;
448-
attachInterrupt(this->nReceiverInterrupt, handleInterrupt, CHANGE);
449448
}
450449
}
451450

452451
/**
453452
* Disable receiving data
454453
*/
455454
void RCSwitch::disableReceive() {
456-
detachInterrupt(this->nReceiverInterrupt);
457455
this->nReceiverInterrupt = -1;
458456
}
459457

@@ -558,40 +556,6 @@ bool RCSwitch::receiveProtocol2(unsigned int changeCount){
558556
}
559557

560558
}
561-
void RCSwitch::handleInterrupt() {
562-
563-
static unsigned int duration;
564-
static unsigned int changeCount;
565-
static unsigned long lastTime;
566-
static unsigned int repeatCount;
567-
568-
569-
long time = micros();
570-
duration = time - lastTime;
571-
572-
if (duration > 5000 && duration > RCSwitch::timings[0] - 200 && duration < RCSwitch::timings[0] + 200) {
573-
repeatCount++;
574-
changeCount--;
575-
if (repeatCount == 2) {
576-
if (receiveProtocol1(changeCount) == false){
577-
if (receiveProtocol2(changeCount) == false){
578-
//failed
579-
}
580-
}
581-
repeatCount = 0;
582-
}
583-
changeCount = 0;
584-
} else if (duration > 5000) {
585-
changeCount = 0;
586-
}
587-
588-
if (changeCount >= RCSWITCH_MAX_CHANGES) {
589-
changeCount = 0;
590-
repeatCount = 0;
591-
}
592-
RCSwitch::timings[changeCount++] = duration;
593-
lastTime = time;
594-
}
595559

596560
/**
597561
* Turns a decimal value to its binary representation

‎RCSwitch.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,21 @@
3030
#else
3131
#include <wiringPi.h>
3232
#include <stdint.h>
33-
#endif
34-
33+
#define NULL 0
34+
#define CHANGE 1
3535
#ifdef __cplusplus
3636
extern "C"{
3737
#endif
3838
typedef uint8_t boolean;
3939
typedef uint8_t byte;
40+
41+
#if !defined(NULL)
42+
#endif
4043
#ifdef __cplusplus
4144
}
4245
#endif
46+
#endif
47+
4348

4449
// Number of maximum High/Low changes per packet.
4550
// We can handle up to (unsigned long) => 32 bit * 2 H/L changes per bit + 2 for sync

0 commit comments

Comments
 (0)
Please sign in to comment.