luat_airui_block_lvgl_button.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "luat_base.h"
  2. #include "luat_airui.h"
  3. #include "luat_malloc.h"
  4. #define LUAT_LOG_TAG "airui"
  5. #include "luat_log.h"
  6. // #include "lv_btn.h"
  7. int airui_block_lvgl_button_cb(airui_block_t *bl) {
  8. //LLOGD("create btn");
  9. lv_obj_t *parent = (lv_obj_t*)bl->parent;
  10. lv_obj_t *obj = lv_btn_create(parent, NULL);
  11. bl->self = obj;
  12. //---------------------------------------
  13. // 取comConf
  14. int comConf_pos = jsmn_find_by_key(bl->ctx->data, "comConf", bl->tok, bl->schema_pos + 1);
  15. if (comConf_pos < 1) {
  16. LLOGD("schema without comConf");
  17. return 0;
  18. }
  19. // -----------------------------------
  20. // 设置text 属性
  21. /*
  22. int text_pos = jsmn_find_by_key(bl->ctx->data, "text", bl->tok, comConf_pos + 1);
  23. if (text_pos < 1) {
  24. LLOGD("label without text");
  25. return 0;
  26. }
  27. c_str_t text = {.len = 0};
  28. jsmn_get_string(bl->ctx->data, bl->tok, text_pos + 1, &text);
  29. char* buff = luat_heap_malloc(text.len + 1);
  30. // TODO 检查buff是否为NULL
  31. memcpy(buff, text.ptr, text.len);
  32. buff[text.len] = 0;
  33. lv_btn_set_text(obj, buff);
  34. luat_heap_free(buff);
  35. */
  36. return 0;
  37. }