(2019-08-08, 08:00 PM)seandepagnier Wrote: I'm not sure about pressing buttons together. I am implementing rf receiver eventually so I will play with it. The raspberry turns out having difficulty decoding these in software, a lot of cpu used and not all packets are decoded. Unless maybe a kernel module could help this.
For now I found an arduino is better to offload this task. This means it would be relatively easy to also make custom remotes with more than 4 buttons, so dodge buttons are possible, and sending different messages for releasing the buttons to make holding them down work better.
Sean
I used to do embedded software a long time ago.
New hardware is much more powerful but with an os to deal with make some options more complicated.
I used to write my own scheduler and interrupt handling as there was no os.
If there was an os it was msdos that is worthless so just took over everything.
I have a few ideas on how to attack it.
Not sure what they have in python.
Hopefully they have ques and semaphores or some sort of multi threading tools in python.
Maybe this will work:
If possible arrange inputs so they are in one byte.
Run an independent process that does the following:
Read inputs.
If necessary pack into one byte and mask unneeded bits.
Store in a que
sleep I'd do .05 seconds as first try ( as long as sleep period is reasonably consistent it should work OK)
Back to beginning
Then in main program read from the que.
Make a simple table with the 16 possibilities.
................. editing a bit
The main loop part is too simplistic :-(
Best to activate a command when all keys return released state.
A 2 key command will likely have the keys pressed and released in arbitrary order.
What matters is seeing 2 keys pressed and activate when all go off.
If an undefined combination of keys are pressed I would just consider it an error state until all keys are released. That will give you a way to abort a command by just pressing another key before releasing.
Will need to keep track of state a little but nothing that complicated.
Can check how long a key is down by how counting how many times it was in the que.
.......................
If you need to debounce need to compare old to new and wait until old=new.
Hopefully that makes sense.
I've never had the best language skills :-(