Skip to content

Commit 63421a0

Browse files
committed
Explained timezone field in secrets.py
1 parent 30807b4 commit 63421a0

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

PyPortal_Smart_Switch/code.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
from 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
2224
SWITCHX = 260
@@ -87,9 +89,9 @@ 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, fill=SWITCH_FILL_COLOR, stroke=3)
9193
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)
9395
my_pyportal.splash.append(self.circle_on)
9496
self.circle_off = Circle(SWITCHX + 15, SWITCHY + 42, 10, fill=DISPLAY_COLOR)
9597
my_pyportal.splash.append(self.circle_off)
@@ -99,10 +101,10 @@ def enable(self, enable):
99101
print("turning switch to ", enable)
100102
self.switch.value = enable
101103
if enable:
102-
self.circle_off.fill = 0x0
104+
self.circle_off.fill = SWITCH_FILL_COLOR
103105
self.circle_on.fill = DISPLAY_COLOR
104106
else:
105-
self.circle_on.fill = 0x0
107+
self.circle_on.fill = SWITCH_FILL_COLOR
106108
self.circle_off.fill = DISPLAY_COLOR
107109

108110
def toggle(self):
@@ -127,11 +129,11 @@ def __init__(self, my_pyportal):
127129
self.pyportal = my_pyportal
128130
self.current_time = 0
129131
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)]
133135
self.text_areas = create_text_areas(text_area_configs)
134-
self.text_areas[2].text = "starting ..."
136+
self.text_areas[2].text = "starting..."
135137
for ta in self.text_areas:
136138
self.pyportal.splash.append(ta)
137139

@@ -226,7 +228,9 @@ def message(client, topic, message):
226228
print("Firmware vers.", esp.firmware_version)
227229
print("MAC addr:", [hex(i) for i in esp.MAC_address])
228230

229-
pyportal = PyPortal(esp=esp, external_spi=spi)
231+
pyportal = PyPortal(esp=esp,
232+
external_spi=spi,
233+
default_bg="/background.bmp")
230234

231235
ampm_font = bitmap_font.load_font("/fonts/RobotoMono-18.bdf")
232236
ampm_font.load_glyphs(b'ampAMP')

PyPortal_Smart_Switch/secrets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
secrets = {
55
'ssid' : 'CHANGE ME',
66
'password' : 'CHANGE ME',
7-
'timezone' : 'CHANGE ME',
7+
# leave blank or use timezone from # http://worldtimeapi.org/timezones
8+
'timezone' : '',
89
'aio_username' : 'CHANGE ME',
910
'aio_key' : 'CHANGE ME',
1011
}

0 commit comments

Comments
 (0)