from __future__ import print_function
import os
from time import sleep
import numpy as np
import pigpio
#import cv2
#from imutils.video.pivideostream import PiVideoStream
#from sys import exit
#from multiprocessing.dummy import Pool
#from timeit import default_timer as timer

os.system('sudo pigpiod')
sleep(1)
PWM_freq=20000
PWM_GPIO = 18
pi = pigpio.pi()

#vs = PiVideoStream(0,(720,720),40)


if __name__ == "__main__":
   pi.hardware_PWM(18,8000,0)
   #pi.set_PWM_frequency(18,8000)
  
   for i in range(0,10001,1):
      pi.hardware_PWM(18,8000,1000000*np.sin(np.pi*i/10000.0))
  #pi.set_PWM_dutycycle(18,255*np.sin(np.pi*i/10000.0))
            
   print("done") 
   #cv2.destroyAllWindows()
   #vs.stop()
   #pi.set_mode(PWM_GPIO,pigpio.INPUT)
   pi.stop()
   #p.close()
   #p.join()
   os.system('sudo killall pigpiod')
   sleep(1)
   print("exit")
    #exit()
   
   


