forked from manfredipist/homebridge-gpio-rgb-ledstrip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpwmhelper.py
36 lines (25 loc) · 806 Bytes
/
pwmhelper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
import pigpio
if len(sys.argv) < 7:
sys.stderr.write("""usage: pwmhelper.py red_pin blue_pin green_pin red_value blue_value green_value
Example:
pwmhelper.py 17 24 22 0 0 0
""")
sys.exit()
RED_PIN=int(sys.argv[1])
GREEN_PIN=int(sys.argv[2])
BLUE_PIN=int(sys.argv[3])
MAX_RANGE=255
RED_VALUE=int(sys.argv[4])
GREEN_VALUE=int(sys.argv[5])
BLUE_VALUE=int(sys.argv[6])
def set_color(red_intensity, green_intensity, blue_intensity):
pi.set_PWM_dutycycle(RED_PIN, red_intensity);
pi.set_PWM_dutycycle(GREEN_PIN, green_intensity);
pi.set_PWM_dutycycle(BLUE_PIN, blue_intensity);
pi = pigpio.pi();
pi.set_PWM_range(RED_PIN, MAX_RANGE);
pi.set_PWM_range(GREEN_PIN, MAX_RANGE);
pi.set_PWM_range(BLUE_PIN, MAX_RANGE);
set_color(RED_VALUE, GREEN_VALUE, BLUE_VALUE)
pi.stop();