From 145440dbce57babe6ef65936853944947dab7fe6 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Sat, 31 Jul 2021 16:07:07 +0300 Subject: [PATCH] fix(examples) use lv.grid_fr for MicroPython (#2419) Instead of re-implementing LV_GRID_FR, use lv.grid_fr Also use lv.GRID_TEMPLATE.LAST instead of lv.COORD.MAX where needed --- examples/anim/lv_example_anim_3.py | 6 ++---- examples/layouts/grid/lv_example_grid_1.py | 4 ++-- examples/layouts/grid/lv_example_grid_3.py | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/examples/anim/lv_example_anim_3.py b/examples/anim/lv_example_anim_3.py index 8e687d8aa..8822e0d1c 100644 --- a/examples/anim/lv_example_anim_3.py +++ b/examples/anim/lv_example_anim_3.py @@ -7,8 +7,6 @@ from micropython import const # CHART_POINTS_NUM = const(256) -def LV_GRID_FR(x): - return lv.COORD.MAX -100 +x class LvExampleAnim_3(): # @@ -16,8 +14,8 @@ class LvExampleAnim_3(): # def __init__(self): # Create a container with grid - col_dsc = [LV_GRID_FR(1), 200, LV_GRID_FR(1), lv.GRID_TEMPLATE.LAST] - row_dsc = [30, 10, 10, LV_GRID_FR(1),lv.GRID_TEMPLATE.LAST] + col_dsc = [lv.grid_fr(1), 200, lv.grid_fr(1), lv.GRID_TEMPLATE.LAST] + row_dsc = [30, 10, 10, lv.grid_fr(1),lv.GRID_TEMPLATE.LAST] self.p1 = 0 self.p2 = 0 diff --git a/examples/layouts/grid/lv_example_grid_1.py b/examples/layouts/grid/lv_example_grid_1.py index 814b076fd..433ffc676 100644 --- a/examples/layouts/grid/lv_example_grid_1.py +++ b/examples/layouts/grid/lv_example_grid_1.py @@ -2,8 +2,8 @@ # A simple grid # -col_dsc = [70, 70, 70, lv.COORD.MAX] -row_dsc = [50, 50, 50, lv.COORD.MAX] +col_dsc = [70, 70, 70, lv.GRID_TEMPLATE.LAST] +row_dsc = [50, 50, 50, lv.GRID_TEMPLATE.LAST] # Create a container with grid cont = lv.obj(lv.scr_act()) diff --git a/examples/layouts/grid/lv_example_grid_3.py b/examples/layouts/grid/lv_example_grid_3.py index 873129995..e820bdacc 100644 --- a/examples/layouts/grid/lv_example_grid_3.py +++ b/examples/layouts/grid/lv_example_grid_3.py @@ -1,5 +1,3 @@ -def LV_GRID_FR(x): - return lv.COORD.MAX - 100 + x # # Demonstrate grid's "free unit" # @@ -8,13 +6,13 @@ def LV_GRID_FR(x): # 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] +col_dsc = [60, lv.grid_fr(1), lv.grid_fr(2), lv.GRID_TEMPLATE.LAST] # 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] +row_dsc = [40, lv.grid_fr(1), 40, lv.GRID_TEMPLATE.LAST] # Create a container with grid cont = lv.obj(lv.scr_act())