fix(micropython) update examples for new API (#3059)

Related: https://github.com/lvgl/lv_binding_micropython/issues/202
This commit is contained in:
Amir Gonnen
2022-01-29 19:39:11 +02:00
committed by GitHub
parent f6a61df3ae
commit c7a414bfc6
7 changed files with 9 additions and 11 deletions

View File

@@ -31,7 +31,7 @@ def event_cb(e):
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
lv.draw_label(txt_area, dsc.clip_area, label_dsc, value_txt, None)
dsc.draw_ctx.label(label_dsc, txt_area, value_txt, None)
#
# Custom drawer on the bar to display the current value

View File

@@ -34,7 +34,7 @@ def event_cb(e):
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
lv.draw_label(txt_area, dsc.clip_area, label_dsc, value_txt, None)
dsc.draw_ctx.label(label_dsc, txt_area, value_txt, None)
#
# Custom drawer on the bar to display the current value

View File

@@ -21,8 +21,8 @@ img_star_argb = lv.img_dsc_t({
def event_cb(e):
code = e.get_code()
obj = e.get_target()
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
if code == lv.EVENT.DRAW_PART_BEGIN:
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
# Change the draw descriptor the 2nd button
if dsc.id == 1:
dsc.rect_dsc.radius = 0
@@ -50,8 +50,6 @@ def event_cb(e):
dsc.label_dsc.opa = lv.OPA.TRANSP # Hide the text if any
if code == lv.EVENT.DRAW_PART_END:
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
# Add custom content to the 4th button when the button itself was drawn
if dsc.id == 3:
# LV_IMG_DECLARE(img_star)
@@ -72,7 +70,7 @@ def event_cb(e):
if obj.get_selected_btn() == dsc.id:
img_draw_dsc.recolor_opa = lv.OPA._30
lv.draw_img(a, dsc.clip_area, img_star_argb, img_draw_dsc)
dsc.draw_ctx.img(img_draw_dsc, a, img_star_argb)
#
# Add custom drawer to the button matrix to c

View File

@@ -35,7 +35,7 @@ def draw_event_cb(e):
coords = lv.area_t()
obj.get_coords(coords)
a.y2 = coords.y2
lv.draw_rect(a, dsc.clip_area, draw_rect_dsc)
dsc.draw_ctx.rect(draw_rect_dsc, a)
# Remove the masks
lv.draw_mask_remove_id(line_mask_id)

View File

@@ -41,7 +41,7 @@ def draw_event_cb(e):
a.x2 = dsc.p2.x
a.y1 = min(dsc.p1.y, dsc.p2.y)
a.y2 = cont_a.y2 - 13 # -13 cuts off where the rectangle draws over the chart margin. Without this an area of 0 doesn't look like 0
lv.draw_rect(a, dsc.clip_area, draw_rect_dsc)
dsc.draw_ctx.rect(draw_rect_dsc, a)
# Remove the mask
lv.draw_mask_free_param(line_mask_param)

View File

@@ -24,7 +24,7 @@ def slider_event_cb(e):
label_draw_dsc = lv.draw_label_dsc_t()
label_draw_dsc.init()
lv.draw_label(label_area, dsc.clip_area, label_draw_dsc, label_text, None)
dsc.draw_ctx.label(label_draw_dsc, label_area, label_text, None)
#
# Show the current value when the slider if pressed by extending the drawer
#

View File

@@ -25,7 +25,7 @@ def draw_event_cb(e):
sw_area.x2 = sw_area.x1 + 40
sw_area.y1 = dsc.draw_area.y1 + dsc.draw_area.get_height() // 2 - 10
sw_area.y2 = sw_area.y1 + 20
lv.draw_rect(sw_area, dsc.clip_area, rect_dsc)
dsc.draw_ctx.rect(rect_dsc, sw_area)
rect_dsc.bg_color = lv.color_white()
@@ -37,7 +37,7 @@ def draw_event_cb(e):
sw_area.x2 = sw_area.x1 + 16
sw_area.y1 += 2
sw_area.y2 -= 2
lv.draw_rect(sw_area, dsc.clip_area, rect_dsc)
dsc.draw_ctx.rect(rect_dsc, sw_area)
def change_event_cb(e):
obj = e.get_target()