Skip to content

Commit

Permalink
0742
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjoerd82 committed Jul 16, 2018
1 parent baa48ce commit 78ceb31
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/hu_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def select( self, index, subIndex=None ):
self.__printer('Setting active source to {0}: {1:s}'.format(index,self.lSource[index]['displayname']))
self.iCurrentSource[0] = index
self.iCurrentSource[1] = subIndex
self.source_manager.getPluginByName(self.lSource[index]['name']).plugin_object.on_activate(subIndex)
self.source_manager.getPluginByName(self.lSource[index]['name']).plugin_object.on_activate(subIndex) # TODO! do we want to activate by calling ON-activate????
return True

'''
Expand Down Expand Up @@ -695,7 +695,7 @@ def source_iterator(ix_start, ix_stop, j_start, reverse):
if subsource['available']:
self.iCurrentSource[0] = i
self.iCurrentSource[1] = j
self.source_manager.getPluginByName(self.lSource[i]['name']).plugin_object.on_activate(j)
self.source_manager.getPluginByName(self.lSource[i]['name']).plugin_object.on_activate(j) # TODO! do we want to activate by calling ON-activate????
return self.iCurrentSource
j += 1
i += 1
Expand Down
67 changes: 67 additions & 0 deletions rgb_test_werkt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#defining the RPi's pins as Input / Output
import RPi.GPIO as GPIO

#importing the library for delaying command.
import time

#used for GPIO numbering
GPIO.setmode(GPIO.BCM)

#closing the warnings when you are compiling the code
GPIO.setwarnings(False)

RUNNING = True

#defining the pins
red = 16
green = 12
blue = 23

#defining the pins as output
GPIO.setup(red, GPIO.OUT)
GPIO.setup(green, GPIO.OUT)
GPIO.setup(blue, GPIO.OUT)

#choosing a frequency for pwm
Freq = 100

#defining the pins that are going to be used with PWM
RED = GPIO.PWM(red, Freq)
GREEN = GPIO.PWM(green, Freq)
BLUE = GPIO.PWM(blue, Freq)

try:
#we are starting with the loop
while RUNNING:
#lighting up the pins. 100 means giving 100% to the pin
RED.start(100)
GREEN.start(1)
BLUE.start(1)
#For anode RGB LED users, if you want to start with RED too the only thing to be done is defining RED as one and GREEN and BLUE as 100.

for x in range(1,101):
# for changing the width of PWM, this command is used
GREEN.ChangeDutyCycle(x)
#for anode LED users, just change x with 101-x

# and for delay time.sleep is used. You can chance the duration of the colors with changing the time from here
time.sleep(0.05)

for x in range(1,101):

RED.ChangeDutyCycle(101-x)
time.sleep(0.025)

for x in range(1,101):
GREEN.ChangeDutyCycle(101-x)
BLUE.ChangeDutyCycle(x)
time.sleep(0.025)

for x in range(1,101):
RED.ChangeDutyCycle(x)
time.sleep(0.025)

except KeyboardInterrupt:
# the purpose of this part is, when you interrupt the code, it will stop the while loop and turn off the pins, which means your LED won't light anymore
RUNNING = False
GPIO.cleanup()

0 comments on commit 78ceb31

Please sign in to comment.