dBerriff,
Unfortunately, that doesn't work. Since there's only a single PWM object created, the next thread in line can't access it until the current thread is done using it (which makes sense). However, the threads then just act as sequential code, which defeats the purpose of threading.
Unless I'm implementing incorrecting.
I just added the following near the top of the file:
and the following inside the power look:I'm thinking now that the solution is to create a list of PWM objects and iterate through them as needed (appending and popping as I go). I'm just a little confused on how to implement that properly.
-Joe
Unfortunately, that doesn't work. Since there's only a single PWM object created, the next thread in line can't access it until the current thread is done using it (which makes sense). However, the threads then just act as sequential code, which defeats the purpose of threading.
Unless I'm implementing incorrecting.
I just added the following near the top of the file:
Code:
lock = threading.Lock()Code:
def power(device, level, duration): with lock: output = GPIO.PWM(myOuts[device], 1000) output.start(level) sleep(duration) output.stop()-Joe
Statistics: Posted by joebro391 — Thu Mar 27, 2025 1:44 pm