Skip to content

Commit 3207d3e

Browse files
committed
Added kelvinstops.py to generate qlinegradient style stops, added background colors to hue, temperature, and brightness sliders
1 parent 15748bd commit 3207d3e

8 files changed

+323
-13
lines changed

Diff for: RGBDimmer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class RGBDimmerController():
44
MIN_TEMPERATURE = 1000
55
MAX_TEMPERATURE = 12000
66
MIN_HUE = 0
7-
MAX_HUE = 259
7+
MAX_HUE = 359
88
MIN_BRIGHTNESS = 0
99
MAX_BRIGHTNESS = 255
1010

Diff for: __pycache__/RGBDimmer.cpython-39.pyc

0 Bytes
Binary file not shown.

Diff for: __pycache__/myutils.cpython-39.pyc

375 Bytes
Binary file not shown.

Diff for: __pycache__/serialhelper.cpython-39.pyc

-43 Bytes
Binary file not shown.

Diff for: kelvinstops.py

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
from myutils import rgb_to_hex
2+
3+
kelvin_table = {
4+
1000: (255, 56, 0),
5+
1100: (255, 71, 0),
6+
1200: (255, 83, 0),
7+
1300: (255, 93, 0),
8+
1400: (255, 101, 0),
9+
1500: (255, 109, 0),
10+
1600: (255, 115, 0),
11+
1700: (255, 121, 0),
12+
1800: (255, 126, 0),
13+
1900: (255, 131, 0),
14+
2000: (255, 138, 18),
15+
2100: (255, 142, 33),
16+
2200: (255, 147, 44),
17+
2300: (255, 152, 54),
18+
2400: (255, 157, 63),
19+
2500: (255, 161, 72),
20+
2600: (255, 165, 79),
21+
2700: (255, 169, 87),
22+
2800: (255, 173, 94),
23+
2900: (255, 177, 101),
24+
3000: (255, 180, 107),
25+
3100: (255, 184, 114),
26+
3200: (255, 187, 120),
27+
3300: (255, 190, 126),
28+
3400: (255, 193, 132),
29+
3500: (255, 196, 137),
30+
3600: (255, 199, 143),
31+
3700: (255, 201, 148),
32+
3800: (255, 204, 153),
33+
3900: (255, 206, 159),
34+
4000: (255, 209, 163),
35+
4100: (255, 211, 168),
36+
4200: (255, 213, 173),
37+
4300: (255, 215, 177),
38+
4400: (255, 217, 182),
39+
4500: (255, 219, 186),
40+
4600: (255, 221, 190),
41+
4700: (255, 223, 194),
42+
4800: (255, 225, 198),
43+
4900: (255, 227, 202),
44+
5000: (255, 228, 206),
45+
5100: (255, 230, 210),
46+
5200: (255, 232, 213),
47+
5300: (255, 233, 217),
48+
5400: (255, 235, 220),
49+
5500: (255, 236, 224),
50+
5600: (255, 238, 227),
51+
5700: (255, 239, 230),
52+
5800: (255, 240, 233),
53+
5900: (255, 242, 236),
54+
6000: (255, 243, 239),
55+
6100: (255, 244, 242),
56+
6200: (255, 245, 245),
57+
6300: (255, 246, 247),
58+
6400: (255, 248, 251),
59+
6500: (255, 249, 253),
60+
6600: (254, 249, 255),
61+
6700: (252, 247, 255),
62+
6800: (249, 246, 255),
63+
6900: (247, 245, 255),
64+
7000: (245, 243, 255),
65+
7100: (243, 242, 255),
66+
7200: (240, 241, 255),
67+
7300: (239, 240, 255),
68+
7400: (237, 239, 255),
69+
7500: (235, 238, 255),
70+
7600: (233, 237, 255),
71+
7700: (231, 236, 255),
72+
7800: (230, 235, 255),
73+
7900: (228, 234, 255),
74+
8000: (227, 233, 255),
75+
8100: (225, 232, 255),
76+
8200: (224, 231, 255),
77+
8300: (222, 230, 255),
78+
8400: (221, 230, 255),
79+
8500: (220, 229, 255),
80+
8600: (218, 229, 255),
81+
8700: (217, 227, 255),
82+
8800: (216, 227, 255),
83+
8900: (215, 226, 255),
84+
9000: (214, 225, 255),
85+
9100: (212, 225, 255),
86+
9200: (211, 224, 255),
87+
9300: (210, 223, 255),
88+
9400: (209, 223, 255),
89+
9500: (208, 222, 255),
90+
9600: (207, 221, 255),
91+
9700: (207, 221, 255),
92+
9800: (206, 220, 255),
93+
9900: (205, 220, 255),
94+
10000: (207, 218, 255),
95+
10100: (207, 218, 255),
96+
10200: (206, 217, 255),
97+
10300: (205, 217, 255),
98+
10400: (204, 216, 255),
99+
10500: (204, 216, 255),
100+
10600: (203, 215, 255),
101+
10700: (202, 215, 255),
102+
10800: (202, 214, 255),
103+
10900: (201, 214, 255),
104+
11000: (200, 213, 255),
105+
11100: (200, 213, 255),
106+
11200: (199, 212, 255),
107+
11300: (198, 212, 255),
108+
11400: (198, 212, 255),
109+
11500: (197, 211, 255),
110+
11600: (197, 211, 255),
111+
11700: (197, 210, 255),
112+
11800: (196, 210, 255),
113+
11900: (195, 210, 255),
114+
12000: (195, 209, 255)}
115+
116+
117+
118+
def print_stops(temps):
119+
120+
keys = kelvin_table.keys()
121+
for t in temps:
122+
if t in keys:
123+
print("stop: {:1.3f} {}".format((float(t)-1000.0)/11000.0,rgb_to_hex(kelvin_table[t])))
124+
125+
def print_all():
126+
keys = kelvin_table.keys()
127+
for k in keys:
128+
print(f"Temperature {k}, rgb {kelvin_table[k]} hex {rgb_to_hex(kelvin_table[k])} stop {(float(k)-1000.0)/11000.0}")
129+
130+
if __name__ == '__main__':
131+
# print_all()
132+
133+
print("Stops")
134+
temps = range(1000,12500,500)
135+
print_stops(temps)
136+
137+

Diff for: myutils.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
import threading
22
import random
33

4+
def rgb_to_hex(rgb,maximize = False):
5+
6+
7+
if maximize:
8+
9+
# print(f"before maximize : {rgb}")
10+
m = float(max(rgb))
11+
if m > 0:
12+
m = 255.0/m
13+
# print(f"max is {m}")
14+
r = (int(rgb[0]*m),int(rgb[1]*m),int(rgb[2]*m))
15+
# print(f"r is {r}")
16+
17+
# print(f"After maximize : {r}")
18+
return '#%02x%02x%02x' % r
19+
return '#%02x%02x%02x' % rgb
20+
421
def createRandomRGB(maxC = 255):
522
o = (random.randint(0,maxC),random.randint(0,maxC),random.randint(0,maxC))
623
return o

0 commit comments

Comments
 (0)