More iteration on the shell designs

This commit is contained in:
rmgr 2022-01-31 20:48:40 +10:30
parent 70c0702236
commit cca27534d9
8 changed files with 77 additions and 28 deletions

View File

@ -0,0 +1 @@
2022-01-20 10:30:00 "IT Meeting"

55
apps/calendar.py Normal file
View File

@ -0,0 +1,55 @@
class CalendarAgendaView():
def __init__(self, parent_object):
parent_object.destroy()
self.objects = []
prev_btn_x = 0
prev_btn_y = 0
eventlistpath = "/sd/appdata/calendar/events.txt"
lv_list = lv.list(lv.scr_act())
lv_list.set_size(DEVICE_MAX_WIDTH,DEVICE_MAX_HEIGHT)
lv_list.center()
self.objects.append(lv_list)
print(rtc.datetime())
with open(eventlistpath, "r") as f:
while True:
line = f.readline()
if not line:
break
# print(line)
year_part = int(line[0:4])
month_part = int(line[5:7])
day_part = int(line[8:10])
# print(year_part)
# print(month_part)
# print(day_part)
date1 = (year_part, month_part, day_part)
date2 = rtc.datetime()[0:3]
distance = self.days_between(date1, date2)
print(distance)
if 0 < distance < 7:
#This is a relevant entry
print(line)
btn_temp = self.objects[0].add_btn(None, line[11: len(line)])
# Iterate over /sd/appdata/notes
# for note in notelist:
# btn = lv.btn(lv.scr_act())
# btn.align_to(lv.scr_act(), lv.ALIGN.TOP_LEFT, 0, prev_btn_y)
# btn.add_event_cb(self.note_click, lv.EVENT.CLICKED, None)
# prev_btn_y += 40
# label = lv.label(btn)
# label.set_text(note)
# self.objects.append(btn)
def destroy(self):
for obj in self.objects:
obj.delete()
self.objects.remove(obj)
def days_between(self,d1, d2):
d1 += (1, 0, 0, 0, 0) # ensure a time past midnight
d2 += (1, 0, 0, 0, 0)
return time.mktime(d1) // (24*3600) - time.mktime(d2) // (24*3600)
n = CalendarAgendaView(launcher)

View File

@ -17,34 +17,25 @@ class sync():
time.sleep(1)
print(station.ifconfig())
### MAYBE WE'RE LOSING CONNECTION???
# addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
# s = socket.socket()
# s.bind(addr)
# s.listen(1)
# print("listening on ", addr)
# while True:
# print ('waiting for you uwu')
# cl, addr = s.accept()
# print('client connected from', addr)
# cl_file = cl.makefile('rwb', 0)
# while True:
# line = cl_file.readline()
# if not line or line == b'\r\n':
# break
#rows = ['<tr><td>%s</td><td>%d</td></tr>' % (str(p), p.value()) for p in pins]
# response = html % '\n'.join(rows)
# cl.send('HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n')
# cl.send(response)
# cl.close()
addr_info = socket.getaddrinfo("towel.blinkenlights.nl", 23)
addr = addr_info[0][-1]
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.connect(addr)
s.bind(addr)
s.listen(1)
print("listening on ", addr)
while True:
data = s.recv(500)
print(str(data, 'utf8'), end='')
print ('waiting for you uwu')
cl, addr = s.accept()
print('client connected from', addr)
cl_file = cl.makefile('rwb', 0)
while True:
line = cl_file.readline()
if not line or line == b'\r\n':
break
rows = ['<tr><td>%s</td><td>%d</td></tr>' % (str(p), p.value()) for p in pins]
response = html % '\n'.join(rows)
cl.send('HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n')
cl.send(response)
cl.close()
def destroy(self):
for obj in self.objects:

View File

@ -2,5 +2,5 @@
mount /dev/sdd1 /mnt/sd
cp /home/jake/dev/diy-pda/apps/*.py /mnt/sd/apps/
cp -r /home/jake/dev/diy-pda/appdata/* /mnt/sd/appdata/
#cp -r /home/jake/dev/diy-pda/appdata/* /mnt/sd/appdata/
umount /mnt/sd

BIN
diy-pda-front-shell-4.stl Normal file

Binary file not shown.

BIN
diy-pda-rear-shell-1.stl Normal file

Binary file not shown.

BIN
diy-pda-rear-shell-2.stl Normal file

Binary file not shown.

View File

@ -4,6 +4,8 @@ import os,machine,sdcard
import json
import time
DEVICE_MAX_WIDTH = 240
DEVICE_MAX_HEIGHT = 320
#Initialise hardware
lv.init()
from ili9XXX import ili9341
@ -40,7 +42,7 @@ class Launcher():
self.btn = e.get_target()
label = self.btn.get_child(0)
print("Executing " + label.get_text())
exec(open("/sd/apps/"+ label.get_text()).read(), {'lv':lv, 'launcher': self, 'os':os, 'json':json, 'time':time}, {})
exec(open("/sd/apps/"+ label.get_text()).read(), {'lv':lv, 'launcher': self, 'os':os, 'json':json, 'time':time, 'rtc':rtc, 'DEVICE_MAX_WIDTH':DEVICE_MAX_WIDTH, 'DEVICE_MAX_HEIGHT': DEVICE_MAX_HEIGHT}, {})
def destroy(self):
print("destroying launcher")