-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathambilight.py
51 lines (39 loc) · 1.23 KB
/
ambilight.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import config as configuration
import ScreenPixel as SP
import Arduino as AR
import json
import requests
from time import sleep
if __name__ == '__main__':
m = 254
conf = configuration.config()
sp = SP.ScreenPixel(
top = conf.top,
right = conf.right,
bottom = conf.bottom,
left = conf.left,
height = conf.height,
width = conf.width,
offsetTop = conf.offsetTop,
offsetRight = conf.offsetRight,
offsetBottom = conf.offsetBottom,
offsetLeft = conf.offsetLeft,
step = conf.step
)
ar = AR.Arduino()
old_data = ''
while 1:
brightness = 100
"""max(sp.getBrightness(), 44)"""
data = sp.getColors()
colors = sp.normalizeSides(data)
data = chr(255) + chr(min(m, brightness))
"""data += chr(max(1, sp.getBrightness()))"""
for color in colors:
for channel in color:
data += chr(min(m, channel))
"""data += chr(max(m, color[0])) + chr(max(m, color[1])) + chr(max(m, color[2]))"""
if not old_data==data:
ar.sendPacket(data)
old_data = data
sleep(0.05)