forked from derkalle4/python3-idotmatrix-library
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathexample.py
More file actions
100 lines (83 loc) · 2.41 KB
/
Copy pathexample.py
File metadata and controls
100 lines (83 loc) · 2.41 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import asyncio
import logging
import time
from idotmatrix.client import IDotMatrixClient
from idotmatrix.modules.clock import ClockStyle
from idotmatrix.screensize import ScreenSize
# set basic logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s :: %(levelname)s :: %(name)s :: %(message)s",
datefmt="%d.%m.%Y %H:%M:%S",
handlers=[logging.StreamHandler()],
)
# set log level of bleak
logging.getLogger("bleak").setLevel(logging.WARNING)
async def main():
client = IDotMatrixClient(
screen_size=ScreenSize.SIZE_64x64, # or use ScreenSize.SIZE_32x32 or ScreenSize.SIZE_16x16
# mac_address="00:11:22:33:44:55", # (optional) specify your device's Bluetooth address
)
# if mac_address is provided, this is optional.
# if not, the first discovered device will be connected to.
await client.connect()
# Chronograph
await client.chronograph.reset()
time.sleep(5)
await client.chronograph.start_from_zero()
time.sleep(5)
# Clock
await client.clock.show(ClockStyle.RGBSwipeOutline)
time.sleep(5)
# Common
await client.common.set_screen_flipped(True)
time.sleep(5)
await client.common.set_screen_flipped(False)
# Countdown
await client.countdown.start(minutes=10)
time.sleep(5)
# FullscreenColor
await client.color.show_color("yellow")
time.sleep(5)
# GIF
await client.gif.upload_gif_file(
file_path="./images/demo.gif",
)
time.sleep(5)
# Graffiti
await client.graffiti.set_pixel(
color=(255, 255, 255),
xy=(10, 10),
)
await client.graffiti.set_pixels(
color=(128, 192, 255),
xys=[(x, y) for y in range(20, 30) for x in range(20, 30)]
)
time.sleep(5)
# Image
await client.image.set_mode()
await client.image.upload_image_file(
file_path="./images/demo_512.png",
palletize=True,
)
time.sleep(5)
# Scoreboard
await client.scoreboard.show(10, 5)
time.sleep(5)
# Text
await client.text.show_text(
text="HELLO WORLD",
font_path="./fonts/Rain-DRM3.otf",
)
time.sleep(5)
# Effect
await client.effect.show(
style=1,
colors=[(255, 0, 0), (255, 162, 0), (255, 255, 0), (0, 255, 0), (0, 0, 255), (255, 0, 255)]
)
time.sleep(5)
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
quit()