def __init__(self): self.sys.path.append( '') # See: https://github.com/micropython/micropython/issues/6419 import display_driver_utils self.lv.init() driver = display_driver_utils.driver() scr = self.lv.scr_act()
def __init__(self): import ulogging as logging self.log = logging.getLogger("t-watch") self.log.setLevel(logging.DEBUG) self.log.debug("Starting LVGL") self.drv = driver(width=240, height=240) scr_style = lv.style_t() scr_style.set_bg_color(lv.STATE.DEFAULT, lv_colors.BLACK) lv.scr_act().add_style(lv.obj.PART.MAIN, scr_style) self.log.debug("starting splash screen") splash = Splashscreen() sleep(1) splash.set_label("Starting WiFi") try: from hardware.wifi import WiFi wifi = WiFi() wifi.connect() # # get CET time from NTP and set up the pcf8563 RTC # self.pcf8563 = self.drv.watch.rtc wifi.getTime() currentTime = wifi.cetTime() year = currentTime[0] month = currentTime[1] date = currentTime[2] hour = currentTime[3] minute = currentTime[4] second = currentTime[5] day = currentTime[6] month_short = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] day_of_week_short = [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ] self.log.debug( " Setting RTC to %s %d. %s %02d %02d:%02d:%02d" % (day_of_week_short[day], date, month_short[month - 1], year, hour, minute, second)) self.pcf8563.set_datetime(currentTime) except: pass self.log.debug("Starting the power manager") if hasattr(self.drv, "watch"): print("Running on the twatch") self.powermgr = PowerManager(self.drv) splash.deinit() self.gui = GUI(self.drv)
self.theme.apply(txt, LV_DEMO_PRINTER_THEME_LABEL_WHITE) txt.align(arc, lv.ALIGN.OUT_BOTTOM_MID, 0, 60) self.anim_in(arc, delay) delay += self.LV_DEMO_PRINTER_ANIM_DELAY self.anim_in(txt, delay) def print_start_ready(self): self.anim_bg(0, LV_DEMO_PRINTER_GREEN, self.LV_DEMO_PRINTER_BG_FULL) self.anim_out_all(lv.scr_act(), 0) img = lv.img(lv.scr_act(), None) img.set_src(self.img_ready_dsc) img.align(None, lv.ALIGN.CENTER, 0, -40) delay = 200 self.anim_in(img, delay) delay += self.LV_DEMO_PRINTER_ANIM_DELAY self.info_bottom_create("Printing finished", "CONTINUE", self.back_to_home_event_cb, delay) def back_to_print_event_cb(self, obj, evt): if evt == lv.EVENT.CLICKED: self.anim_out_all(lv.scr_act(), 0) self.print_open(150) drv = driver(width=800, height=480, orientation=ORIENT_LANDSCAPE) printer = DemoPrinter()
#!/opt/bin/lv_micropython -i import lvgl as lv import time,sys from display_driver_utils import driver from lv_colors import lv_colors if len(sys.argv) != 4: print("Usage %s filename width height"%sys.argv[0]) sys.exit() filename = sys.argv[1] width = int(sys.argv[2]) height = int(sys.argv[3]) drv = driver(width,height) try: with open(filename,'rb') as f: img_data = f.read() except: print("Could not open image file") sys.exit() scr = lv.scr_act() img = lv.img(scr) img.align(scr, lv.ALIGN.CENTER, 0, 0) img_dsc = lv.img_dsc_t( { "header": {"always_zero": 0, "w": width, "h": height, "cf": lv.img.CF.TRUE_COLOR_ALPHA}, "data_size": len(img_data), "data": img_data, }
#!/opt/bin/lv_micropython -i import lvgl as lv import time from display_driver_utils import driver drv = driver(width=480, height=320) LV_DEMO_WIDGETS_SLIDESHOW = 0 LV_THEME_DEFAULT_COLOR_PRIMARY = lv.color_hex(0x01a2b1) LV_THEME_DEFAULT_COLOR_SECONDARY = lv.color_hex(0x44d1b6) LV_LED_BRIGHT_MIN = 120 LV_LED_BRIGHT_MAX = 255 LV_DPI = 130 LV_ANIM_REPEAT_INFINITE = -1 def LV_DPX(n): if n == 0: return n scr = lv.scr_act() display = scr.get_disp() dpi = display.get_dpi() # print("dpi: ",dpi) tmp = (dpi * n + 80) // 160 # print("tmp: ",tmp) if tmp > 1: return tmp else: return 1
#!/opt/bin/lv_micropython -i """ST7735 demo (images).""" from time import sleep import lvgl as lv from display_driver_utils import driver, ORIENT_LANDSCAPE import time, sys from lv_colors import lv_colors drv = driver(width=320, height=240, orientation=ORIENT_LANDSCAPE) # Display a raw image SDL = 0 ILI9341 = 1 def drawImage(filename): img_height = 240 img_width = 320 # print("filename: ",filename) if '320x240' in filename: # print('320x240 image') offset = 0 else: offset = (img_width - img_height) // 2 img_width = 240 sdl_filename = '../assets/' + filename + '_argb8888.bin' ili3941_filename = 'images/' + filename + '_rgb565.bin' # print("filenames: " + sdl_filename + ", " + ili3941_filename)
#!/opt/bin/lv_micropython -i import lvgl as lv from display_driver_utils import driver, ORIENT_PORTRAIT import time, sys from os import stat from lv_colors import lv_colors from math import sqrt from random import randint, seed from utime import sleep_us, ticks_ms, ticks_us, ticks_diff from micropython import const driver(width=240, height=320, orientation=ORIENT_PORTRAIT) # Display a raw image SDL = 0 ILI9341 = 1 SCREEN_WIDTH = lv.scr_act().get_disp().driver.hor_res SCREEN_HEIGHT = lv.scr_act().get_disp().driver.ver_res # print("screen height: ",SCREEN_HEIGHT) LV_ANIM_REPEAT_INFINITE = -1 def draw_background(): try: with open('arkanoid_images/frame_top_240x10_argb8888.bin', 'rb') as f: frame_top_data = f.read() print( "'arkanoid_images/frame_top_240x10_argb8888.bin successfully read" ) driver = SDL except:
from display_driver_utils import driver drv = driver()
sys.path.append('') # See: https://github.com/micropython/micropython/issues/6419 try: script_path = __file__[:__file__.rfind('/')] if __file__.find('/') >= 0 else '.' except NameError: script_path = '' import lvgl as lv import fs_driver lv.init() # display driver init... import display_driver_utils # Default implementation. Replace by your driver driver = display_driver_utils.driver() # FS driver init. fs_drv = lv.fs_drv_t() fs_driver.fs_register(fs_drv, 'S') ''' load the font file from filesystem(For me is flash ) How to convert font files refer here: https://github.com/lvgl/lv_font_conv font-PHT-en-20.bin: lv_font_conv --size 20 --format bin --bpp 1 --font Alibaba-PuHuiTi-Medium.subset.ttf --range 0x20-0x7f --no-compress -o font-PHT-en-20.bin font-PHT-cn-20.bin: lv_font_conv --size 20 --format bin --bpp 1 --font Alibaba-PuHuiTi-Medium.subset.ttf --range 0x4e00-0x4e56 --no-compress -o font-PHT-cn-20.bin font-PHT-jp-20.bin: lv_font_conv --size 20 --format bin --bpp 1 --font Alibaba-PuHuiTi-Medium.subset.ttf --range 0x3042-0x3093 --no-compress -o font-PHT-jp-20.bin