-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinkyprinter.py
More file actions
35 lines (33 loc) · 1.19 KB
/
inkyprinter.py
File metadata and controls
35 lines (33 loc) · 1.19 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
import inkyphat
from PIL import ImageFont
def inky_print(message):
font = ImageFont.truetype(inkyphat.fonts.AmaticSC, 18)
small_font = ImageFont.truetype(inkyphat.fonts.AmaticSC, 14)
x = 7
y = 7
formatted_message = ""
iterator = 0
words = message.split()
counter = 0
while(iterator<len(words)):
cur_word = words[iterator]
if (counter > 22):
formatted_message += "\n" + cur_word
counter = 0
else:
if cur_word == "==>":
cur_word = "\n" + cur_word
if iterator == 0:
formatted_message += words[iterator]
else:
formatted_message += " " + words[iterator]
counter += len(words[iterator])
iterator += 1
inkyphat.rectangle((0, 0, inkyphat.WIDTH, inkyphat.HEIGHT), fill=inkyphat.RED, outline=inkyphat.RED)
inkyphat.text((x,y), formatted_message, inkyphat.WHITE, font)
copy_right = "Made by Ard"
w, h = small_font.getsize(copy_right)
inkyphat.text((inkyphat.WIDTH-1-w, inkyphat.HEIGHT-1-h), copy_right, inkyphat.WHITE, small_font)
inkyphat.show()
print(formatted_message)
print('Done printing')