luat_lib_lvgl_tileview_ex.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. @module lvgl
  3. @summary LVGL图像库
  4. @version 1.0
  5. @date 2021.06.01
  6. */
  7. #include "luat_base.h"
  8. #include "lvgl.h"
  9. #include "luat_lvgl.h"
  10. #include "luat_mem.h"
  11. int luat_lv_tileview_set_valid_positions(lua_State *L) {
  12. LV_DEBUG("CALL lv_tileview_set_valid_positions");
  13. lv_obj_t* tileview = (lv_obj_t*)lua_touserdata(L, 1);
  14. uint16_t valid_pos_cnt = (uint16_t)luaL_checkinteger(L, 3);
  15. lv_point_t *valid_pos = (lv_point_t*)luat_heap_calloc(valid_pos_cnt,sizeof(lv_point_t));
  16. if (lua_istable(L,2)){
  17. for (int m = 0; m < valid_pos_cnt; m++) {
  18. lua_pushinteger(L, m+1);
  19. if (LUA_TTABLE == lua_gettable(L, 2)) {
  20. lua_geti(L,-1,1);
  21. valid_pos[m].x=luaL_checkinteger(L,-1);
  22. lua_pop(L, 1);
  23. lua_geti(L,-1,2);
  24. valid_pos[m].y=luaL_checkinteger(L,-1);
  25. lua_pop(L, 1);
  26. }
  27. lua_pop(L, 1);
  28. }
  29. }
  30. lv_tileview_set_valid_positions(tileview,valid_pos,valid_pos_cnt);
  31. //luat_heap_free(valid_pos);
  32. return 0;
  33. }