How should I structure my Python script?
Posted: Tue Apr 25, 2017 5:13 pm
I have two scripts:
> Script A controls an array of LEDs and flashes them in particular patterns within an infinite while loop.
> Script B controls a PC monitor and some buttons. The buttons are on callback interrupts, when they're pressed different images are displayed on the PC monitor.
In addition to the buttons' current function, I also want one of them to start the light pattern, one to stop it and one to change it's colour. What's the best way to structure this in the program?
Option 1: Can I trigger script A from within script B and leave A running independently in the background? Maybe I can pass variables to it to tell A whether to stop/start/change color?
Option 2: Or is it better to integrate A within B and try to integrate all of my code into the infinite while loop that is controlling the lighting?
I don't know how to implement Option 1 or if this is even the best approach. Any advice would be appreciated.
> Script A controls an array of LEDs and flashes them in particular patterns within an infinite while loop.
> Script B controls a PC monitor and some buttons. The buttons are on callback interrupts, when they're pressed different images are displayed on the PC monitor.
In addition to the buttons' current function, I also want one of them to start the light pattern, one to stop it and one to change it's colour. What's the best way to structure this in the program?
Option 1: Can I trigger script A from within script B and leave A running independently in the background? Maybe I can pass variables to it to tell A whether to stop/start/change color?
Option 2: Or is it better to integrate A within B and try to integrate all of my code into the infinite while loop that is controlling the lighting?
I don't know how to implement Option 1 or if this is even the best approach. Any advice would be appreciated.