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
Exemple #2
0
def init():
    """
    GUI initialization function. 
    Should be called once in the very beginning.
    """

    # init the gui library
    lv.init()
    # init the hardware library
    SDL.init()

    # Register SDL display driver
    disp_buf1 = lv.disp_buf_t()
    buf1_1 = bytearray(HOR_RES*10)
    lv.disp_buf_init(disp_buf1,buf1_1, None, len(buf1_1)//4)
    disp_drv = lv.disp_drv_t()
    lv.disp_drv_init(disp_drv)
    disp_drv.buffer = disp_buf1
    disp_drv.flush_cb = SDL.monitor_flush
    disp_drv.hor_res = HOR_RES
    disp_drv.ver_res = VER_RES
    lv.disp_drv_register(disp_drv)

    # Regsiter SDL mouse driver
    indev_drv = lv.indev_drv_t()
    lv.indev_drv_init(indev_drv) 
    indev_drv.type = lv.INDEV_TYPE.POINTER;
    indev_drv.read_cb = SDL.mouse_read;
    lv.indev_drv_register(indev_drv);

    # Set up material theme
    # First argument (210) is a hue - theme color shift,
    # Second - default font to use. Builtin: roboto_16, roboto_28
    th = lv.theme_material_init(210, lv.font_roboto_22)
    lv.theme_set_current(th)

    # Create a screen and load it
    # To access active screen use lv.scr_act()
    scr = lv.obj()
    lv.scr_load(scr)

    # Initialize the styles
    styles["title"] = lv.style_t()
    # Title style - just a default style with larger font
    lv.style_copy(styles["title"], lv.style_plain)
    styles["title"].text.font = lv.font_roboto_28
Exemple #3
0
def init():
    display.init()

    # Set up material theme
    # First argument (210) is a hue - theme color shift,
    # Second - default font to use. Builtin: roboto_16, roboto_28
    th = lv.theme_material_init(210, lv.font_roboto_22)
    lv.theme_set_current(th)

    # Create a screen and load it
    # To access active screen use lv.scr_act()
    scr = lv.obj()
    lv.scr_load(scr)

    # Initialize the styles
    styles["title"] = lv.style_t()
    # Title style - just a default style with larger font
    lv.style_copy(styles["title"], lv.style_plain)
    styles["title"].text.font = lv.font_roboto_28
Exemple #4
0
def set_theme():
    # setup theme
    th = lv.theme_material_init(210, lv.font_roboto_22)
    lv.theme_set_current(th)
disp_drv.gpu_fill_cb = lcd.gpu_fill
disp_drv.hor_res = hres
disp_drv.ver_res = vres
lv.disp_drv_register(disp_drv)

indev_drv = lv.indev_drv_t()
lv.indev_drv_init(indev_drv)
indev_drv.type = lv.INDEV_TYPE.POINTER
indev_drv.read_cb = lcd.ts_read
lv.indev_drv_register(indev_drv)

th = lv.theme_material_init(10, lv.font_roboto_16)
# th = lv.theme_alien_init(160, lv.font_roboto_16)
# th = lv.theme_zen_init(120, lv.font_roboto_16)
# th = lv.theme_nemo_init(180, lv.font_roboto_16)
lv.theme_set_current(th)

scr1 = lv.obj()
scr2 = lv.obj()
lv.scr_load(scr1)

slider = lv.slider(scr2)
slider.set_width(200)
slider.align(scr2, lv.ALIGN.IN_TOP_MID, 0, 15)

btn1 = lv.btn(scr1)
btn1.align(scr1, lv.ALIGN.IN_TOP_RIGHT, -5, 5)
label = lv.label(btn1)
label.set_text(">")

btn2 = lv.btn(scr2)
Exemple #6
0
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
Exemple #7
0
 def init_ui(self):
     display.init()
     theme = lv.theme_material_init(210, lv.font_roboto_mono_28)
     lv.theme_set_current(theme)
Exemple #8
0
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