-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpixoo.py
33 lines (26 loc) · 1.23 KB
/
pixoo.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
from os import getenv
from time import sleep
from PIL import Image
from dotenv import load_dotenv
from modules.time import draw_time
from modules.github import draw_github_contribution
import modules.pixoo_client as pixc
load_dotenv("local.env", verbose=True)
if __name__ == "__main__":
bt_mac_addr = getenv("BT_MAC_ADDR")
tmp_folder = getenv("TEMP_FOLDER")
assert bt_mac_addr is not None, "Did you copy the example.env to local.env?"
assert tmp_folder is not None, "Did you copy the example.env to local.env?"
print(bt_mac_addr)
pixoo = pixc.PixooMax(bt_mac_addr)
pixoo.connect()
while True: # Main loop - here you can change the drawing functions
base = Image.new("RGBA", (32, 32), (0, 0, 0, 0)) # Create a base new image
time_img = draw_time(x_max=32, y_max=32) # Draw the clock
base.alpha_composite(time_img) # Add the clock to the base image
# this draws the github contribution pixel on top of the base image
draw_github_contribution(base, "HoroTW", required_contributions=1)
# workaround for final displaying
base.save(tmp_folder + "tmp.png")
pixoo.draw_pic(tmp_folder + "tmp.png")
sleep(1.0 / 10) # 10 fps are already pretty smooth