15
15
from adafruit_display_shapes .rect import Rect
16
16
from adafruit_display_shapes .circle import Circle
17
17
from adafruit_display_shapes .triangle import Triangle
18
+ from adafruit_bitmap_font import bitmap_font
18
19
from adafruit_displayio_layout .layouts .tab_layout import TabLayout
19
20
20
21
# +-------------------------------------------------------+
@@ -49,6 +50,7 @@ def __init__(self):
49
50
18 : "use_txt_in_month" ,
50
51
19 : "use_usa_notation" ,
51
52
20 : "content_sensor_idx" ,
53
+ 21 : "temp_in_fahrenheit" ,
52
54
}
53
55
54
56
self .gVars_rDict = {
@@ -73,6 +75,7 @@ def __init__(self):
73
75
"use_txt_in_month" : 18 ,
74
76
"use_usa_notation" : 19 ,
75
77
"content_sensor_idx" : 20 ,
78
+ "temp_in_fahrenheit" : 21 ,
76
79
}
77
80
78
81
self .g_vars = {}
@@ -127,6 +130,7 @@ def clean(self):
127
130
18 : None ,
128
131
19 : None ,
129
132
20 : None ,
133
+ 21 : None ,
130
134
}
131
135
132
136
def list (self ):
@@ -203,6 +207,7 @@ def list(self):
203
207
myVars .write ("use_usa_notation" , True )
204
208
myVars .write ("use_ntp" , False )
205
209
myVars .write ("content_sensor_idx" , None )
210
+ myVars .write ("temp_in_fahrenheit" , True )
206
211
# -------------------------------------------------------------------------
207
212
if myVars .read ("my_debug" ):
208
213
# print list of all variables in myVars
@@ -221,15 +226,16 @@ def list(self):
221
226
display .show (main_group )
222
227
223
228
# fon.gvars bitmap_font.load_font("fonts/Helvetica-Bold-16.bdf")
224
- font = terminalio .FONT
229
+ font_arial = bitmap_font .load_font ("/fonts/Arial-16.bdf" )
230
+ font_term = terminalio .FONT
225
231
226
232
# create the page layout
227
233
test_page_layout = TabLayout (
228
234
x = 0 ,
229
235
y = 0 ,
230
236
display = board .DISPLAY ,
231
237
tab_text_scale = 2 ,
232
- custom_font = font ,
238
+ custom_font = font_term ,
233
239
inactive_tab_spritesheet = "bmps/inactive_tab_sprite.bmp" ,
234
240
showing_tab_spritesheet = "bmps/active_tab_sprite.bmp" ,
235
241
showing_tab_text_color = 0x00AA59 ,
@@ -247,63 +253,63 @@ def list(self):
247
253
248
254
# labels
249
255
pge1_lbl = Label (
250
- font = terminalio . FONT ,
256
+ font = font_term ,
251
257
scale = 2 ,
252
258
text = "This is the first page!" ,
253
259
anchor_point = (0 , 0 ),
254
260
anchored_position = (10 , 10 ),
255
261
)
256
262
pge1_lbl2 = Label (
257
- font = terminalio . FONT ,
263
+ font = font_term ,
258
264
scale = 2 ,
259
265
text = "Please wait..." ,
260
266
anchor_point = (0 , 0 ),
261
267
anchored_position = (10 , 150 ),
262
268
)
263
269
pge2_lbl = Label (
264
- font = terminalio . FONT ,
270
+ font = font_term ,
265
271
scale = 2 ,
266
272
text = "This page is the second page!" ,
267
273
anchor_point = (0 , 0 ),
268
274
anchored_position = (10 , 10 ),
269
275
)
270
276
pge3_lbl = Label (
271
- font = terminalio . FONT ,
277
+ font = font_term ,
272
278
scale = 2 ,
273
279
text = myVars .read ("pge3_lbl_dflt" ), # Will be "Date/time:"
274
280
anchor_point = (0 , 0 ),
275
281
anchored_position = (10 , 10 ),
276
282
)
277
283
pge3_lbl2 = Label (
278
- font = terminalio . FONT ,
284
+ font = font_term ,
279
285
scale = 2 ,
280
286
text = "" , # pge3_lbl2_dflt, # Will be DD-MO-YYYY or Month-DD-YYYY
281
287
anchor_point = (0 , 0 ),
282
288
anchored_position = (10 , 40 ),
283
289
)
284
290
pge3_lbl3 = Label (
285
- font = terminalio . FONT ,
291
+ font = font_term ,
286
292
scale = 2 ,
287
293
text = "" , # pge3_lbl3_dflt, # Will be HH:MM:SS
288
294
anchor_point = (0 , 0 ),
289
295
anchored_position = (10 , 70 ),
290
296
)
291
297
pge4_lbl = Label (
292
- font = terminalio . FONT ,
298
+ font = font_term ,
293
299
scale = 2 ,
294
300
text = myVars .read ("pge4_lbl_dflt" ),
295
301
anchor_point = (0 , 0 ),
296
302
anchored_position = (10 , 10 ),
297
303
)
298
304
pge4_lbl2 = Label (
299
- font = terminalio . FONT ,
305
+ font = font_term ,
300
306
scale = 2 ,
301
307
text = "" , # Will be "Temperature"
302
308
anchor_point = (0 , 0 ),
303
309
anchored_position = (10 , 130 ),
304
310
)
305
311
pge4_lbl3 = Label (
306
- font = terminalio . FONT ,
312
+ font = font_arial ,
307
313
scale = 2 ,
308
314
text = "" , # Will be "xx.yy C"
309
315
anchor_point = (0 , 0 ),
@@ -405,7 +411,11 @@ def connect_temp_sensor():
405
411
print (t )
406
412
print ("temperature sensor connected" )
407
413
myVars .write ("t0" , "Temperature" )
408
- myVars .write ("t1" , " C" )
414
+ if myVars .read ("temp_in_fahrenheit" ):
415
+ myVars .write ("t1" , chr (186 ) + "F" )
416
+ else :
417
+ myVars .write ("t1" , chr (186 ) + "C" )
418
+
409
419
myVars .write ("t2" , 27 * "_" )
410
420
else :
411
421
print ("no " + t )
@@ -460,6 +470,8 @@ def get_temp():
460
470
if myVars .read ("temp_sensor" ) is not None :
461
471
try :
462
472
temp = myVars .read ("temp_sensor" ).temperature
473
+ if myVars .read ("temp_in_fahrenheit" ):
474
+ temp = (temp * 1.8 ) + 32
463
475
t = "{:5.2f} " .format (temp ) + myVars .read ("t1" )
464
476
if (
465
477
myVars .read ("my_debug" )
0 commit comments