Skip to content

Commit e294aa4

Browse files
author
Alvaro Figueroa
committed
Cosmetic changes, setting delay to off-testing mode (30s), erased large font
1 parent 284d41a commit e294aa4

File tree

4 files changed

+18
-6048
lines changed

4 files changed

+18
-6048
lines changed

PyPortal_Electioncal_US/code.py renamed to PyPortal_Electioncal_US/electioncal.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@
66
sys.path.append(cwd)
77
import electioncal_graphics # pylint: disable=wrong-import-position
88

9-
# Optional, to take a screenshot to SD card
10-
#from adafruit_bitmapsaver import save_pixels
11-
#import storage
12-
#import busio
13-
149
# Get wifi details and more from a secrets.py file
1510
try:
1611
from secrets import secrets
1712
except ImportError:
1813
print("WiFi secrets are kept in secrets.py, please add them there!")
1914
raise
2015

21-
#STATE="puerto_rico"
22-
#COUNTY="aguada"
23-
STATE="texas"
24-
COUNTY="andrews"
16+
# Change this to your state and county, replacing spaces for underscores and in lowercase
17+
STATE="new_york"
18+
COUNTY="new_york"
2519

2620
DATA_SOURCE = "https://electioncal.us/en/" + STATE +"/" + COUNTY + "/voter.json"
2721
DATA_LOCATION = []
@@ -58,12 +52,4 @@
5852
gfx.elections_cycle()
5953
except RuntimeError as e:
6054
print("Some error ocurred, retrying! -", e)
61-
continue
62-
63-
# Optional: to take screenshot to SD card
64-
#storage.remount("/", False)
65-
#print('Taking Screenshot...')
66-
#save_pixels('/screenshot.bmp')
67-
#print('Screenshot taken')
68-
69-
#time.sleep(60) # wait 60 seconds before updating anything again
55+
continue

PyPortal_Electioncal_US/electioncal_graphics.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,47 @@ def __init__(self, root_group, *, am_pm=True):
2929
self.small_font.load_glyphs(glyphs)
3030
self.medium_font.load_glyphs(glyphs)
3131

32+
self.date_text = Label(self.small_font, max_glyphs=21)
33+
self.date_text.x = 15
34+
self.date_text.y = 195
35+
self.date_text.color = 0xFFFFFF
36+
self._text_group.append(self.date_text)
37+
3238
self.url_text = Label(self.small_font, max_glyphs=35)
33-
self.url_text.x = 10
34-
self.url_text.y = 195
39+
self.url_text.x = 15
40+
self.url_text.y = 220
3541
self.url_text.color = 0xFFFFFF
3642
self._text_group.append(self.url_text)
3743
self.url_text.text = "Visit us at https://electioncal.us"
3844

39-
self.date_text = Label(self.small_font, max_glyphs=21)
40-
self.date_text.x = 10
41-
self.date_text.y = 220
42-
self.date_text.color = 0xFFFFFF
43-
self._text_group.append(self.date_text)
44-
4545
self.state_text = Label(self.small_font, max_glyphs=60)
46-
self.state_text.x = 10
46+
self.state_text.x = 15
4747
self.state_text.y = 10
4848
self.state_text.color = 0xFFFFFF
4949
self._text_group.append(self.state_text)
5050

5151
self.election_date_text = Label(self.medium_font, max_glyphs=11)
52-
self.election_date_text.x = 10
52+
self.election_date_text.x = 15
5353
self.election_date_text.y = 60
5454
self.election_date_text.color = 0xFFFFFF
5555
self._text_group.append(self.election_date_text)
5656

5757
self.election_name_text = Label(self.small_font, max_glyphs=60)
58-
self.election_name_text.x = 10
58+
self.election_name_text.x = 15
5959
self.election_name_text.y = 95
6060
self.election_name_text.color = 0xFFFFFF
6161
self._text_group.append(self.election_name_text)
6262

6363
self.election_name_text_line2 = Label(self.small_font, max_glyphs=60)
64-
self.election_name_text_line2.x = 10
64+
self.election_name_text_line2.x = 15
6565
self.election_name_text_line2.y = 120
6666
self.election_name_text_line2.color = 0xFFFFFF
6767
self._text_group.append(self.election_name_text_line2)
6868

6969

7070
def load_data(self, election_data):
7171
self.electioncal = json.loads(election_data)
72-
self.state_text.text = self.electioncal["dates"][0]["state"] + " State, " + self.electioncal["dates"][1]["county"]
72+
self.state_text.text = self.electioncal["dates"][1]["county"] + ", " + self.electioncal["dates"][0]["state"]
7373

7474
def elections_cycle(self):
7575
self.update_time()
@@ -80,7 +80,7 @@ def elections_cycle(self):
8080
self.election_date_text.text = self.electioncal["dates"][i]["date"]
8181
# splitting the line at around 40 chars seems ok for regular PyPortal
8282
self.election_name_text_line2.text, self.election_name_text.text = self.paragrapher(self.electioncal["dates"][i]["name"], 40)
83-
time.sleep(4)
83+
time.sleep(30)
8484

8585
def update_time(self):
8686
"""Fetch the time.localtime(), parse it out and update the display text"""

0 commit comments

Comments
 (0)