LibreELEC menu rotary control

  • So I'm working on controlling the menu with a ky-040 rotary controller and a few buttons, new to python I somehow hacked this code together that allows me to scroll up and down and click select.

    The code is brute forced together and I know it could be optimized, it also has a bug where if you turn the knob too quickly after clicking it fires the select event twice. Being new to Python I'm struggling to understand how "print" the os.system "ssh function thingy" into the "while True:" part, ha I have alot to learn about python. But I think that may make it run smoother. So far its interesting and this encoder working is pretty sweet, but im not sure how optimized this is and how it will effect the pi's cpu etc. Next I need to figure out how to make different events fire on long presses and convert this to a volume control, but I'm making progress, any help on how to fix the double firing of events on rapid wheel changes after click or how to improve this would be appreciated.

    The only real part of this code I had to figure out was this

    os.system("kodi-send --action='Up'")

    But I still dont really understand the whole import kodi stuff or where that comes from...

    Edited once, last by mnrdsgn (May 29, 2019 at 8:44 PM).