16
16
17
17
from adafruit_minimqtt import MQTT
18
18
19
- DISPLAY_COLOR = 0x4444FF
19
+ DISPLAY_COLOR = 0x006600
20
+ SWITCH_COLOR = 0x008800
21
+ SWITCH_FILL_COLOR = 0xffffff
20
22
21
23
# Switch location
22
24
SWITCHX = 260
@@ -87,9 +89,10 @@ class Switch(object):
87
89
def __init__ (self , pin , my_pyportal ):
88
90
self .switch = digitalio .DigitalInOut (pin )
89
91
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 )
91
94
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 )
93
96
my_pyportal .splash .append (self .circle_on )
94
97
self .circle_off = Circle (SWITCHX + 15 , SWITCHY + 42 , 10 , fill = DISPLAY_COLOR )
95
98
my_pyportal .splash .append (self .circle_off )
@@ -99,10 +102,10 @@ def enable(self, enable):
99
102
print ("turning switch to " , enable )
100
103
self .switch .value = enable
101
104
if enable :
102
- self .circle_off .fill = 0x0
105
+ self .circle_off .fill = SWITCH_FILL_COLOR
103
106
self .circle_on .fill = DISPLAY_COLOR
104
107
else :
105
- self .circle_on .fill = 0x0
108
+ self .circle_on .fill = SWITCH_FILL_COLOR
106
109
self .circle_off .fill = DISPLAY_COLOR
107
110
108
111
def toggle (self ):
@@ -127,11 +130,11 @@ def __init__(self, my_pyportal):
127
130
self .pyportal = my_pyportal
128
131
self .current_time = 0
129
132
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 )]
133
136
self .text_areas = create_text_areas (text_area_configs )
134
- self .text_areas [2 ].text = "starting ..."
137
+ self .text_areas [2 ].text = "starting..."
135
138
for ta in self .text_areas :
136
139
self .pyportal .splash .append (ta )
137
140
@@ -229,7 +232,9 @@ def message(client, topic, message):
229
232
print ("Firmware vers." , esp .firmware_version )
230
233
print ("MAC addr:" , [hex (i ) for i in esp .MAC_address ])
231
234
232
- pyportal = PyPortal (esp = esp , external_spi = spi )
235
+ pyportal = PyPortal (esp = esp ,
236
+ external_spi = spi ,
237
+ default_bg = "/background.bmp" )
233
238
234
239
ampm_font = bitmap_font .load_font ("/fonts/RobotoMono-18.bdf" )
235
240
ampm_font .load_glyphs (b'ampAMP' )
0 commit comments