Beispiel #1
0
 def resume(self, resumePosition=False):
     if self._isSuspended:
         self._wave = wavePWM.PWM(PIGPIO_DAEMON)
         self._wave.set_cycle_time(20000)
         self._isSuspended = False
         if resumePosition:
             self.setPosition(self.getPosition())
         else:
             self.setPosition(90)
Beispiel #2
0
 def resume(self, resumeSpeed=False):
     if self._isSuspended:
         self._wave = wavePWM.PWM(PIGPIO_DAEMON)
         self._wave.set_cycle_time(20000)
         self._isSuspended = False
         if resumeSpeed:
             self.setSpeed(self.getSpeed())
         else:
             self.setSpeed(0.0)
Beispiel #3
0
    def __init__(self, pin):
        self._pin = pin

        self._wave = wavePWM.PWM(PIGPIO_DAEMON)
        self._wave.set_cycle_time(3000)

        self._currentPulseWidth = 1500

        self.setSpeed(0.0)
        self._isSuspended = False
Beispiel #4
0
    def __init__(self, stepPin, dirPin):
        self._stepPin = stepPin
        self._dirPin = dirPin

        self._direction = 1
        PIGPIO_DAEMON.write(self._dirPin, self._direction)

        self._wave = wavePWM.PWM(PIGPIO_DAEMON)

        self._isSuspended = False
Beispiel #5
0
 def resume(self, resumeState=False):
     if self._isSuspended:
         self._wave = wavePWM.PWM(PIGPIO_DAEMON)
         self._wave.set_cycle_time(3000)
         self._isSuspended = False
         if resumeState:
             if self._isExtended:
                 self.extend()
             elif not self._isExtended:
                 self.retract()
             else:
                 self.idle()
Beispiel #6
0
    def __init__(self, pin):

        self._pin = pin

        self._TIME0 = 553
        self._TIME180 = 2520

        self._wave = wavePWM.PWM(PIGPIO_DAEMON)

        self._wave.set_cycle_time(4000)

        self._currentPulseWidth = -1

        #self.setPosition(90)
        self._isSuspended = False
Beispiel #7
0
    def __init__(self, pin):
        self._pin = pin

        self._wave = wavePWM.PWM(PIGPIO_DAEMON)

        self._wave.set_cycle_time(1000)
        self._wave.set_pulse_length_in_micros(self._pin, 500)

        self._wave.update()

        self._cycleTime = 1000
        self._frequency = 1000

        self._pulseWidth = 500
        self._dutyCycle = 0.5
Beispiel #8
0
    def __init__(self, pin, invertDirections=False):
        self._pin = pin

        self._wave = wavePWM.PWM(PIGPIO_DAEMON)
        self._wave.set_cycle_time(3000)

        self._currentPulseWidth = 1500

        if invertDirections:
            self._extendValue = 2000
            self._retractValue = 1000
        else:
            self._extendValue = 1000
            self._retractValue = 2000

        self.idle()
        self._isSuspended = False
Beispiel #9
0
def pot_rotate():

    p2_hw = pigpio.pi()
    if not p2_hw.connected:
        exit(0)

    pwm2 = wavePWM.PWM(p2_hw)  # Use default frequency
    pwm2.set_frequency(50)
    pos = 0
    pwm2.set_pulse_start_in_micros(21, pos)
    for i in range(2500, 2000, -1):
        if (i == 2004):
            pwm2.set_pulse_length_in_micros(21, 2500)
            pwm2.update()
            break
        pwm2.set_pulse_length_in_micros(21, i)
        pwm2.update()
    print('b')
Beispiel #10
0
    import time
    import pigpio
    import wavePWM

    GPIO = [5, 6, 7, 8, 9, 10, 11, 12]

    pi = pigpio.pi()

    if not pi.connected:
        exit(0)
    """
   This code demonstrates four different methods of setting
   the pulse start and length.
   """
    pwm = wavePWM.PWM(pi)  # Use default frequency

    try:

        for i in range(1000, 5400, 200):

            if i % 400:
                pwm.set_frequency(i)
            else:
                pwm.set_cycle_time(1000000.0 / i)

            cl = pwm.get_cycle_length()

            # Method 1.
            pwm.set_pulse_start_in_micros(5, cl / 10)
            pwm.set_pulse_length_in_micros(5, cl / 2)
Beispiel #11
0
import time
import board
import busio
import adafruit_am2320
import wavePWM
import pigpio

pi = pigpio.pi()
pwm = wavePWM.PWM(pi)

pwm.set_frequency(1000)
# create the I2C shared bus
i2c = busio.I2C(board.SCL, board.SDA)
am = adafruit_am2320.AM2320(i2c)

