diff --git a/appdata/calendar/events.txt b/appdata/calendar/events.txt new file mode 100644 index 0000000..ff86998 --- /dev/null +++ b/appdata/calendar/events.txt @@ -0,0 +1 @@ +2022-01-20 10:30:00 "IT Meeting" diff --git a/apps/calendar.py b/apps/calendar.py new file mode 100644 index 0000000..85d22f1 --- /dev/null +++ b/apps/calendar.py @@ -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) diff --git a/apps/sync.py b/apps/sync.py index 0822a31..7b19de6 100644 --- a/apps/sync.py +++ b/apps/sync.py @@ -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 = ['%s%d' % (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 = ['%s%d' % (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: diff --git a/copy_apps.sh b/copy_apps.sh index 595a4be..974a9ac 100755 --- a/copy_apps.sh +++ b/copy_apps.sh @@ -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 diff --git a/diy-pda-front-shell-4.stl b/diy-pda-front-shell-4.stl new file mode 100644 index 0000000..5bd5513 Binary files /dev/null and b/diy-pda-front-shell-4.stl differ diff --git a/diy-pda-rear-shell-1.stl b/diy-pda-rear-shell-1.stl new file mode 100644 index 0000000..2b438e5 Binary files /dev/null and b/diy-pda-rear-shell-1.stl differ diff --git a/diy-pda-rear-shell-2.stl b/diy-pda-rear-shell-2.stl new file mode 100644 index 0000000..1243ece Binary files /dev/null and b/diy-pda-rear-shell-2.stl differ diff --git a/main.py b/main.py index 64aad6b..b8e0d36 100755 --- a/main.py +++ b/main.py @@ -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")