Instead of re-implementing LV_GRID_FR, use lv.grid_fr Also use lv.GRID_TEMPLATE.LAST instead of lv.COORD.MAX where needed