1616
1717from adafruit_minimqtt import MQTT
1818
19- DISPLAY_COLOR = 0x4444FF
19+ DISPLAY_COLOR = 0x006600
20+ SWITCH_COLOR = 0x008800
21+ SWITCH_FILL_COLOR = 0xffffff
2022
2123# Switch location
2224SWITCHX = 260
@@ -87,9 +89,10 @@ class Switch(object):
8789 def __init__ (self , pin , my_pyportal ):
8890 self .switch = digitalio .DigitalInOut (pin )
8991 self .switch .direction = digitalio .Direction .OUTPUT
90- rect = RoundRect (SWITCHX , SWITCHY , 31 , 60 , 16 , fill = 0x0 , outline = DISPLAY_COLOR , stroke = 3 )
92+ rect = RoundRect (SWITCHX , SWITCHY , 31 , 60 , 16 , outline = SWITCH_COLOR ,
93+ fill = SWITCH_FILL_COLOR , stroke = 3 )
9194 my_pyportal .splash .append (rect )
92- self .circle_on = Circle (SWITCHX + 15 , SWITCHY + 16 , 10 , fill = 0x0 )
95+ self .circle_on = Circle (SWITCHX + 15 , SWITCHY + 16 , 10 , fill = SWITCH_FILL_COLOR )
9396 my_pyportal .splash .append (self .circle_on )
9497 self .circle_off = Circle (SWITCHX + 15 , SWITCHY + 42 , 10 , fill = DISPLAY_COLOR )
9598 my_pyportal .splash .append (self .circle_off )
@@ -99,10 +102,10 @@ def enable(self, enable):
99102 print ("turning switch to " , enable )
100103 self .switch .value = enable
101104 if enable :
102- self .circle_off .fill = 0x0
105+ self .circle_off .fill = SWITCH_FILL_COLOR
103106 self .circle_on .fill = DISPLAY_COLOR
104107 else :
105- self .circle_on .fill = 0x0
108+ self .circle_on .fill = SWITCH_FILL_COLOR
106109 self .circle_off .fill = DISPLAY_COLOR
107110
108111 def toggle (self ):
@@ -127,11 +130,11 @@ def __init__(self, my_pyportal):
127130 self .pyportal = my_pyportal
128131 self .current_time = 0
129132 self .light = analogio .AnalogIn (board .LIGHT )
130- text_area_configs = [dict (x = 0 , y = 110 , size = 10 , color = DISPLAY_COLOR , font = time_font ),
131- dict (x = 260 , y = 165 , size = 3 , color = DISPLAY_COLOR , font = ampm_font ),
132- dict (x = 10 , y = 40 , size = 20 , color = DISPLAY_COLOR , font = date_font )]
133+ text_area_configs = [dict (x = 0 , y = 105 , size = 10 , color = DISPLAY_COLOR , font = time_font ),
134+ dict (x = 260 , y = 153 , size = 3 , color = DISPLAY_COLOR , font = ampm_font ),
135+ dict (x = 110 , y = 40 , size = 20 , color = DISPLAY_COLOR , font = date_font )]
133136 self .text_areas = create_text_areas (text_area_configs )
134- self .text_areas [2 ].text = "starting ..."
137+ self .text_areas [2 ].text = "starting..."
135138 for ta in self .text_areas :
136139 self .pyportal .splash .append (ta )
137140
@@ -229,7 +232,9 @@ def message(client, topic, message):
229232 print ("Firmware vers." , esp .firmware_version )
230233 print ("MAC addr:" , [hex (i ) for i in esp .MAC_address ])
231234
232- pyportal = PyPortal (esp = esp , external_spi = spi )
235+ pyportal = PyPortal (esp = esp ,
236+ external_spi = spi ,
237+ default_bg = "/background.bmp" )
233238
234239ampm_font = bitmap_font .load_font ("/fonts/RobotoMono-18.bdf" )
235240ampm_font .load_glyphs (b'ampAMP' )
0 commit comments