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
This commit is contained in:
Amir Gonnen
2021-07-31 16:07:07 +03:00
committed by GitHub
parent 65475a75ba
commit 145440dbce
3 changed files with 6 additions and 10 deletions

View File

@@ -7,8 +7,6 @@ from micropython import const
# #
CHART_POINTS_NUM = const(256) CHART_POINTS_NUM = const(256)
def LV_GRID_FR(x):
return lv.COORD.MAX -100 +x
class LvExampleAnim_3(): class LvExampleAnim_3():
# #
@@ -16,8 +14,8 @@ class LvExampleAnim_3():
# #
def __init__(self): def __init__(self):
# Create a container with grid # Create a container with grid
col_dsc = [LV_GRID_FR(1), 200, 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] row_dsc = [30, 10, 10, lv.grid_fr(1),lv.GRID_TEMPLATE.LAST]
self.p1 = 0 self.p1 = 0
self.p2 = 0 self.p2 = 0

View File

@@ -2,8 +2,8 @@
# A simple grid # A simple grid
# #
col_dsc = [70, 70, 70, lv.COORD.MAX] col_dsc = [70, 70, 70, lv.GRID_TEMPLATE.LAST]
row_dsc = [50, 50, 50, lv.COORD.MAX] row_dsc = [50, 50, 50, lv.GRID_TEMPLATE.LAST]
# Create a container with grid # Create a container with grid
cont = lv.obj(lv.scr_act()) cont = lv.obj(lv.scr_act())

View File

@@ -1,5 +1,3 @@
def LV_GRID_FR(x):
return lv.COORD.MAX - 100 + x
# #
# Demonstrate grid's "free unit" # Demonstrate grid's "free unit"
# #
@@ -8,13 +6,13 @@ def LV_GRID_FR(x):
# Column 2: 1 unit from the remaining free space # Column 2: 1 unit from the remaining free space
# Column 3: 2 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 1: fix width 60 px
# Row 2: 1 unit from the remaining free space # Row 2: 1 unit from the remaining free space
# Row 3: fix width 60 px # 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 # Create a container with grid
cont = lv.obj(lv.scr_act()) cont = lv.obj(lv.scr_act())