example(micropython): updated MicroPython examples according to LVGL changes (#4031)
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
_CANVAS_WIDTH = 200
|
||||
_CANVAS_HEIGHT = 150
|
||||
LV_ZOOM_NONE = 256
|
||||
LV_IMG_ZOOM_NONE = 256
|
||||
|
||||
rect_dsc = lv.draw_rect_dsc_t()
|
||||
rect_dsc.init()
|
||||
rect_dsc.radius = 10
|
||||
rect_dsc.bg_opa = lv.OPA.COVER
|
||||
rect_dsc.bg_grad.dir = lv.GRAD_DIR.HOR
|
||||
rect_dsc.bg_grad.stops[0].color = lv.palette_main(lv.PALETTE.RED)
|
||||
rect_dsc.bg_grad.stops[1].color = lv.palette_main(lv.PALETTE.BLUE)
|
||||
#rect_dsc.bg_grad.stops[0].color = lv.palette_main(lv.PALETTE.RED)
|
||||
#rect_dsc.bg_grad.stops[1].color = lv.palette_main(lv.PALETTE.BLUE)
|
||||
|
||||
rect_dsc.bg_grad.stops = [
|
||||
lv.gradient_stop_t({'color': lv.palette_main(lv.PALETTE.RED)}),
|
||||
lv.gradient_stop_t({'color': lv.palette_main(lv.PALETTE.BLUE), 'frac':0xff})
|
||||
]
|
||||
|
||||
rect_dsc.border_width = 2
|
||||
rect_dsc.border_opa = lv.OPA._90
|
||||
rect_dsc.border_color = lv.color_white()
|
||||
@@ -18,9 +24,10 @@ rect_dsc.shadow_ofs_y = 5
|
||||
|
||||
label_dsc = lv.draw_label_dsc_t()
|
||||
label_dsc.init()
|
||||
label_dsc.color = lv.palette_main(lv.PALETTE.YELLOW)
|
||||
label_dsc.color = lv.palette_main(lv.PALETTE.ORANGE)
|
||||
|
||||
cbuf = bytearray(_CANVAS_WIDTH * _CANVAS_HEIGHT * 4)
|
||||
# cbuf2 = bytearray(_CANVAS_WIDTH * _CANVAS_HEIGHT * 4)
|
||||
|
||||
canvas = lv.canvas(lv.scr_act())
|
||||
canvas.set_buffer(cbuf, _CANVAS_WIDTH, _CANVAS_HEIGHT, lv.COLOR_FORMAT.NATIVE)
|
||||
@@ -34,10 +41,14 @@ canvas.draw_text(40, 20, 100, label_dsc, "Some text on text canvas")
|
||||
# So copy the current image to buffer and rotate it to the canvas
|
||||
|
||||
img = lv.img_dsc_t()
|
||||
|
||||
img.data = cbuf[:]
|
||||
# cbuf2 = cbuf[:]
|
||||
# img.data = cbuf2
|
||||
img.header.cf = lv.COLOR_FORMAT.NATIVE
|
||||
img.header.w = _CANVAS_WIDTH
|
||||
img.header.h = _CANVAS_HEIGHT
|
||||
|
||||
canvas.fill_bg(lv.palette_lighten(lv.PALETTE.GREY, 3), lv.OPA.COVER)
|
||||
canvas.transform(img, 30, LV_ZOOM_NONE, 0, 0, _CANVAS_WIDTH // 2, _CANVAS_HEIGHT // 2, True)
|
||||
canvas.transform(img, 120, LV_IMG_ZOOM_NONE, 0, 0, _CANVAS_WIDTH // 2, _CANVAS_HEIGHT // 2, True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user