initial commit

This commit is contained in:
zoe 2022-09-13 18:56:35 +02:00
commit 65122b9a53
49 changed files with 3203 additions and 0 deletions

3039
PICO-8ROMMono.bdf Normal file

File diff suppressed because it is too large Load Diff

2
boot_out.txt Normal file
View File

@ -0,0 +1,2 @@
Adafruit CircuitPython 7.2.0 on 2022-02-24; Adafruit Matrix Portal M4 with samd51j19
Board ID:matrixportal_m4

154
code.py Normal file
View File

@ -0,0 +1,154 @@
from adafruit_display_text.label import Label
import time
import gc
import board
import displayio
import random
from adafruit_bitmap_font import bitmap_font
from adafruit_matrixportal.network import Network
from adafruit_matrixportal.matrix import Matrix
import adafruit_requests as requests
# statics
SPEED = 6 # should be even
COLORS = [
0x50FA7B,
0xffb86c,
0xf1fa8c,
0xff5555,
0xff79c6,
0x8be9fd,
]
FONT = bitmap_font.load_font("/PICO-8ROMMono.bdf")
def random_color():
return random.choice(COLORS)
# Get wifi details and more from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
network = Network(debug=False, status_neopixel=board.NEOPIXEL,)
matrix = Matrix()
display = matrix.display
upper_text_content = "jacking"
upper_text = Label(
FONT,
text=upper_text_content,
color=random_color(),
)
upper_text.y = 6
middle_text_content = " in"
middle_text = Label(
FONT,
text=middle_text_content,
color=random_color(),
)
middle_text.y = 17
lower_text_content = "=^_^="
lower_text = Label(
FONT,
text=lower_text_content,
color=random_color(),
)
lower_text.y = 28
g = displayio.Group()
g.append(upper_text)
g.append(middle_text)
g.append(lower_text)
display.show(g)
daynames = {
0: "monday",
1: "tuesday",
2: "wednesday",
3: "thursday",
4: "friday",
5: "saturday",
6: "sunday",
}
def sliceForTextField(s, i, max_chars=8) -> str:
if len(s) < max_chars:
return s
return str(s[i % len(s):] + " " + s[: i % len(s)])[:max_chars]
def update_content():
global middle_text_content, upper_text_content
try:
# set time from network
network.get_local_time()
except RuntimeError as e:
print("failed loading time")
try:
# get unread rss feeds
print("loading rss feeds")
headers = {"X-Auth-Token": secrets["miniflux_token"]}
rssresponse = requests.get(secrets["miniflux_url"] + "/entries?status=unread&direction=desc", headers=headers,)
entries = rssresponse.json()["entries"]
rssresponse.close()
upper_text_content = str(len(entries)) + " unread entries"
for e in entries:
gc.collect()
upper_text_content += " | " + e["feed"]["title"]
upper_text_content += "-" + e["title"]
gc.collect()
except RuntimeError as e:
print("failed loading unread")
gc.collect()
try:
weatherresponse = requests.get("https://wttr.in/?format='%l:+%C+%t+%w+%h+humidty'")
middle_text_content = weatherresponse.text.replace("\n", " ").replace("'", "")
weatherresponse.close()
except RuntimeError as e:
print("failed getting weather")
def update_time():
global lower_text_content
now = time.localtime()
lower_text_content = "{dayname} {day}.{month}.{year} {hours}:{minutes}:{seconds}".format(
hours=now[3],
minutes=now[4],
seconds=now[5],
dayname=daynames[now[6]],
day=now[2],
month=now[1],
year=now[0],
)
def update(tick):
# do this once about every hour
if tick % (360 * SPEED) == 0:
update_content()
# do this every second
if tick % SPEED == 0:
update_time()
upper_text.color = random_color()
middle_text.color = random_color()
lower_text.color = random_color()
lower_text.text = sliceForTextField(
lower_text_content,
tick,
)
middle_text.text = sliceForTextField(
middle_text_content,
tick,
)
upper_text.text = sliceForTextField(
upper_text_content,
tick,
)
network.connect()
i = 0
while True:
update(i)
time.sleep(1 / SPEED)
i += 1

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

BIN
lib/adafruit_lis3dh.mpy Normal file

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/adafruit_requests.mpy Normal file

Binary file not shown.

BIN
lib/asyncio/__init__.mpy Normal file

Binary file not shown.

BIN
lib/asyncio/core.mpy Normal file

Binary file not shown.

BIN
lib/asyncio/event.mpy Normal file

Binary file not shown.

BIN
lib/asyncio/funcs.mpy Normal file

Binary file not shown.

BIN
lib/asyncio/lock.mpy Normal file

Binary file not shown.

BIN
lib/asyncio/manifest.mpy Normal file

Binary file not shown.

BIN
lib/asyncio/stream.mpy Normal file

Binary file not shown.

BIN
lib/asyncio/task.mpy Normal file

Binary file not shown.

BIN
lib/neopixel.mpy Normal file

Binary file not shown.

8
secrets.py Normal file
View File

@ -0,0 +1,8 @@
secrets = {
"ssid": "ssid",
"password": "hunter2",
"aio_username": "bugfan23",
"aio_key": "aio_kesmashsdkfjsdkljfkdsjfkldsj",
"miniflux_token": "kdfjgkdfkgjdfklgjkfdj1",
"miniflux_url": "https://rss.example.com/v1/",
}