#!/opt/bin/lv_micropython -i import lvgl as lv import display_driver import fs_driver fs_drv = lv.fs_drv_t() fs_driver.fs_register(fs_drv, 'S') img = lv.img(lv.scr_act()) # The File system is attached to letter 'S' img.set_src("S:example_32bit.bmp") img.center()
def __init__(self,script_dir,high_res): self.LV_HOR_RES = lv.scr_act().get_disp().driver.hor_res self.LV_VER_RES = lv.scr_act().get_disp().driver.ver_res # # dynamically load fonts # # FS driver init. fs_drv = lv.fs_drv_t() fs_driver.fs_register(fs_drv, 'S') # print( script_dir) # print("S:" + script_dir + "font/montserrat-22.bin") if high_res: self.font_montserrat_small = lv.font_load("S:" + script_dir + "font/montserrat-22.bin") self.font_montserrat_big = lv.font_load("S:" + script_dir + "font/montserrat-28.bin") else: self.font_montserrat_small = lv.font_load("S:" + script_dir + "font/montserrat-10.bin") self.font_montserrat_big = lv.font_load("S:" + script_dir + "font/montserrat-14.bin") self.log = logging.getLogger("Theme") self.log.setLevel(logging.ERROR) self.style_ddbox_pad = lv.style_t() self.style_ddbox_pad.init() self.style_ddbox_pad.set_pad_left(lv.STATE.DEFAULT, 5) self.style_ddbox_pad.set_pad_right(lv.STATE.DEFAULT, 5) self.style_ddbox_pad.set_pad_inner(lv.STATE.DEFAULT, 5) self.style_pad = lv.style_t() self.style_pad.init() self.style_pad.set_pad_top(lv.STATE.DEFAULT, self.LV_VER_RES // 30) self.style_pad.set_pad_bottom(lv.STATE.DEFAULT, self.LV_VER_RES // 30) self.style_pad.set_pad_left(lv.STATE.DEFAULT, self.LV_VER_RES // 40) self.style_pad.set_pad_right(lv.STATE.DEFAULT, self.LV_VER_RES // 40) self.style_circle = lv.style_t() self.style_circle.init() self.style_circle.set_radius(lv.STATE.DEFAULT, LV_RADIUS_CIRCLE) self.style_bg = lv.style_t() self.style_bg.init() self.style_bg.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER) self.style_bg.set_bg_color(lv.STATE.DEFAULT,LV_DEMO_PRINTER_LIGHT) self.style_bg.set_text_font(lv.STATE.DEFAULT, self.get_font_normal()) self.style_box = lv.style_t() self.style_box.init() self.style_box.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER) self.style_box.set_radius(lv.STATE.DEFAULT, 2) self.style_box.set_value_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_BLUE) self.style_box.set_value_font(lv.STATE.DEFAULT, self.get_font_normal()) self.style_box_border = lv.style_t() self.style_box_border.init() self.style_box_border.set_border_width(lv.STATE.DEFAULT, 2) self.style_box_border.set_border_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_GRAY) self.style_box_border.set_text_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_BLUE) self.style_title = lv.style_t() self.style_title.init() self.style_title.set_text_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_title.set_text_font(lv.STATE.DEFAULT, self.get_font_subtitle()) self.style_label = lv.style_t() self.style_label.init() self.style_label.set_text_font(lv.STATE.DEFAULT, self.get_font_normal()) self.style_label_white = lv.style_t() self.style_label_white.init() self.style_label_white.set_text_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_btn = lv.style_t() self.style_btn.init() self.style_btn.set_radius(lv.STATE.DEFAULT, 10) self.style_btn.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER) self.style_btn.set_bg_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_BLUE) self.style_btn.set_bg_color(lv.STATE.PRESSED, LV_DEMO_PRINTER_BLUE.color_darken(lv.OPA._20)) self.style_btn.set_text_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_btn.set_value_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_btn.set_text_font(lv.STATE.DEFAULT, self.get_font_subtitle()) self.style_btn.set_pad_top(lv.STATE.DEFAULT, self.LV_VER_RES // 40) self.style_btn.set_pad_bottom(lv.STATE.DEFAULT, self.LV_VER_RES // 40) self.style_btn.set_transform_width(lv.STATE.PRESSED, self.LV_HOR_RES // 100) self.style_btn.set_transform_height(lv.STATE.PRESSED, self.LV_HOR_RES // 150) self.style_btn.set_transition_time(lv.STATE.DEFAULT, 100) self.style_btn.set_transition_delay(lv.STATE.PRESSED, 0) self.style_btn.set_transition_delay(lv.STATE.DEFAULT, 70) self.style_btn.set_transition_prop_1(lv.STATE.DEFAULT, lv.STYLE.TRANSFORM_WIDTH) self.style_btn.set_transition_prop_2(lv.STATE.DEFAULT, lv.STYLE.TRANSFORM_HEIGHT) self.style_btn_border = lv.style_t() self.style_btn_border.init() self.style_btn_border.set_radius(lv.STATE.DEFAULT, LV_RADIUS_CIRCLE) self.style_btn_border.set_border_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_btn_border.set_border_width(lv.STATE.DEFAULT, 2) self.style_btn_border.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.TRANSP) self.style_btn_border.set_bg_opa(lv.STATE.PRESSED, lv.OPA._30) self.style_btn_border.set_bg_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_btn_border.set_bg_color(lv.STATE.PRESSED, LV_DEMO_PRINTER_WHITE) self.style_btn_border.set_text_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_btn_border.set_value_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_btn_border.set_transition_prop_3(lv.STATE.DEFAULT, lv.STYLE.BG_OPA) self.style_icon = lv.style_t() self.style_icon.init() self.style_icon.set_text_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_icon.set_transform_zoom(lv.STATE.PRESSED, 245) self.style_icon.set_transition_time(lv.STATE.DEFAULT, 100) self.style_icon.set_transition_delay(lv.STATE.PRESSED, 0) self.style_icon.set_transition_delay(lv.STATE.DEFAULT, 70) self.style_icon.set_transition_prop_1(lv.STATE.DEFAULT, lv.STYLE.TRANSFORM_ZOOM) self.style_icon.set_value_font(lv.STATE.DEFAULT, self.get_font_subtitle()) self.style_back = lv.style_t() self.style_back.init() self.style_back.set_value_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_back.set_value_color(lv.STATE.PRESSED, LV_DEMO_PRINTER_LIGHT_GRAY) self.style_back.set_border_width(lv.STATE.DEFAULT,0) self.style_back.set_bg_color(lv.STATE.DEFAULT,LV_DEMO_PRINTER_BLUE) self.style_back.set_value_str(lv.STATE.DEFAULT, lv.SYMBOL.LEFT) self.style_back.set_value_font(lv.STATE.DEFAULT, self.get_font_subtitle()) self.style_bar_indic = lv.style_t() self.style_bar_indic.init() self.style_bar_indic.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER) self.style_bar_indic.set_radius(lv.STATE.DEFAULT, 10) self.style_scrollbar = lv.style_t() self.style_scrollbar.init() self.style_scrollbar.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER) self.style_scrollbar.set_radius(lv.STATE.DEFAULT, LV_RADIUS_CIRCLE) self.style_scrollbar.set_bg_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_LIGHT_GRAY) self.style_scrollbar.set_size(lv.STATE.DEFAULT, self.LV_HOR_RES // 80) self.style_scrollbar.set_pad_right(lv.STATE.DEFAULT, self.LV_HOR_RES // 60) self.style_list_btn = lv.style_t() self.style_list_btn.init() self.style_list_btn.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER) self.style_list_btn.set_bg_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_list_btn.set_bg_color(lv.STATE.PRESSED, LV_DEMO_PRINTER_LIGHT_GRAY) self.style_list_btn.set_bg_color(lv.STATE.CHECKED, LV_DEMO_PRINTER_GRAY) self.style_list_btn.set_bg_color(lv.STATE.CHECKED | lv.STATE.PRESSED, LV_DEMO_PRINTER_GRAY.color_darken(lv.OPA._20)) self.style_list_btn.set_text_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_BLUE) self.style_list_btn.set_text_color(lv.STATE.PRESSED, LV_DEMO_PRINTER_BLUE.color_darken(lv.OPA._20)) self.style_list_btn.set_text_color(lv.STATE.CHECKED, LV_DEMO_PRINTER_WHITE) self.style_list_btn.set_text_color(lv.STATE.CHECKED | lv.STATE.PRESSED, LV_DEMO_PRINTER_WHITE) self.style_list_btn.set_image_recolor(lv.STATE.DEFAULT, LV_DEMO_PRINTER_BLUE) self.style_list_btn.set_image_recolor(lv.STATE.PRESSED, LV_DEMO_PRINTER_BLUE.color_darken(lv.OPA._20)) self.style_list_btn.set_image_recolor(lv.STATE.CHECKED, LV_DEMO_PRINTER_WHITE) self.style_list_btn.set_image_recolor(lv.STATE.CHECKED | lv.STATE.PRESSED, LV_DEMO_PRINTER_WHITE) self.style_list_btn.set_pad_left(lv.STATE.DEFAULT, self.LV_HOR_RES // 25) self.style_list_btn.set_pad_right(lv.STATE.DEFAULT, self.LV_HOR_RES // 25) self.style_list_btn.set_pad_top(lv.STATE.DEFAULT, self.LV_HOR_RES // 100) self.style_list_btn.set_pad_bottom(lv.STATE.DEFAULT, self.LV_HOR_RES // 100) self.style_list_btn.set_pad_inner(lv.STATE.DEFAULT, self.LV_HOR_RES // 50) self.style_ddlist_bg = lv.style_t() self.style_ddlist_bg.init() self.style_ddlist_bg.set_radius(lv.STATE.DEFAULT,10) self.style_ddlist_bg.set_bg_color(lv.STATE.DEFAULT,LV_DEMO_PRINTER_BLUE) self.style_ddlist_bg.set_text_color(lv.STATE.DEFAULT,lv_colors.WHITE) self.style_ddlist_bg.set_text_color(lv.STATE.PRESSED,LV_DEMO_PRINTER_WHITE) self.style_ddlist_bg.set_text_font(lv.STATE.DEFAULT,self.font_montserrat_small) self.style_ddlist_list = lv.style_t() self.style_ddlist_list.init() self.style_ddlist_list.set_text_font(lv.STATE.DEFAULT,self.font_montserrat_small) self.style_ddlist_list.set_shadow_width(lv.STATE.DEFAULT, self.LV_VER_RES // 20) self.style_ddlist_list.set_shadow_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_GRAY) self.style_ddlist_selected = lv.style_t() self.style_ddlist_selected.copy(self.style_ddlist_list) self.style_ddlist_selected.set_bg_color(lv.STATE.DEFAULT,LV_DEMO_PRINTER_BLUE) self.style_ddlist_selected.set_bg_color(lv.STATE.PRESSED, LV_DEMO_PRINTER_LIGHT_GRAY) self.style_ddlist_selected.set_text_color(lv.STATE.PRESSED, LV_DEMO_PRINTER_GRAY.color_darken(lv.OPA._20)) self.style_sw_bg = lv.style_t() self.style_sw_bg.init() self.style_sw_bg.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER) self.style_sw_bg.set_bg_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_LIGHT_GRAY) self.style_sw_bg.set_radius(lv.STATE.DEFAULT, lv.RADIUS.CIRCLE) self.style_sw_bg.set_value_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_BLUE) self.style_sw_indic = lv.style_t() self.style_sw_indic.init() self.style_sw_indic.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER) self.style_sw_indic.set_bg_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_GREEN); self.style_sw_knob = lv.style_t() self.style_sw_knob.init() self.style_sw_knob.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER) self.style_sw_knob.set_bg_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_sw_knob.set_radius(lv.STATE.DEFAULT, LV_RADIUS_CIRCLE) self.style_sw_knob.set_pad_top(lv.STATE.DEFAULT, - 4) self.style_sw_knob.set_pad_bottom(lv.STATE.DEFAULT, - 4) self.style_sw_knob.set_pad_left(lv.STATE.DEFAULT, - 4) self.style_sw_knob.set_pad_right(lv.STATE.DEFAULT, - 4) self.style_slider_knob = lv.style_t() self.style_slider_knob.init() self.style_slider_knob.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER) self.style_slider_knob.set_bg_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_BLUE) self.style_slider_knob.set_border_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_slider_knob.set_border_width(lv.STATE.DEFAULT, 3) self.style_slider_knob.set_radius(lv.STATE.DEFAULT, LV_RADIUS_CIRCLE) if high_res: knob_size = 10 pressed_knob_size = 14 else: knob_size = 5 pressed_knob_size = 8 self.style_slider_knob.set_pad_top(lv.STATE.DEFAULT, knob_size) self.style_slider_knob.set_pad_bottom(lv.STATE.DEFAULT, knob_size) self.style_slider_knob.set_pad_left(lv.STATE.DEFAULT, knob_size) self.style_slider_knob.set_pad_right(lv.STATE.DEFAULT, knob_size) self.style_slider_knob.set_pad_top(lv.STATE.PRESSED, pressed_knob_size) self.style_slider_knob.set_pad_bottom(lv.STATE.PRESSED, pressed_knob_size) self.style_slider_knob.set_pad_left(lv.STATE.PRESSED, pressed_knob_size) self.style_slider_knob.set_pad_right(lv.STATE.PRESSED, pressed_knob_size) self.style_slider_knob.set_transition_time(lv.STATE.DEFAULT, 150) self.style_slider_knob.set_transition_delay(lv.STATE.PRESSED, 0) self.style_slider_knob.set_transition_delay(lv.STATE.DEFAULT, 70) self.style_slider_knob.set_transition_prop_1(lv.STATE.DEFAULT, lv.STYLE.PAD_BOTTOM) self.style_slider_knob.set_transition_prop_2(lv.STATE.DEFAULT, lv.STYLE.PAD_TOP) self.style_slider_knob.set_transition_prop_3(lv.STATE.DEFAULT, lv.STYLE.PAD_LEFT) self.style_slider_knob.set_transition_prop_4(lv.STATE.DEFAULT, lv.STYLE.PAD_RIGHT) self.style_arc_indic = lv.style_t() self.style_arc_indic.init() if high_res: self.style_arc_indic.set_line_width(lv.STATE.DEFAULT, 5) else: self.style_arc_indic.set_line_width(lv.STATE.DEFAULT, 3) self.style_arc_indic.set_line_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_arc_bg = lv.style_t() self.style_arc_bg.init() self.style_arc_bg.set_value_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_WHITE) self.style_arc_bg.set_bg_color(lv.STATE.DEFAULT, LV_DEMO_PRINTER_BLUE) self.style_arc_bg.set_value_font(lv.STATE.DEFAULT, self.get_font_normal()) self.style_arc_bg.set_border_width(lv.STATE.DEFAULT,0)