luat_lib_lvgl_line_ex.c 1.0 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_malloc.h"
  11. int luat_lv_line_set_points(lua_State *L) {
  12. LV_DEBUG("CALL lv_line_set_points");
  13. lv_obj_t* line = (lv_obj_t*)lua_touserdata(L, 1);
  14. uint16_t point_num = (uint16_t)luaL_checkinteger(L, 3);
  15. lv_point_t *point_a = (lv_point_t*)luat_heap_calloc(point_num,sizeof(lv_point_t));
  16. if (lua_istable(L,2)){
  17. for (int m = 0; m < point_num; m++) {
  18. lua_pushinteger(L, m+1);
  19. if (LUA_TTABLE == lua_gettable(L, 2)) {
  20. lua_geti(L,-1,1);
  21. point_a[m].x=luaL_checkinteger(L,-1);
  22. lua_pop(L, 1);
  23. lua_geti(L,-1,2);
  24. point_a[m].y=luaL_checkinteger(L,-1);
  25. lua_pop(L, 1);
  26. }
  27. lua_pop(L, 1);
  28. }
  29. }
  30. lv_line_set_points(line,point_a,point_num);
  31. //luat_heap_free(point_a);
  32. return 0;
  33. }