Skip to content

Commit b68c9cb

Browse files
committed
Added tests for text API
1 parent 9c2a03e commit b68c9cb

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

tests/test_text_api.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import asyncio
2+
from frameutils import Bluetooth
3+
4+
5+
async def main():
6+
b = Bluetooth()
7+
8+
await b.connect(print_response_handler=lambda s: print(s))
9+
10+
# Print text in all the corners
11+
await b.send_lua("frame.display.text('Test', 1, 1)")
12+
await b.send_lua("frame.display.text('Test', 563, 1)")
13+
await b.send_lua("frame.display.text('Test', 1, 352)")
14+
await b.send_lua("frame.display.text('Test', 563, 352)")
15+
await b.send_lua("frame.display.show()")
16+
await asyncio.sleep(2.00)
17+
18+
# Test UTF-8 characters
19+
await b.send_lua("frame.display.text('ÄÖÅ', 50, 50)")
20+
await b.send_lua("frame.display.show()")
21+
await asyncio.sleep(2.00)
22+
23+
# Test spacing
24+
await b.send_lua("frame.display.text('Test', 50, 50, { spacing = 0})")
25+
await b.send_lua("frame.display.text('Test', 50, 100, { spacing = 2})")
26+
await b.send_lua("frame.display.text('Test', 50, 150, { spacing = 4})")
27+
await b.send_lua("frame.display.text('Test', 50, 200, { spacing = 10})")
28+
await b.send_lua("frame.display.text('Test', 50, 250, { spacing = 25})")
29+
await b.send_lua("frame.display.show()")
30+
await asyncio.sleep(2.00)
31+
32+
# Print all colors
33+
await b.send_lua("frame.display.text('WHITE', 1, 1, { color = 'WHITE' })")
34+
await b.send_lua("frame.display.text('GREY', 1, 50, { color = 'GREY' })")
35+
await b.send_lua("frame.display.text('RED', 1, 100, { color = 'RED' })")
36+
await b.send_lua("frame.display.text('PINK', 1, 150, { color = 'PINK' })")
37+
await b.send_lua("frame.display.text('DARKBROWN', 1, 200, { color = 'DARKBROWN' })")
38+
await b.send_lua("frame.display.text('BROWN', 1, 250, { color = 'BROWN' })")
39+
await b.send_lua("frame.display.text('ORANGE', 1, 300, { color = 'ORANGE' })")
40+
await b.send_lua("frame.display.text('YELLOW', 1, 350, { color = 'YELLOW' })")
41+
await b.send_lua("frame.display.text('DARKGREEN', 320, 1, { color = 'DARKGREEN' })")
42+
await b.send_lua("frame.display.text('GREEN', 320, 50, { color = 'GREEN' })")
43+
await b.send_lua(
44+
"frame.display.text('LIGHTGREEN', 320, 100, { color = 'LIGHTGREEN' })"
45+
)
46+
await b.send_lua(
47+
"frame.display.text('NIGHTBLUE', 320, 150, { color = 'NIGHTBLUE' })"
48+
)
49+
await b.send_lua("frame.display.text('SEABLUE', 320, 200, { color = 'SEABLUE' })")
50+
await b.send_lua("frame.display.text('SKYBLUE', 320, 250, { color = 'SKYBLUE' })")
51+
await b.send_lua(
52+
"frame.display.text('CLOUDBLUE', 320, 300, { color = 'CLOUDBLUE' })"
53+
)
54+
await b.send_lua("frame.display.show()")
55+
await asyncio.sleep(2.00)
56+
57+
# Change colors
58+
await b.send_lua("frame.display.assign_color_ycbcr('CLOUDBLUE', 15, 4, 4)")
59+
await b.send_lua("frame.display.assign_color_ycbcr('WHITE', 7, 4, 4)")
60+
await b.send_lua("frame.display.assign_color_ycbcr('GREY', 5, 3, 6)")
61+
await b.send_lua("frame.display.assign_color_ycbcr('RED', 9, 3, 5)")
62+
await b.send_lua("frame.display.assign_color_ycbcr('PINK', 2, 2, 5)")
63+
await b.send_lua("frame.display.assign_color_ycbcr('DARKBROWN', 4, 2, 5)")
64+
await b.send_lua("frame.display.assign_color_ycbcr('BROWN', 9, 2, 5)")
65+
await b.send_lua("frame.display.assign_color_ycbcr('ORANGE', 13, 2, 4)")
66+
await b.send_lua("frame.display.assign_color_ycbcr('YELLOW', 4, 4, 3)")
67+
await b.send_lua("frame.display.assign_color_ycbcr('DARKGREEN', 6, 2, 3)")
68+
await b.send_lua("frame.display.assign_color_ycbcr('GREEN', 10, 1, 3)")
69+
await b.send_lua("frame.display.assign_color_ycbcr('LIGHTGREEN', 1, 5, 2)")
70+
await b.send_lua("frame.display.assign_color_ycbcr('NIGHTBLUE', 4, 5, 2)")
71+
await b.send_lua("frame.display.assign_color_ycbcr('SEABLUE', 8, 5, 2)")
72+
await b.send_lua("frame.display.assign_color_ycbcr('SKYBLUE', 13, 4, 3)")
73+
await asyncio.sleep(5.00)
74+
75+
# Change them back
76+
await b.send_lua("frame.display.assign_color_ycbcr('WHITE', 15, 4, 4)")
77+
await b.send_lua("frame.display.assign_color_ycbcr('GREY', 7, 4, 4)")
78+
await b.send_lua("frame.display.assign_color_ycbcr('RED', 5, 3, 6)")
79+
await b.send_lua("frame.display.assign_color_ycbcr('PINK', 9, 3, 5)")
80+
await b.send_lua("frame.display.assign_color_ycbcr('DARKBROWN', 2, 2, 5)")
81+
await b.send_lua("frame.display.assign_color_ycbcr('BROWN', 4, 2, 5)")
82+
await b.send_lua("frame.display.assign_color_ycbcr('ORANGE', 9, 2, 5)")
83+
await b.send_lua("frame.display.assign_color_ycbcr('YELLOW', 13, 2, 4)")
84+
await b.send_lua("frame.display.assign_color_ycbcr('DARKGREEN', 4, 4, 3)")
85+
await b.send_lua("frame.display.assign_color_ycbcr('GREEN', 6, 2, 3)")
86+
await b.send_lua("frame.display.assign_color_ycbcr('LIGHTGREEN', 10, 1, 3)")
87+
await b.send_lua("frame.display.assign_color_ycbcr('NIGHTBLUE', 1, 5, 2)")
88+
await b.send_lua("frame.display.assign_color_ycbcr('SEABLUE', 4, 5, 2)")
89+
await b.send_lua("frame.display.assign_color_ycbcr('SKYBLUE', 8, 5, 2)")
90+
await b.send_lua("frame.display.assign_color_ycbcr('CLOUDBLUE', 13, 4, 3)")
91+
92+
await b.disconnect()
93+
94+
95+
asyncio.run(main())

0 commit comments

Comments
 (0)