import pigpio
from time import sleep
import cv2
freq=10
dt=950
gpio=23

def nothing(*x):
    pass
cv2.namedWindow('led_steuerung',cv2.WINDOW_NORMAL)
cv2.createTrackbar('duty','led_steuerung',1000,4000,nothing)
cv2.createTrackbar('freq','led_steuerung',1000,8000,nothing)
gp=pigpio.pi()
gp.set_mode(gpio,pigpio.OUTPUT)
gp.set_PWM_range(gpio,4000)
olddt=dt
oldf=freq
while cv2.waitKey(10)!=ord('q')&0xFF:
    
    freq=cv2.getTrackbarPos('freq','led_steuerung')
    dt=cv2.getTrackbarPos('duty','led_steuerung')
    if olddt!=dt:
        gp.set_PWM_dutycycle(gpio, dt)
        olddt=dt
    if oldf!=freq:
        gp.set_PWM_frequency(gpio, freq)
        oldf=freq


gp.set_mode(gpio,pigpio.INPUT)
cv2.destroyAllWindows()
