def __init__(self): # init LVGL lv.init() # TFT and TS driver # POTENTIAL: move into LaserMcu self._tft = tftwing.TFTFeatherWing(tft_mhz=24) self._tft.init() # Register display buffer, driver and input device driver self._register_disp_drv() self._register_indev_drv() th = lv.theme_night_init(210, lv.font_roboto_16) lv.theme_set_current(th) blank_scr = lv.obj() lv.scr_load(blank_scr) # MCU Control self.mcu = laser_mcu.LaserMCU() # Laser Measuring Control self.laser = laser_ctrl.LaserCtrl() self.laser.off() # Load Time # TODO: also move into LaserMcu try: self.mcu.set_time_ntp() except OSError as err: print("OSError: {0}".format(err)) self.mcu.load_time() self.mcu.set_creation_time() # Create screen self._load_screen() # Register Tasks self._register_tasks() # Create lock for panel wait process self._lock = _thread.allocate_lock() return
def init_styles(dark=True): if dark: # Set theme th = lv.theme_night_init(210, lv.font_roboto_22) # adjusting theme # background color cbg = lv.color_hex(0x192432) # ctxt = lv.color_hex(0x7f8fa4) ctxt = lv.color_hex(0xFFFFFF) cbtnrel = lv.color_hex(0x506072) cbtnpr = lv.color_hex(0x405062) chl = lv.color_hex(0x313E50) else: # Set theme to light # TODO: work in progress... th = lv.theme_material_init(210, lv.font_roboto_22) # adjusting theme # background color cbg = lv.color_hex(0xEEEEEE) # ctxt = lv.color_hex(0x7f8fa4) ctxt = lv.color_hex(0) cbtnrel = lv.color_hex(0x506072) cbtnpr = lv.color_hex(0x405062) chl = lv.color_hex(0x313E50) th.style.label.sec.text.color = cbtnrel th.style.scr.body.main_color = cbg th.style.scr.body.grad_color = cbg # text color th.style.scr.text.color = ctxt # buttons # btn released th.style.btn.rel.body.main_color = cbtnrel th.style.btn.rel.body.grad_color = cbtnrel th.style.btn.rel.body.shadow.width = 0 th.style.btn.rel.body.border.width = 0 th.style.btn.rel.body.radius = 10 # btn pressed lv.style_copy(th.style.btn.pr, th.style.btn.rel) th.style.btn.pr.body.main_color = cbtnpr th.style.btn.pr.body.grad_color = cbtnpr # button map released th.style.btnm.btn.rel.body.main_color = cbg th.style.btnm.btn.rel.body.grad_color = cbg th.style.btnm.btn.rel.body.radius = 0 th.style.btnm.btn.rel.body.border.width = 0 th.style.btnm.btn.rel.body.shadow.width = 0 th.style.btnm.btn.rel.text.color = ctxt # button map pressed lv.style_copy(th.style.btnm.btn.pr, th.style.btnm.btn.rel) th.style.btnm.btn.pr.body.main_color = chl th.style.btnm.btn.pr.body.grad_color = chl # button map toggled lv.style_copy(th.style.btnm.btn.tgl_pr, th.style.btnm.btn.pr) lv.style_copy(th.style.btnm.btn.tgl_rel, th.style.btnm.btn.pr) # button map inactive lv.style_copy(th.style.btnm.btn.ina, th.style.btnm.btn.rel) th.style.btnm.btn.ina.text.opa = 80 # button map background th.style.btnm.bg.body.opa = 0 th.style.btnm.bg.body.border.width = 0 th.style.btnm.bg.body.shadow.width = 0 # textarea th.style.ta.oneline.body.opa = 0 th.style.ta.oneline.body.border.width = 0 th.style.ta.oneline.text.font = lv.font_roboto_28 th.style.ta.oneline.text.color = ctxt # slider th.style.slider.knob.body.main_color = cbtnrel th.style.slider.knob.body.grad_color = cbtnrel th.style.slider.knob.body.radius = 5 th.style.slider.knob.body.border.width = 0 # page th.style.page.bg.body.opa = 0 th.style.page.scrl.body.opa = 0 th.style.page.bg.body.border.width = 0 th.style.page.bg.body.padding.left = 0 th.style.page.bg.body.padding.right = 0 th.style.page.bg.body.padding.top = 0 th.style.page.bg.body.padding.bottom = 0 th.style.page.scrl.body.border.width = 0 th.style.page.scrl.body.padding.left = 0 th.style.page.scrl.body.padding.right = 0 th.style.page.scrl.body.padding.top = 0 th.style.page.scrl.body.padding.bottom = 0 lv.theme_set_current(th) styles["theme"] = th # Title style - just a default style with larger font styles["title"] = lv.style_t() lv.style_copy(styles["title"], th.style.label.prim) styles["title"].text.font = lv.font_roboto_28 styles["title"].text.color = ctxt styles["hint"] = lv.style_t() lv.style_copy(styles["hint"], th.style.label.sec) styles["hint"].text.font = lv.font_roboto_16 styles["small"] = lv.style_t() lv.style_copy(styles["small"], styles["hint"]) styles["small"].text.color = ctxt
import lvgl as lv import lib.screen.widgets as w import lib.screen.icons as i import lib.game.game as g import time as t import gc NIGHT_THEME = lv.theme_night_init(210, lv.font_roboto_16) DEFAULT_THEME = lv.theme_default_init(210, lv.font_roboto_16) MATERIAL_THEME = lv.theme_material_init(210, lv.font_roboto_16) DISP_SCALE = 4 SCR_Y = 32 SCR_X = 40 class App(): def __init__(self, name, display, buttons, timer, **kwargs): gc.collect() self.disp = display self.buttons = buttons self.tim = timer # self.theme = th self.group = lv.group_create() # lv.theme_set_current(self.theme) self.scr = lv.obj() self.name = name self.items = {} self.item_ids = {} self.cont = w.Container(self.scr) self.set_buttons(
def init_styles(): # Set theme th = lv.theme_night_init(210, lv.font_roboto_22) # adjusting theme # background color cbg = lv.color_hex(0x192432) th.style.scr.body.main_color = cbg th.style.scr.body.grad_color = cbg # text color # ctxt = lv.color_hex(0x7f8fa4) ctxt = lv.color_hex(0xffffff) th.style.scr.text.color = ctxt # buttons cbtnrel = lv.color_hex(0x506072) cbtnpr = lv.color_hex(0x405062) # btn released th.style.btn.rel.body.main_color = cbtnrel th.style.btn.rel.body.grad_color = cbtnrel th.style.btn.rel.body.shadow.width = 0 th.style.btn.rel.body.border.width = 0 th.style.btn.rel.body.radius = 10 # btn pressed lv.style_copy(th.style.btn.pr, th.style.btn.rel) th.style.btn.pr.body.main_color = cbtnpr th.style.btn.pr.body.grad_color = cbtnpr # button map released th.style.btnm.btn.rel.body.main_color = cbg th.style.btnm.btn.rel.body.grad_color = cbg th.style.btnm.btn.rel.body.radius = 0 th.style.btnm.btn.rel.body.border.width = 0 th.style.btnm.btn.rel.body.shadow.width = 0 # button map pressed chl = lv.color_hex(0x313E50) lv.style_copy(th.style.btnm.btn.pr, th.style.btnm.btn.rel) th.style.btnm.btn.pr.body.main_color = chl th.style.btnm.btn.pr.body.grad_color = chl # button map inactive lv.style_copy(th.style.btnm.btn.ina, th.style.btnm.btn.rel) th.style.btnm.btn.ina.text.opa = 80 # button map background th.style.btnm.bg.body.opa = 0 th.style.btnm.bg.body.border.width = 0 th.style.btnm.bg.body.shadow.width = 0 # textarea th.style.ta.oneline.body.opa = 0 th.style.ta.oneline.body.border.width = 0 th.style.ta.oneline.text.font = lv.font_roboto_28 # slider th.style.slider.knob.body.main_color = cbtnrel th.style.slider.knob.body.grad_color = cbtnrel th.style.slider.knob.body.radius = 5 th.style.slider.knob.body.border.width = 0 # page th.style.page.bg.body.opa = 0 th.style.page.scrl.body.opa = 0 th.style.page.bg.body.border.width = 0 th.style.page.bg.body.padding.left = 0 th.style.page.bg.body.padding.right = 0 th.style.page.bg.body.padding.top = 0 th.style.page.bg.body.padding.bottom = 0 th.style.page.scrl.body.border.width = 0 th.style.page.scrl.body.padding.left = 0 th.style.page.scrl.body.padding.right = 0 th.style.page.scrl.body.padding.top = 0 th.style.page.scrl.body.padding.bottom = 0 styles["theme"] = th lv.theme_set_current(th) # Title style - just a default style with larger font styles["title"] = lv.style_t() lv.style_copy(styles["title"], th.style.label.prim) styles["title"].text.font = lv.font_roboto_28 styles["title"].text.color = lv.color_hex(0xffffff) styles["hint"] = lv.style_t() lv.style_copy(styles["hint"], th.style.label.sec) styles["hint"].text.font = lv.font_roboto_16