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,9 @@ 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 , fill = SWITCH_FILL_COLOR , stroke = 3 )
91
93
my_pyportal .splash .append (rect )
92
- self .circle_on = Circle (SWITCHX + 15 , SWITCHY + 16 , 10 , fill = 0x0 )
94
+ self .circle_on = Circle (SWITCHX + 15 , SWITCHY + 16 , 10 , fill = SWITCH_FILL_COLOR )
93
95
my_pyportal .splash .append (self .circle_on )
94
96
self .circle_off = Circle (SWITCHX + 15 , SWITCHY + 42 , 10 , fill = DISPLAY_COLOR )
95
97
my_pyportal .splash .append (self .circle_off )
@@ -99,10 +101,10 @@ def enable(self, enable):
99
101
print ("turning switch to " , enable )
100
102
self .switch .value = enable
101
103
if enable :
102
- self .circle_off .fill = 0x0
104
+ self .circle_off .fill = SWITCH_FILL_COLOR
103
105
self .circle_on .fill = DISPLAY_COLOR
104
106
else :
105
- self .circle_on .fill = 0x0
107
+ self .circle_on .fill = SWITCH_FILL_COLOR
106
108
self .circle_off .fill = DISPLAY_COLOR
107
109
108
110
def toggle (self ):
@@ -127,11 +129,11 @@ def __init__(self, my_pyportal):
127
129
self .pyportal = my_pyportal
128
130
self .current_time = 0
129
131
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 )]
132
+ text_area_configs = [dict (x = 0 , y = 105 , size = 10 , color = DISPLAY_COLOR , font = time_font ),
133
+ dict (x = 260 , y = 153 , size = 3 , color = DISPLAY_COLOR , font = ampm_font ),
134
+ dict (x = 110 , y = 40 , size = 20 , color = DISPLAY_COLOR , font = date_font )]
133
135
self .text_areas = create_text_areas (text_area_configs )
134
- self .text_areas [2 ].text = "starting ..."
136
+ self .text_areas [2 ].text = "starting..."
135
137
for ta in self .text_areas :
136
138
self .pyportal .splash .append (ta )
137
139
@@ -226,7 +228,9 @@ def message(client, topic, message):
226
228
print ("Firmware vers." , esp .firmware_version )
227
229
print ("MAC addr:" , [hex (i ) for i in esp .MAC_address ])
228
230
229
- pyportal = PyPortal (esp = esp , external_spi = spi )
231
+ pyportal = PyPortal (esp = esp ,
232
+ external_spi = spi ,
233
+ default_bg = "/background.bmp" )
230
234
231
235
ampm_font = bitmap_font .load_font ("/fonts/RobotoMono-18.bdf" )
232
236
ampm_font .load_glyphs (b'ampAMP' )
0 commit comments