66from adafruit_display_text .label import Label
77from adafruit_bitmap_font import bitmap_font
88
9- cwd = ("/" + __file__ ).rsplit ('/' , 1 )[0 ] # the current working directory (where this file is)
9+ # the current working directory (where this file is)
10+ cwd = ("/" + __file__ ).rsplit ("/" , 1 )[0 ]
1011
1112# Fonts within /fonts folder
12- main_font = cwd + "/fonts/EarthHeart-26.bdf"
13- data_font = cwd + "/fonts/Collegiate-50.bdf"
13+ main_font = cwd + "/fonts/EarthHeart-26.bdf"
14+ data_font = cwd + "/fonts/Collegiate-50.bdf"
15+
1416
1517class Azure_GFX (displayio .Group ):
1618 def __init__ (self , is_celsius ):
@@ -34,18 +36,18 @@ def __init__(self, is_celsius):
3436 self ._icon_sprite = None
3537 self ._icon_file = None
3638 self ._cwd = cwd
37- self .set_icon (self ._cwd + "/images/azure_splash.bmp" )
39+ self .set_icon (self ._cwd + "/images/azure_splash.bmp" )
3840
39- print (' loading fonts...' )
40- glyphs = b' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-,.: '
41- data_glyphs = b' 012345678-,.:/FC'
41+ print (" loading fonts..." )
42+ glyphs = b" 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-,.: "
43+ data_glyphs = b" 012345678-,.:/FC"
4244 self .main_font = bitmap_font .load_font (main_font )
4345 self .main_font .load_glyphs (glyphs )
4446 self .data_font = bitmap_font .load_font (data_font )
4547 self .data_font .load_glyphs (data_glyphs )
46- self .data_font .load_glyphs (('°' ,)) # extra glyph for temperature font
48+ self .data_font .load_glyphs (("°" ,)) # extra glyph for temperature font
4749
48- print (' setting up labels...' )
50+ print (" setting up labels..." )
4951 self .title_text = Label (self .main_font , text = "Azure Plant Monitor" )
5052 self .title_text .x = 35
5153 self .title_text .y = 25
@@ -89,7 +91,7 @@ def display_moisture(self, moisture_data):
8991 """Displays the moisture from the Stemma Soil Sensor.
9092 :param int moisture_data: Moisture value
9193 """
92- print (' Moisture Level: ' , moisture_data )
94+ print (" Moisture Level: " , moisture_data )
9395 self .moisture_text .text = str (moisture_data )
9496
9597 def display_temp (self , temp_data ):
@@ -98,22 +100,22 @@ def display_temp(self, temp_data):
98100 """
99101 if not self ._is_celsius :
100102 temp_data = (temp_data * 9 / 5 ) + 32 - 15
101- print (' Temperature: %0.0f°F' % temp_data )
103+ print (" Temperature: %0.0f°F" % temp_data )
102104 if temp_data >= 212 :
103105 self .temp_text .color = 0xFD2EE
104106 elif temp_data <= 32 :
105107 self .temp_text .color = 0xFF0000
106- self .temp_text .text = ' %0.0f°F' % temp_data
107- temp_data = ' %0.0f' % temp_data
108+ self .temp_text .text = " %0.0f°F" % temp_data
109+ temp_data = " %0.0f" % temp_data
108110 return int (temp_data )
109111 else :
110- print (' Temperature: %0.0f°C' % temp_data )
112+ print (" Temperature: %0.0f°C" % temp_data )
111113 if temp_data <= 0 :
112114 self .temp_text .color = 0xFD2EE
113115 elif temp_data >= 100 :
114116 self .temp_text .color = 0xFF0000
115- self .temp_text .text = ' %0.0f°C' % temp_data
116- temp_data = ' %0.0f' % temp_data
117+ self .temp_text .text = " %0.0f°C" % temp_data
118+ temp_data = " %0.0f" % temp_data
117119 return int (temp_data )
118120
119121 def set_icon (self , filename ):
@@ -133,8 +135,9 @@ def set_icon(self, filename):
133135 self ._icon_file .close ()
134136 self ._icon_file = open (filename , "rb" )
135137 icon = displayio .OnDiskBitmap (self ._icon_file )
136- self ._icon_sprite = displayio .TileGrid (icon ,
137- pixel_shader = getattr (icon , 'pixel_shader' , displayio .ColorConverter ()))
138+ self ._icon_sprite = displayio .TileGrid (
139+ icon , pixel_shader = getattr (icon , "pixel_shader" , displayio .ColorConverter ())
140+ )
138141
139142 # CircuitPython 7 compatible
140143 # # Remove self._icon_file - it is no longer used
0 commit comments