07-12-2019, 10:33 PM
(07-12-2019, 08:48 PM)Tim Curtis Wrote: Hi Kent,
Very cool :-) Given that Bluetooth is built into >= 3B it might be worth spending the time to integrate this particular peripheral. What do you think?
Couple of questions:
1) Is the name "flirc" a holdover from your previous script?
2) I don't see the "at" command in stock Buster Lite. Did you apt-get a package that contains it?
- You may be able to use the "eval" command in place of "at now"
3) How does the event loop work?
-Tim
1) yeah. I don't recommend late-night editing! It's just the name I gave to the object instance but I'll fix the script and the How To.
2) oops, I forgot I'd installed the package earlier when I started the Flirc project. Again, I'll fix the How To to include "sudo apt-get install at"
3) The python-evdev module aka package is very cool. From the package docs intro
Quote:This package provides bindings to the generic input event interface in Linux. The evdev interface serves the purpose of passing events generated in the kernel directly to userspace through character devices that are typically located in /dev/input/.
This package also comes with bindings to uinput, the userspace input subsystem. Uinput allows userspace programs to create and handle input devices that can inject events directly into the input subsystem.
The read loop waits for input events generated in the kernel (via /dev/input/---my symlink resolves ultimately to some /dev/input/eventx).
If the type of an event is EV_KEY, then test if it's attribute keystate indicates a keydown event ("1"). If so, match the keycode if possible against one of the values known to the script. If a match is found, use subprocess.run() to call an external program, like mpc, with appropriate arguments. Obviously the sky is the limit here.
Regards,
Kent