while True:
    print("Temperature: ", am.temperature)
    print("Humidity: ", am.relative_humidity)

    if (am.temperature > 30):
        pwm.set_pulse_start_and_length_in_fraction(12, 0, 0.5)
        pwm.set_pulse_start_and_length_in_fraction(16, 0, 0.9)
        pwm.set_pulse_start_and_length_in_fraction(20, 0, 0.9)
        pwm.update()
    else:
        print("stop la dllm")
        pwm.set_pulse_start_and_length_in_fraction(12, 0, 0)
        pwm.set_pulse_start_and_length_in_fraction(16, 0, 0)
        pwm.set_pulse_start_and_length_in_fraction(20, 0, 0)
        pwm.update()
        print("Done")
Beispiel #12
0
 def resume(self):
     self._wave = wavePWM.PWM(PIGPIO_DAEMON)
     self._isSuspended = False
Beispiel #13
0
def servo(q, lock, flag, curtime, count):
    global cup1
    global cup2
    p1_hw = pigpio.pi()

    if not p1_hw.connected:
        exit(0)

    pwm = wavePWM.PWM(p1_hw)  # Use default frequency

    pwm.set_frequency(50)
    pos = 0
    pwm.set_pulse_start_in_micros(16, pos)
    pwm.set_pulse_length_in_micros(21, 0)
    pwm.update()

    for i in range(2500, 500, -6):

        pwm.set_pulse_length_in_micros(16, i)
        pwm.update()
        time.sleep(0.1)
        if q.empty():
            pwm.set_pulse_length_in_micros(16, i - 40)
            pwm.update()
            continue
        m = q.get()
        print(m)
        print('c')

        lock.acquire()

        pwm.set_pulse_start_in_micros(21, 0)

        j = 2500
        jj = 2100 - 50 * count
        count += 1

        while (j >= jj):
            pwm.set_pulse_length_in_micros(21, j)
            pwm.set_pulse_length_in_micros(16, 0)
            pwm.update()
            j = j - 1
        while (j <= 2500):
            pwm.set_pulse_length_in_micros(21, j)
            pwm.set_pulse_length_in_micros(16, 0)
            pwm.update()
            j = j + 1
            time.sleep(0.1)

        pwm.set_pulse_length_in_micros(21, 0)
        pwm.update()
        time.sleep(1)
        print('b')
        print('a')
        i -= 40
        pwm.set_pulse_length_in_micros(16, i)
        pwm.update()
        lock.release()

    for i in range(500, 2500, 5):
        pwm.set_pulse_length_in_micros(16, i)
        pwm.update()
    p1_hw.stop()
Beispiel #14
0
    p1_hw.stop()


if __name__ == '__main__':

    q = Queue(4)
    #q.put(0)
    lock = Lock()
    flag = True
    curtime = 0
    count = 0
    p2_hw = pigpio.pi()
    if not p2_hw.connected:
        exit(0)

    pwm2 = wavePWM.PWM(p2_hw)  # Use default frequency
    pwm2.set_frequency(50)
    pos = 0
    pwm2.set_pulse_start_in_micros(21, pos)
    pwm2.set_pulse_length_in_micros(21, 2500)

    pwm2.update()
    time.sleep(1)
    pwm2.set_pulse_length_in_micros(16, 2500)
    pwm2.update()
    p2_hw.stop()
    time.sleep(15)
    pc = Process(target=camera, args=(q, flag, curtime, count))
    ps = Process(target=servo, args=(q, lock, flag, curtime, count))

    pc.start()
Beispiel #15
0
else:
    shutoffTime = float(shutoffTime)
askWindow.destroy()

colorList = list()
for i in range(len(IONameList)):
    colorList.append(tuple([int(x) for x in np.random.choice(range(100,256),size=3)]))
keyboardTrigList = range(1,IOTypeList.count(0)+1)

for names in IONameList:
    IOTsList.append(list())
    lineHolderList.append(list())
    graphCheckList.append(-1)

GPIO = pigpio.pi()
pwm = wavePWM.PWM(GPIO)

def cbf(g,l,t):
    global graphCheck2,lineHolder2,minTime,startTime,timeLength
    global GPIOList,keyboardTrigList,IOTsList
    
    ind = GPIOList.index(g)
    trueInd = ind+len(keyboardTrigList)
    ts = time.time()-startTime
    realDiv = ts/timeLength
    frac = realDiv-minTime/timeLength
    IOTsList[trueInd].append(ts)
    lineHolderList[trueInd].append(frac)
    if graphCheckList[trueInd] == -1:
        graphCheckList[trueInd] = minTime
outputInd = 0