Initial commit
This commit is contained in:
commit
b52052a4a8
|
@ -0,0 +1,66 @@
|
|||
#import lvgl as lv
|
||||
#lv.init()
|
||||
|
||||
#from ili9XXX import ili9341
|
||||
#disp = ili9341(dc=21, miso=19, mosi=23, cs=5, clk=18)
|
||||
# Import XPT2046 driver and initalize it
|
||||
#from xpt2046 import xpt2046
|
||||
#touch = xpt2046(cs=27, cal_x0=242, cal_x1=3300)
|
||||
|
||||
|
||||
class NoteList():
|
||||
class NoteEditor():
|
||||
def __init__(self, note=''):
|
||||
# Create a keyboard to use it with one of the text areas
|
||||
kb = lv.keyboard(lv.scr_act())
|
||||
print('creating keyboard')
|
||||
# Create a text area. The keyboard will write here
|
||||
ta = lv.textarea(lv.scr_act())
|
||||
ta.set_width(200)
|
||||
ta.align(lv.ALIGN.TOP_LEFT,0, 0)
|
||||
ta.add_event_cb(lambda e: self.ta_event_cb(e,kb), lv.EVENT.ALL, None)
|
||||
if note != '':
|
||||
ta.set_text(open("/sd/appdata/notes/" + note).read())
|
||||
# launcher.destroy()
|
||||
kb.set_textarea(ta)#
|
||||
lv.scr_load(lv.scr_act())
|
||||
|
||||
def ta_event_cb(self, e, kb):
|
||||
code = e.get_code()
|
||||
ta = e.get_target()
|
||||
if code == lv.EVENT.FOCUSED:
|
||||
kb.set_textarea(ta)
|
||||
kb.clear_flag(lv.obj.FLAG.HIDDEN)
|
||||
if code == lv.EVENT.DEFOCUSED:
|
||||
kb.set_textarea(None)
|
||||
kb.add_flag(lv.obj.FLAG.HIDDEN)
|
||||
|
||||
def __init__(self):
|
||||
self.objects = []
|
||||
prev_btn_x = 0
|
||||
prev_btn_y = 0
|
||||
notelist = os.listdir("/sd/appdata/notes")
|
||||
# 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)
|
||||
|
||||
# launcher.destroy()
|
||||
# foreach item, add button to screen with width = screen_width and background = white
|
||||
# onclick button open editor and load note
|
||||
def destroy(self):
|
||||
for obj in self.objects:
|
||||
obj.delete()
|
||||
|
||||
def note_click(self, e):
|
||||
btn = e.get_target()
|
||||
label = btn.get_child(0)
|
||||
print("/sd/appdata/notes/" + label.get_text())
|
||||
n = self.NoteEditor(note=label.get_text())
|
||||
self.destroy()
|
||||
n = NoteList()
|
|
@ -0,0 +1,32 @@
|
|||
#import lvgl as lv
|
||||
|
||||
#lv.init()
|
||||
|
||||
#from ili9XXX import ili9341
|
||||
#disp = ili9341(dc=21, miso=19, mosi=23, cs=5, clk=18)
|
||||
# Import XPT2046 driver and initalize it
|
||||
#from xpt2046 import xpt2046
|
||||
#touch = xpt2046(cs=27, cal_x0=242, cal_x1=3300)
|
||||
|
||||
def ta_event_cb(e,kb):
|
||||
code = e.get_code()
|
||||
ta = e.get_target()
|
||||
if code == lv.EVENT.FOCUSED:
|
||||
kb.set_textarea(ta)
|
||||
kb.clear_flag(lv.obj.FLAG.HIDDEN)
|
||||
|
||||
if code == lv.EVENT.DEFOCUSED:
|
||||
kb.set_textarea(None)
|
||||
kb.add_flag(lv.obj.FLAG.HIDDEN)
|
||||
|
||||
# Create a keyboard to use it with one of the text areas
|
||||
kb = lv.keyboard(lv.scr_act())
|
||||
print('creating keyboard')
|
||||
# Create a text area. The keyboard will write here
|
||||
ta = lv.textarea(lv.scr_act())
|
||||
ta.set_width(200)
|
||||
ta.align(lv.ALIGN.TOP_RIGHT, -10, 10)
|
||||
ta.add_event_cb(lambda e: ta_event_cb(e,kb), lv.EVENT.ALL, None)
|
||||
|
||||
kb.set_textarea(ta)#
|
||||
lv.scr_load(lv.scr_act())
|
|
@ -0,0 +1,6 @@
|
|||
# This file is executed on every boot (including wake-boot from deepsleep)
|
||||
#import esp
|
||||
#esp.osdebug(None)
|
||||
#import webrepl
|
||||
#webrepl.start()
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# DIY PDA Specs
|
||||
|
||||
## Hardware
|
||||
* ESP-WROOM-32 dev board
|
||||
* Generic Arduino-Compatible SD card slot
|
||||
* ILI9341 3.2" touchscreen LCD
|
||||
|
||||
## Software
|
||||
* LVGL's Micropython fork https://github.com/lvgl/lv_micropython
|
||||
|
||||
## Architecture
|
||||
It is assumed that all software is stored on the sd card under /sd/apps. All user/app data is stored in /sd/appdata/[appname].
|
||||
|
||||
Applications are executed by reading the file and feeding it to Python's exec function. All screens should be defined as a class and implement a destroy() function which clears the screen. (The easiest way to do so is to create an array of LVGL objects in __init__() and then just iterate over that object calling obj.delete() for each. Each __init__ function should take a parameter called caller which references the previous screen for disposal.
|
||||
|
||||
Time is kept using the ESP32's on-board RTC. I may look at utilising a dedicated RTC module at some stage but for now the ESP32 will do. Power-wise I intend to use something along the lines of an Adafruit Powerboost 1000c LiPo circuit to handle charging and powering and what-have-you.
|
||||
|
||||
At the moment the project exists on a breadboard and it ain't pretty. I think if I do some aggressive wiring, I should be able to condense everything down to the footprint of the screen which should make for a nice enough PDA footprint. Then I'll need to design and 3D print a shell for it. (Which I have never done so that should be interesting)
|
|
@ -0,0 +1,10 @@
|
|||
import time
|
||||
def see():
|
||||
print("good")
|
||||
time.sleep(65)
|
||||
|
||||
def ya():
|
||||
print("bye")
|
||||
|
||||
see()
|
||||
ya()
|
|
@ -0,0 +1,53 @@
|
|||
import lvgl as lv
|
||||
import espidf as esp
|
||||
import os,machine,sdcard
|
||||
lv.init()
|
||||
# Import ILI9341 driver and initialized it
|
||||
|
||||
#import os,machine
|
||||
#rtc = machine.RTC()
|
||||
#rtc.datetime((2021, 8, 23, 1, 12, 48, 0, 0))
|
||||
#os.mount(machine.SDCard(),"/sd")
|
||||
|
||||
|
||||
#apps = ""
|
||||
#applist = os.listdir("/sd/apps")
|
||||
from ili9XXX import ili9341
|
||||
disp = ili9341(dc=21, miso=19, mosi=23, cs=5, clk=18)
|
||||
# Import XPT2046 driver and initalize it
|
||||
from xpt2046 import xpt2046
|
||||
touch = xpt2046(cs=27, cal_x0=242, cal_x1=3300, cal_y0=3850, cal_y1=423)
|
||||
# Load the screen
|
||||
|
||||
sd = sdcard.SDCard(machine.SoftSPI(sck=machine.Pin(13),miso=machine.Pin(14),mosi=machine.Pin(15)), machine.Pin(25))
|
||||
os.mount(sd,'/sd')
|
||||
|
||||
class Launcher():
|
||||
def __init__(self):
|
||||
self.objects = []
|
||||
apps = ""
|
||||
applist = os.listdir("/sd/apps")
|
||||
print(applist[0]);
|
||||
prev_btn_y = 0
|
||||
scr = lv.scr_act()
|
||||
for app in applist:
|
||||
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.event_cb, lv.EVENT.CLICKED, None)
|
||||
prev_btn_y += 40
|
||||
label = lv.label(btn)
|
||||
label.set_text(app)
|
||||
self.objects.append(btn)
|
||||
def event_cb(self, e):
|
||||
self.btn = e.get_target()
|
||||
label = self.btn.get_child(0)
|
||||
print(label.get_text())
|
||||
# exec('print("ashf")',{}, {'lv':lv})
|
||||
exec(open("/sd/apps/"+ label.get_text()).read(), {'lv':lv, 'launcher': self, 'os':os, }, {})
|
||||
|
||||
def destroy(self):
|
||||
print("destroying launcher")
|
||||
for obj in self.objects:
|
||||
obj.delete()
|
||||
launcher = Launcher()
|
||||
#lv.scr_load(scr)
|
|
@ -0,0 +1,22 @@
|
|||
import os,machine,sdcard
|
||||
rtc = machine.RTC()
|
||||
rtc.datetime((2021, 8, 23, 1, 12, 48, 0, 0))
|
||||
#pin12= machine.Pin(12)
|
||||
#pin12.value(1)
|
||||
pins = [27,14,12,13]
|
||||
for pin in pins:
|
||||
machine.Pin(pin).init(-1, machine.Pin.PULL_UP)
|
||||
#os.mount(machine.SDCard(slot=3,sck=13, miso=14, mosi=15, cs=25),"/sd")
|
||||
sd = sdcard.SDCard(machine.SoftSPI(sck=machine.Pin(13),miso=machine.Pin(14),mosi=machine.Pin(15)), machine.Pin(25))
|
||||
os.mount(sd,'/sd')
|
||||
apps = ""
|
||||
applist = os.listdir("/sd")
|
||||
print(applist)
|
||||
#
|
||||
#for i in range(0, len(applist)):
|
||||
# apps += str(i) + " - " + applist[i] + "\n"
|
||||
#apps = apps[0:len(apps)-1]
|
||||
#print(rtc.datetime())
|
||||
#choice = input('Select an app to execute\n' + apps + "\n")
|
||||
#exec(open("/sd/apps/" + applist[int(choice)]).read())
|
||||
#print(rtc.datetime())
|
Loading…
Reference in New Issue