luat_lib_gtfont.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. @module gtfont
  3. @summary 高通字库芯片
  4. @version 1.0
  5. @date 2021.11.11
  6. @tag LUAT_USE_GTFONT
  7. @usage
  8. -- 已测试字体芯片型号 GT5SLCD1E-1A
  9. -- 如需要支持其他型号,请报issue
  10. */
  11. #include "luat_base.h"
  12. #include "luat_spi.h"
  13. #include "luat_lcd.h"
  14. #include "luat_mem.h"
  15. #include "luat_gtfont.h"
  16. #define LUAT_LOG_TAG "gt"
  17. #include "luat_log.h"
  18. /**
  19. 初始化高通字体芯片
  20. @api gtfont.init(spi_device)
  21. @userdata 仅支持spi device 生成的指针数据
  22. @return boolean 成功返回true,否则返回false
  23. @usage
  24. -- 特别提醒: 使用本库的任何代码,都需要额外的高通字体芯片 !!
  25. -- 没有额外芯片是跑不了的!!
  26. gtfont.init(spi_device)
  27. */
  28. static int l_gtfont_init(lua_State* L) {
  29. if (gt_spi_dev == NULL) {
  30. gt_spi_dev = lua_touserdata(L, 1);
  31. }
  32. const char data = 0xff;
  33. luat_spi_device_send(gt_spi_dev, &data, 1);
  34. int font_init = GT_Font_Init();
  35. // LLOGD("font_init:%d",font_init);
  36. lua_pushboolean(L, font_init > 0 ? 1 : 0);
  37. return 1;
  38. }
  39. #include "rotable2.h"
  40. static const rotable_Reg_t reg_gtfont[] =
  41. {
  42. { "init" , ROREG_FUNC(l_gtfont_init)},
  43. { NULL, ROREG_INT(0)}
  44. };
  45. LUAMOD_API int luaopen_gtfont( lua_State *L ) {
  46. luat_newlib2(L, reg_gtfont);
  47. return 1;
  48. }