Пример #1
0
#!//opt/bin/lv_micropython -i
import lvgl as lv
from time import sleep
import display_driver
from math import sin, cos, pi
from lv_colors import LV_COLOR_MAKE, lv_colors

disp = lv.scr_act().get_disp()
CANVAS_WIDTH = disp.driver.hor_res
CANVAS_HEIGHT = disp.driver.ver_res

HALF_WIDTH = CANVAS_WIDTH // 2
HALF_HEIGHT = CANVAS_HEIGHT // 2
CENTER_X = CANVAS_WIDTH // 2 - 1
CENTER_Y = CANVAS_HEIGHT // 2 - 1
ANGLE_STEP_SIZE = 0.05  # Decrease step size for higher resolution
PI2 = pi * 2


def clear(canvas):
    canvas.fill_bg(lv_colors.BLACK, lv.OPA.COVER)


def hsv_to_rgb(h, s, v):
    """
    Convert HSV to RGB (based on colorsys.py).

        Args:
            h (float): Hue 0 to 1.
            s (float): Saturation 0 to 1.
            v (float): Value 0 to 1 (Brightness).
Пример #2
0
#!/opt/bin/lv_micropython -i
import lvgl as lv
import display_driver

# Create a LED and switch it OFF
led1 = lv.led(lv.scr_act(), None)
led1.align(None, lv.ALIGN.CENTER, -80, 0)
led1.off()

# Copy the previous LED and set a brightness
led2 = lv.led(lv.scr_act(), led1)
led2.align(None, lv.ALIGN.CENTER, 0, 0)
led2.set_bright(190)

# Copy the previous LED and switch it ON
led3 = lv.led(lv.scr_act(), led1)
led3.align(None, lv.ALIGN.CENTER, 80, 0)
led3.on()
Пример #3
0
#
import time
#
# initialize lvgl
#
import lvgl as lv
import display_driver
from lv_colors import lv_colors

style = lv.style_t()
style.init()
# Set a background color and a radius
style.set_radius(lv.STATE.DEFAULT, 5)
style.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER)
style.set_bg_color(lv.STATE.DEFAULT, lv_colors.SILVER)

# Add a value text properties
style.set_value_color(lv.STATE.DEFAULT, lv_colors.BLUE)
style.set_value_align(lv.STATE.DEFAULT, lv.ALIGN.IN_BOTTOM_RIGHT)
style.set_value_ofs_x(lv.STATE.DEFAULT, 10)
style.set_value_ofs_y(lv.STATE.DEFAULT, 10)

# Create an object with the new style
obj = lv.obj(lv.scr_act(), None)
obj.add_style(lv.obj.PART.MAIN, style)
obj.align(None, lv.ALIGN.CENTER, 0, 0)

# Add a value text to the local style. This way every object can have different text
obj.set_style_local_value_str(lv.obj.PART.MAIN, lv.STATE.DEFAULT, "Text")

Пример #4
0
def add_data(t):
    chart.set_next_value(ser, lv.rand(10, 90))

    p = chart.get_point_count()
    s = chart.get_x_start_point(ser)
    a = chart.get_y_array(ser)

    a[(s + 1) % p] = lv.CHART_POINT_NONE
    a[(s + 2) % p] = lv.CHART_POINT_NONE
    a[(s + 3) % p] = lv.CHART_POINT_NONE
    chart.refresh()


#
# Circular line chart with gap
#
chart = lv.chart(lv.scr_act())

chart.set_update_mode(lv.chart.UPDATE_MODE.CIRCULAR)
chart.set_size(200, 150)
chart.center()

chart.set_point_count(30)
ser = chart.add_series(lv.palette_main(lv.PALETTE.RED),
                       lv.chart.AXIS.PRIMARY_Y)
#Prefill with data
for i in range(0, 30):
    chart.set_next_value(ser, lv.rand(10, 90))

lv.timer_create(add_data, 200, None)
Пример #5
0
import lcd
import time
from machine import Timer

lcd.init()
lv.init()

disp_drv = lv.disp_drv_t()
lv.disp_drv_init(disp_drv)
disp_drv.disp_flush = lv_h.flush
disp_drv.disp_fill = lv_h.fill
lv.disp_drv_register(disp_drv)

scr = lv.obj()
btn = lv.btn(scr)
btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text("Button")
lv.scr_load(scr)


def on_timer(timer):
    lv.tick_inc(5)


timer = Timer(Timer.TIMER0,
              Timer.CHANNEL0,
              mode=Timer.MODE_PERIODIC,
              period=5,
              unit=Timer.UNIT_MS,
              callback=on_timer,
Пример #6
0
img_cogwheel_argb = lv.img_dsc_t({
    'data_size': len(png_data),
    'data': png_data
})

#
# Using the Image style properties
#
style = lv.style_t()
style.init()

# Set a background color and a radius
style.set_radius(5)
style.set_bg_opa(lv.OPA.COVER)
style.set_bg_color(lv.palette_lighten(lv.PALETTE.GREY, 3))
style.set_border_width(2)
style.set_border_color(lv.palette_main(lv.PALETTE.BLUE))

style.set_img_recolor(lv.palette_main(lv.PALETTE.BLUE))
style.set_img_recolor_opa(lv.OPA._50)
# style.set_transform_angle(300)

# Create an object with the new style
obj = lv.img(lv.scr_act())
obj.add_style(style, 0)

obj.set_src(img_cogwheel_argb)

obj.center()
Пример #7
0
#

# Column 1: fix width 60 px
# Column 2: 1 unit from the remaining free space
# Column 3: 2 unit from the remaining free space

col_dsc = [60, LV_GRID_FR(1), LV_GRID_FR(2), lv.COORD.MAX]

# Row 1: fix width 60 px
# Row 2: 1 unit from the remaining free space
# Row 3: fix width 60 px

row_dsc = [40, LV_GRID_FR(1), 40, lv.COORD.MAX]

# Create a container with grid
cont = lv.obj(lv.scr_act())
cont.set_size(300, 220)
cont.center()
cont.set_grid_dsc_array(col_dsc, row_dsc)

for i in range(9):
    col = i % 3
    row = i // 3

    obj = lv.obj(cont)
    # Stretch the cell horizontally and vertically too
    # Set span to 1 to make the cell 1 column/row sized
    obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, col, 1, lv.GRID_ALIGN.STRETCH,
                      row, 1)

    label = lv.label(obj)
#!//opt/bin/lv_micropython -i
import time
import lvgl as lv
import display_driver


def slider_event_cb(evt):
    slider = evt.get_target()

    # Refresh the text
    label.set_text(str(slider.get_value()))


#
# Create a slider and write its value on a label.
#

# Create a slider in the center of the display
slider = lv.slider(lv.scr_act())
slider.set_width(200)  # Set the width
slider.center()  # Align to the center of the parent (screen)
slider.add_event_cb(slider_event_cb, lv.EVENT.VALUE_CHANGED,
                    None)  # Assign an event function

# Create a label below the slider
label = lv.label(lv.scr_act())
label.set_text("0")
label.align_to(slider, lv.ALIGN.OUT_TOP_MID, 0, -15)  # Align below the slider
display_driver.getdisplay_landscape()

#
# Create a drop down, up, left and right menus
#

opts = "\n".join(
    ["Apple\n"
     "Banana\n"
     "Orange\n"
     "Melon\n"
     "Grape\n"
     "Raspberry"])

dd = lv.dropdown(lv.scr_act())
dd.set_options_static(opts)
dd.align(lv.ALIGN.TOP_MID, 0, 10)
dd = lv.dropdown(lv.scr_act())
dd.set_options_static(opts)
dd.set_dir(lv.DIR.BOTTOM)
dd.set_symbol(lv.SYMBOL.UP)
dd.align(lv.ALIGN.BOTTOM_MID, 0, -10)

dd = lv.dropdown(lv.scr_act())
dd.set_options_static(opts)
dd.set_dir(lv.DIR.RIGHT)
dd.set_symbol(lv.SYMBOL.RIGHT)
dd.align(lv.ALIGN.LEFT_MID, 10, 0)

dd = lv.dropdown(lv.scr_act())
Пример #10
0

#############################################
############### Calendar(日历) ##############
#############################################
#日历触摸回调函数
def event_handler(obj, event):
    if event == lv.EVENT.CLICKED:
        date = obj.get_pressed_date()
        if date is not None:
            obj.set_today_date(date)  #显示按下选中的日期


if TOUCH_READY:

    calendar = lv.calendar(lv.scr_act())
    calendar.set_size(230, 230)
    calendar.align(None, lv.ALIGN.CENTER, 0, 0)
    calendar.set_event_cb(event_handler)

    #设置当前日期
    today = lv.calendar_date_t()  #构建日期对象
    today.year = 2020
    today.month = 7
    today.day = 1

    calendar.set_today_date(today)
    calendar.set_showed_date(today)  #设置当前显示日期

    #设置显示3个高亮日期
    highlihted_days = [
Пример #11
0
            ymax = ymax+500
            label_log.set_text('Y Range Updated')
            chart.set_range(lv.chart.AXIS.PRIMARY_Y, ymin, ymax)
        label_log.set_text('Plotting ' + str(temp))
        
    label_log.set_text('Plotting Complete')
        
'''start lvgl'''
from ili9XXX import ili9488
disp = ili9488(miso=19, mosi=23, clk=18, cs=5, dc=26, rst=27, power=14, backlight=-1, backlight_on=0, power_on=0, rot=0x80,spihost=VSPI_HOST, mhz=50, factor=16, hybrid=True, width=320, height=480, invert=False, double_buffer=True, half_duplex=False, initialize=True)

from xpt2046 import xpt2046
touch = xpt2046(cs=25, spihost=VSPI_HOST, mosi=-1, miso=-1, clk=-1, cal_y0 = 423, cal_y1=3948)

'''Main screen : lv.scr_act()'''
lv.scr_act().set_style_bg_color(lv.color_hex(0x000000),0)
label = lv.label(lv.scr_act())
label.set_style_text_font(lv.font_montserrat_28,0)
label.set_text("{} : {:2} ".format(data_j['symbol'], float(data_j['price'])))
label.align_to(lv.scr_act(), lv.ALIGN.TOP_MID,0,10)
label.set_style_text_color(lv.color_hex(0x00eeff),0)

label_log = lv.label(lv.scr_act())
label_log.align_to(lv.scr_act(), lv.ALIGN.BOTTOM_LEFT,0,-10)
label_log.set_text("Log")
label_log.set_style_text_color(lv.color_hex(0x1aec1a),0)

'''Chart minute : add chart'''
chart = lv.chart(lv.scr_act())
chart.set_style_bg_color(lv.color_hex(0x000000),0)
chart.set_style_line_color(lv.color_hex(0x1aec1a),0)
Пример #12
0
 def global_refresher(self, _):
     lv.event_send_refresh_recursive(lv.scr_act())
Пример #13
0
# Create a transition animation on width transformation and recolor.
tr_prop = [lv.STYLE.TRANSFORM_WIDTH, lv.STYLE.IMG_RECOLOR_OPA, 0]
tr = lv.style_transition_dsc_t()
tr.init(tr_prop, lv.anim_t.path_linear, 200, 0, None)

style_def = lv.style_t()
style_def.init()
style_def.set_text_color(lv.color_white())
style_def.set_transition(tr)

# Darken the button when pressed and make it wider
style_pr = lv.style_t()
style_pr.init()
style_pr.set_img_recolor_opa(lv.OPA._30)
style_pr.set_img_recolor(lv.color_black())
style_pr.set_transform_width(20)

# Create an image button
imgbtn1 = lv.imgbtn(lv.scr_act())
imgbtn1.set_src(lv.imgbtn.STATE.RELEASED, imgbtn_left_dsc, imgbtn_mid_dsc,
                imgbtn_right_dsc)
imgbtn1.add_style(style_def, 0)
imgbtn1.add_style(style_pr, lv.STATE.PRESSED)

imgbtn1.align(lv.ALIGN.CENTER, 0, 0)

# Create a label on the image button
label = lv.label(imgbtn1)
label.set_text("Button")
label.align(lv.ALIGN.CENTER, 0, -4)
Пример #14
0
import gc
import lvgl as lv
from imagetools import get_png_info, open_png

# Register PNG image decoder
decoder = lv.img.decoder_create()
decoder.info_cb = get_png_info
decoder.open_cb = open_png

# Measure memory usage
gc.enable()
gc.collect()
mem_free = gc.mem_free()

label = lv.label(lv.scr_act())
label.align(lv.ALIGN.BOTTOM_MID, 0, -10)
label.set_text(" memory free:" + str(mem_free / 1024) + " kB")

# Create an image from the png file
try:
    with open('../../assets/star.png', 'rb') as f:
        png_data = f.read()
except:
    print("Could not find star.png")
    sys.exit()

img_star = lv.img_dsc_t({'data_size': len(png_data), 'data': png_data})


def event_cb(e, snapshot_obj):
    img = e.get_target()
Пример #15
0
indev_drv.read_cb = touch.read
lv.indev_drv_register(indev_drv)

# Load the screen
scr = lv.obj()
lv.scr_load(scr)


# create objects
def on_button(obj, event):
    print('on_button event')
    if event == lv.EVENT.CLICKED:
        print('button clicked!')


btn = lv.btn(lv.scr_act())
#btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
btn.set_pos(50, 50)
label = lv.label(btn)
label.set_text("Button")
btn.set_event_cb(on_button)

bar1 = lv.bar(lv.scr_act())
bar1.set_size(200, 30)
bar1.align(None, lv.ALIGN.CENTER, 0, 100)
bar1.set_anim_time(1000)
bar1.set_value(100, lv.ANIM.ON)

print('starting loop')
while True:
    if DEBUG:
Пример #16
0
#!/opt/bin/lv_micropython -i

import lvgl as lv
import display_driver

display_driver.getdisplay_landscape()

#
# Demonstrate how scrolling appears automatically
#
# Create an object with the new style
panel = lv.obj(lv.scr_act())
panel.set_size(200, 200)
panel.center()

child = lv.obj(panel)
child.set_pos(0, 0)
label = lv.label(child)
label.set_text("Zero")
label.center()

child = lv.obj(panel)
child.set_pos(-40, 100)
label = lv.label(child)
label.set_text("Left")
label.center()

child = lv.obj(panel)
child.set_pos(90, -30)
label = lv.label(child)
label.set_text("Top")
    if len(txt) < 2:
        return
    if ":" in txt:
        return
    if  txt[0] >= '0' and txt[0] <= '9' and \
        txt[1] >= '0' and txt[1] <= '9':
        if len(txt) == 2 or txt[2] != ':' :
            ta.set_cursor_pos(2)
            ta.add_char(ord(':'))
#
# Automatically format text like a clock. E.g. "12:34"
# Add the ':' automatically
#
# Create the text area

LV_HOR_RES = lv.scr_act().get_disp().driver.hor_res
LV_VER_RES = lv.scr_act().get_disp().driver.ver_res

ta = lv.textarea(lv.scr_act())
ta.add_event_cb(ta_event_cb, lv.EVENT.VALUE_CHANGED, None)
ta.set_accepted_chars("0123456789:")
ta.set_max_length(5)
ta.set_one_line(True)
ta.set_text("")
ta.add_state(lv.STATE.FOCUSED)

# Create a keyboard
kb = lv.keyboard(lv.scr_act())
kb.set_size(LV_HOR_RES, LV_VER_RES // 2)
kb.set_mode(lv.keyboard.MODE.NUMBER)
kb.set_textarea(ta)
Пример #18
0
#!/opt/bin/lv_micropython -i
import sys
import lvgl as lv
import display_driver

lottie = lv.rlottie_create_from_file(lv.scr_act(), 100, 100,"lv_example_rlottie_approve.json")
lottie.center()
Пример #19
0
import display_driver

display_driver.getdisplay_landscape()

#
# Create a fake text shadow
#

# Create a style for the shadow
style_shadow = lv.style_t()
style_shadow.init()
style_shadow.set_text_opa(lv.OPA._30)
style_shadow.set_text_color(lv.color_black())

# Create a label for the shadow first (it's in the background)
shadow_label = lv.label(lv.scr_act())
shadow_label.add_style(style_shadow, 0)

# Create the main label
main_label = lv.label(lv.scr_act())
main_label.set_text("A simple method to create\n"
                    "shadows on a text.\n"
                    "It even works with\n\n"
                    "newlines     and spaces.")

# Set the same text for the shadow label
shadow_label.set_text(lv.label.get_text(main_label))

# Position the main label
main_label.align(lv.ALIGN.CENTER, 0, 0)

display_driver.getdisplay_landscape()


def increment_event_cb(e):
    code = e.get_code()
    if code == lv.EVENT.SHORT_CLICKED or code  == lv.EVENT.LONG_PRESSED_REPEAT:
        spinbox.increment()

def decrement_event_cb(e):
    code = e.get_code()
    if code == lv.EVENT.SHORT_CLICKED or code == lv.EVENT.LONG_PRESSED_REPEAT:
        spinbox.decrement()

spinbox = lv.spinbox(lv.scr_act())
spinbox.set_range(-1000, 25000)
spinbox.set_digit_format(5, 2)
spinbox.step_prev()
spinbox.set_width(100)
spinbox.center()

h = spinbox.get_height()

btn = lv.btn(lv.scr_act())
btn.set_size(h, h)
btn.align_to(spinbox, lv.ALIGN.OUT_RIGHT_MID, 5, 0)
btn.set_style_bg_img_src(lv.SYMBOL.PLUS, 0)
btn.add_event_cb(increment_event_cb, lv.EVENT.ALL,  None)

btn = lv.btn(lv.scr_act())
style_pr = lv.style_t()
style_pr.init()

# Add a large outline when pressed
style_pr.set_outline_width(30)
style_pr.set_outline_opa(lv.OPA.TRANSP)

style_pr.set_translate_y(5)
style_pr.set_shadow_ofs_y(3)
style_pr.set_bg_color(lv.palette_darken(lv.PALETTE.BLUE, 2))
style_pr.set_bg_grad_color(lv.palette_darken(lv.PALETTE.BLUE, 4))

# Add a transition to the the outline
trans = lv.style_transition_dsc_t()
props = [lv.STYLE.OUTLINE_WIDTH, lv.STYLE.OUTLINE_OPA, 0]
trans.init(props, lv.anim_t.path_linear, 300, 0, None)

style_pr.set_transition(trans)

btn1 = lv.btn(lv.scr_act())
btn1.remove_style_all()                          # Remove the style coming from the theme
btn1.add_style(style, 0)
btn1.add_style(style_pr, lv.STATE.PRESSED)
btn1.set_size(lv.SIZE.CONTENT, lv.SIZE.CONTENT)
btn1.center()

label = lv.label(btn1)
label.set_text("Button")
label.center()

#!/opt/bin/lv_micropython
import lvgl as lv
import init_gui
import time

cpicker = lv.cpicker(lv.scr_act(),None)
cpicker.set_type(lv.cpicker.TYPE.RECT);
cpicker.set_size(200, 50);
cpicker.align(None, lv.ALIGN.CENTER, 0, 0)

#!/opt/bin/lv_micropython -i

import lvgl as lv
import display_driver

display_driver.getdisplay_landscape()

#
# Using the outline style properties
#

style = lv.style_t()
style.init()

# Set a background color and a radius
style.set_radius(5)
style.set_bg_opa(lv.OPA.COVER)
style.set_bg_color(lv.palette_lighten(lv.PALETTE.GREY, 1))

# Add outline
style.set_outline_width(2)
style.set_outline_color(lv.palette_main(lv.PALETTE.BLUE))
style.set_outline_pad(8)

# Create an object with the new style
obj = lv.obj(lv.scr_act())
obj.add_style(style, 0)
obj.center()
#!//opt/bin/lv_micropython -i
import time
import lvgl as lv
import display_driver
import fs_driver
#
# Show mixed LTR, RTL and Chinese label
#

ltr_label = lv.label(lv.scr_act())
ltr_label.set_text("In modern terminology, a microcontroller is similar to a system on a chip (SoC).");
# ltr_label.set_style_text_font(ltr_label, &lv_font_montserrat_16, 0);

fs_drv = lv.fs_drv_t()
fs_driver.fs_register(fs_drv, 'S')

try:
    ltr_label.set_style_text_font(ltr_label, lv.font_montserrat_16, 0)
except:
    font_montserrat_16 = lv.font_load("S:../../assets/font/montserrat-16.fnt")
    ltr_label.set_style_text_font(font_montserrat_16, 0)
    
ltr_label.set_width(310)
ltr_label.align(lv.ALIGN.TOP_LEFT, 5, 5)

rtl_label = lv.label(lv.scr_act())
rtl_label.set_text("מעבד, או בשמו המלא יחידת עיבוד מרכזית (באנגלית: CPU - Central Processing Unit).")
rtl_label.set_style_base_dir(lv.BASE_DIR.RTL, 0)
rtl_label.set_style_text_font(lv.font_dejavu_16_persian_hebrew, 0)
rtl_label.set_width(310)
rtl_label.align(lv.ALIGN.LEFT_MID, 5, 0)
Пример #25
0
    # If the indicator is still short put the text out of it on the right*/
    else:
        txt_area.x1 = dsc.draw_area.x2 + 5
        txt_area.x2 = txt_area.x1 + txt_size.x - 1
        label_dsc.color = lv.color_black()

    txt_area.y1 = dsc.draw_area.y1 + (dsc.draw_area.get_height() - txt_size.y) // 2
    txt_area.y2 = txt_area.y1 + txt_size.y - 1

    dsc.draw_ctx.label(label_dsc, txt_area, value_txt, None)

#
# Custom drawer on the bar to display the current value
#

bar = lv.bar(lv.scr_act())
bar.add_event_cb(event_cb, lv.EVENT.DRAW_PART_END, None)
bar.set_size(200, 20)
bar.center()

a = lv.anim_t()
a.init()
a.set_var(bar)
a.set_values(0, 100)
a.set_custom_exec_cb(lambda a,val: set_value(bar,val))
a.set_time(2000)
a.set_playback_time(2000)
a.set_repeat_count(lv.ANIM_REPEAT_INFINITE)
lv.anim_t.start(a)

Пример #26
0
#!/opt/bin/lv_micropython -i
import lvgl as lv
import display_driver
def event_handler(e):
    code = e.get_code()
    obj = lv.btn.__cast__(e.get_target())
    if code == lv.EVENT.CLICKED:
            print("Clicked: list1." + list1.get_btn_text(obj))

# Create a list
list1 = lv.list(lv.scr_act())
list1.set_size(180, 220)
list1.center()

# Add buttons to the list
list1.add_text("File")
btn_new = list1.add_btn(lv.SYMBOL.FILE, "New")
btn_new.add_event_cb(event_handler,lv.EVENT.ALL, None)
btn_open = list1.add_btn(lv.SYMBOL.DIRECTORY, "Open")
btn_open.add_event_cb(event_handler,lv.EVENT.ALL, None)
btn_save = list1.add_btn(lv.SYMBOL.SAVE, "Save")
btn_save.add_event_cb(event_handler,lv.EVENT.ALL, None)
btn_delete = list1.add_btn(lv.SYMBOL.CLOSE, "Delete")
btn_delete.add_event_cb(event_handler,lv.EVENT.ALL, None)
btn_edit = list1.add_btn(lv.SYMBOL.EDIT, "Edit")
btn_edit.add_event_cb(event_handler,lv.EVENT.ALL, None)

list1.add_text("Connectivity")
btn_bluetooth = list1.add_btn(lv.SYMBOL.BLUETOOTH, "Bluetooth")
btn_bluetooth.add_event_cb(event_handler,lv.EVENT.ALL, None)
btn_navig = list1.add_btn(lv.SYMBOL.GPS, "Navigation")
Пример #27
0
#!/opt/bin/lv_micropython -i
import sys
import lvgl as lv
import display_driver
import fs_driver

info = lv.ft_info_t()
info.name = "./arial.ttf"
info.weight = 24
info.style = lv.FT_FONT_STYLE.NORMAL
info.font_init()

# Create style with the new font
style = lv.style_t()
style.init()
style.set_text_font(info.font)
style.set_text_align(lv.TEXT_ALIGN.CENTER)

# Create a label with the new style
label = lv.label(lv.scr_act())
label.add_style(style, 0)
label.set_text("Hello world\nI'm a font created with FreeType")
label.center()
    chart.set_zoom_x(v)

def slider_y_event_cb(e):

    slider = e.get_target()
    v = slider.get_value()
    chart.set_zoom_y(v)


#
# Display 1000 data points with zooming and scrolling.
# See how the chart changes drawing mode (draw only vertical lines) when
# the points get too crowded.
 
# Create a chart
chart = lv.chart(lv.scr_act())
chart.set_size(200, 150)
chart.align(lv.ALIGN.CENTER, -30, -30)
chart.set_range(lv.chart.AXIS.PRIMARY_Y, -1000, 1000)

# Do not display points on the data
chart.set_style_size(0, lv.PART.INDICATOR)

ser = chart.add_series(lv.palette_main(lv.PALETTE.RED), lv.chart.AXIS.PRIMARY_Y)

pcnt = len(ecg_sample)
chart.set_point_count(pcnt)
chart.set_ext_y_array(ser, ecg_sample)

slider = lv.slider(lv.scr_act())
slider.set_range(lv.IMG_ZOOM.NONE, lv.IMG_ZOOM.NONE * 10)
Пример #29
0
import lvgl as lv
import display_driver
from imagetools import get_png_info, open_png

# Register PNG image decoder
decoder = lv.img.decoder_create()
decoder.info_cb = get_png_info
decoder.open_cb = open_png

# Create an image from the png file
try:
    with open('../../assets/img_cogwheel_argb.png', 'rb') as f:
        png_data = f.read()
except:
    print("Could not find img_cogwheel_argb.png")
    sys.exit()

img_cogwheel_argb = lv.img_dsc_t({
    'data_size': len(png_data),
    'data': png_data
})

img1 = lv.img(lv.scr_act())
img1.set_src(img_cogwheel_argb)
img1.align(lv.ALIGN.CENTER, 0, -20)
img1.set_size(200, 200)

img2 = lv.img(lv.scr_act())
img2.set_src(lv.SYMBOL.OK + "Accept")
img2.align_to(img1, lv.ALIGN.OUT_BOTTOM_MID, 0, 20)
Пример #30
0
#!//opt/bin/lv_micropython -i
import time
import lvgl as lv
import display_driver

#
# Using the Arc style properties
#
style = lv.style_t()
style.init()

style.set_arc_color(lv.palette_main(lv.PALETTE.RED))
style.set_arc_width(4)

# Create an object with the new style
obj = lv.arc(lv.scr_act())
obj.add_style(style, 0)
obj.center()