def init_PWM(_redPin = 23, _greenPin = 24, _bluePin = 25, _flashPin= 22, initDutyCycle = [100]*3, flashRate = 0): global colorPins, colors, flashActive, flashPin colorPins = [_redPin, _greenPin, _bluePin] #list for pins used in raspberry pi wiringpi2.wiringPiSetup() # Initialize using wiringPi pin numbering scheme for dc in initDutyCycle: #Check for valid initial duty cycle if dc < 0 or dc > 255: return -1 #Create intial PWM signals for input to LED strip for i in range(3): wiringpi2.softPwmCreate(colorPins[i], int(initDutyCycle[i]*100.0/255.0), 100) #Current RGB values of LED strip colors = list(initDutyCycle) #Create square wave for flashing beat flashPin = _flashPin wiringpi2.softToneCreate(flashPin) if flashRate != 0: wiringpi2.softToneWrite(flashPin, flashRate) flashActive = True else: wiringpi2.softToneStop(flashPin) flashActive = False #Use Colors.txt file to create list of preset color options readColorsFile() return 0
def setBPM(flashRate): global flashActive if flashRate != 0: if not flashActive: wiringpi2.softToneCreate(flashPin) flashActive = True wiringpi2.softToneWrite(flashPin, flashRate) else: if flashActive: wiringpi2.softToneStop(flashPin) flashActive = False