Comments (13)
It's very hard to understand what you are saying.
But I am guessing you are requesting support for using two receivers simultaneously, which is currently not possible.
Unfortunately, there seems to be no "elegant" way to fix this. The problem is that RCSwitch::handleInterrupt
has no way to know for which pin respectively interrupt it was invoked.
Since RCSwitch::handleInterrupt
does not know the source of the interrupt, we cannot use it to pass data to multiple RCSwitch instances.
This is a limitation of the Arduino interrupt handling system, it seems :-/.
from rc-switch.
One hackish workaround: If we arbitrarily limit ourselves to e.g. 6 interrupts, we could provie six "outer" interrupt handlers; then modify attachInterrupt
to use the correct handler for each interrupt. Next, we'd use a small global array to lookup which RCSwitch instance is assigned to which interrupt, and dispatch to that.
But that is still limited in flexibility and somewhat ugly. Hrm.
from rc-switch.
Sorry for my English. Thanks for the answer.
from rc-switch.
Another dirty hack that might work would be switching between both receivers once every second. Of course with the risk of missing some signals, depends on your needs.
void loop() {
mySwitch.enableReceive(0);
delay(1000);
mySwitch.enableReceive(1);
delay(1000);
}
from rc-switch.
sui77 Thank you. But I do not fit this option, you must monitor two frequencies at once. I implemented without interruption. But the accuracy lutshe wants to be, although operational.
from rc-switch.
Still managed to use the hack . delay ( 200 ) and set the tolerable results obtained .
Hedgehog Thanks again sui77.
from rc-switch.
Is there a reason why the class uses static definition? as in RCSwitch::?
I had the same need for 2 receivers and added code for a 2nd detection buffer. I can share the code if it helps, but I thought the best way was to use a non static approach.
from rc-switch.
Thank you , I have long been solved the problem of writing separate code to the second receiver .
22 травня 2016, 12:53:35, від "bilogic" < [email protected] >:
Is there a reason why the class uses static definition? as in RCSwitch::?
I had the same need for 2 receivers and added code for an 2nd detection buffer. I can share the code if it helps, but I thought the best way was to use a non static approach. —
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
from rc-switch.
@bilogic The class uses static definitions because Arduino interrupt handler callbacks sadly only can access static / global data; and interrupt handlers cannot easily be shared for different users. In particular, they have no void *refCon
parameter, which many other callback based APIs offer.
So I am really curious to learn how you bypassed that problem. But please let's not put it onto this old, closed issue; instead, submit a pull request, and/or a new issue where you explain your changes.
from rc-switch.
My level of English is low and I did not understand everything. But answer me more . I used the library on the same frequency , but dorabatival library. I added Oregon and Lacrose. I also added support for long codes for other sensor types. In the future, when I will modify the code I'll post the code . At the time of Danian though workable but not beautiful .
Another receiver potsepil I just interrupt and organized another function but to recognize only one protocol .
I just I measure the duration and analyze the code and decodes it . Though excessively but it works.
23 травня 2016, 10:17:45, від "Max Horn" < [email protected] >:
@bilogic The class uses static definitions because Arduino interrupt handler callbacks sadly only can access static / global data; and interrupt handlers cannot easily be shared for different users. In particular, they have no void *refCon parameter, which many other callback based APIs offer.
So I am really curious to learn how you bypassed that problem. But please let's not put it onto this old, closed issue; instead, submit a pull request, and/or a new issue where you explain your changes.
—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
from rc-switch.
@fingolfin, @MeJIyA my codes and suggestions are on #63
from rc-switch.
hi,
great job...
as another hack ,if you include <PinChangeInt.h> library to RCSwitch.c,
and replace this line in RCSwitch::enableReceive() functon:
attachInterrupt(this->nReceiverInterrupt, handleInterrupt, CHANGE);
with :
attachPinChangeInterrupt(this->nReceiverInterrupt, handleInterrupt, CHANGE);
receive function can be attached to every other pins of board,by adding pin number in enableReceive(pin_number) routin...
useful for nodemcu , esp8266 and etc...
from rc-switch.
I solved this problem by simply duplicating the library with new name "RCSwitch2" and created the second receiver instance with that library. It worked perfectly. So if you are interested in this solution it is just enough to copy the library to another folder with name "RCSwitch2" and replace all "RCSwitch" phrases in the files with "RCSwitch2". This is most easily done by Notepad++ in few clicks.
ATTENTION: Just be careful not to have main library files open in Notepad++ otherwise it would replace instances of the word in those files too.
PS: If this issue is solved by just duplicating the library for the second instance of receiver, it has nothing to do with hardware limitations of handling interrupt pins and it is all about misuse of STATIC variables and definitions:
PS2: Probably the culprits are these three static variables defined in handleInterrupt() method:
from rc-switch.
Related Issues (20)
- can't decode 433mhz with esp32 HOT 5
- Problems with an old library 2013 but with an important modification
- Adding new protocol to RCSwitch.cpp
- Esp32 issue... another one, yes... HOT 1
- How to implement a custom protocol?
- Which pin for Arduino pro mini AtMega328P 5V
- control with more than one command
- Problem with recieved value HOT 1
- How to send()? HOT 1
- How the ISR function handle the filtering out first high pulse in SYNC bit
- void RCSwitch::disableReceive()
- ReceiveDemo_Advanced work with Platform.IO and VSCode HOT 1
- How can i modify this protocol? HOT 5
- Cant receive anything with receive demo HOT 1
- Small contribution
- SURNICE: receiver and transmitter HOT 1
- Protocol 6 optimization doubt
- A modest proposal - expose the interrupt so a user can write a callback function.
- How to add a new protocol for my RF receiver HOT 1
- SimpleRCScanner return error 500
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rc-switch.