3131https = requests .Session (socket , ssl .create_default_context ())
3232
3333# Paste your API token below
34- TOKEN = "YOUR_API_TOKEN"
35-
34+ # TOKEN = "YOUR_API_TOKEN"
35+ TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYwYTdlYmZiZjk2N2U2MDAxNzNmNWY0MCIsImlhdCI6MTYzMzM2NzM5NiwiZXhwIjoxNjQyMDA3Mzk2fQ.vJsMVR_b8QMl7APrqoEFNPXIq-jeLKXB8yUeQPIDK_o" # pylint: disable=line-too-long
3636def font_width_to_dict (font ):
3737 # Reads the font file to determine how wide each character is
3838 # Used to avoid bad wrapping breaking the QR code
@@ -155,16 +155,16 @@ def wrap(text, max_width, max_lines, font):
155155
156156# Add the two text fields
157157magtag .add_text (
158- text_font = "fonts/Arial-12.bdf" ,
159- text_position = (5 , - 2 ),
158+ text_font = "fonts/Arial-Bold- 12.bdf" ,
159+ text_position = (5 , 0 ),
160160 text_scale = 1 ,
161- line_spacing = 0.6 ,
161+ line_spacing = 0.7 ,
162162 text_anchor_point = (0 , 0 ),
163163)
164164
165165magtag .add_text (
166166 text_font = "fonts/ArialMT-9.bdf" ,
167- text_position = (5 , 30 ),
167+ text_position = (5 , 38 ),
168168 text_scale = 1 ,
169169 line_spacing = 0.6 ,
170170 text_anchor_point = (0 , 0 ),
@@ -175,13 +175,13 @@ def wrap(text, max_width, max_lines, font):
175175magtag .graphics .qrcode (url , qr_size = 4 , x = 173 , y = 3 )
176176
177177# Prepare to wrap the text correctly by getting the width of each character for every font
178- arial_12 = font_width_to_dict ("fonts/Arial-12.bdf" )
178+ arial_12 = font_width_to_dict ("fonts/Arial-Bold- 12.bdf" )
179179arial_9 = font_width_to_dict ("fonts/ArialMT-9.bdf" )
180180
181181# Set the text. On some characters, this fails. If so, run the whole file again in 5 seconds
182182try :
183- magtag .set_text (wrap (selected ["projectName" ], 530 , 2 , arial_12 ), 0 , False )
184- magtag .set_text (wrap (selected ["projectDescription" ], 530 , 10 , arial_9 ), 1 )
183+ magtag .set_text (wrap (selected ["projectName" ], 545 , 2 , arial_12 ), 0 , False )
184+ magtag .set_text (wrap (selected ["projectDescription" ], 530 , 19 , arial_9 ), 1 )
185185 magtag .exit_and_deep_sleep (3600 )
186186except Exception : # pylint: disable=broad-except
187187 print ("Could not set title or description: unsupported glyphs." )
0 commit comments