luat_lib_eink.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  1. /*
  2. @module eink
  3. @summary 墨水屏操作库
  4. @version 1.0
  5. @date 2020.11.14
  6. @demo eink
  7. */
  8. #include "luat_base.h"
  9. #include "luat_log.h"
  10. #include "luat_sys.h"
  11. #include "luat_msgbus.h"
  12. #include "luat_timer.h"
  13. #include "luat_malloc.h"
  14. #include "luat_spi.h"
  15. #include "luat_gpio.h"
  16. // #include "epd1in54.h"
  17. // #include "epd2in9.h"
  18. #include "epd.h"
  19. #include "epdpaint.h"
  20. #include "imagedata.h"
  21. #include "qrcodegen.h"
  22. #include <stdlib.h>
  23. #include "u8g2.h"
  24. #include "u8g2_luat_fonts.h"
  25. #include "luat_zbuff.h"
  26. #include "luat_ufont.h"
  27. static const lv_font_t* font_current;
  28. static size_t epd_w = 0;
  29. static size_t epd_h = 0;
  30. #define COLORED 0
  31. #define UNCOLORED 1
  32. #ifndef LUAT_LOG_TAG
  33. #define LUAT_LOG_TAG "eink"
  34. #endif
  35. typedef struct eink_ctx
  36. {
  37. uint32_t str_color;
  38. Paint paint;
  39. uint8_t fb[];
  40. }eink_ctx_t;
  41. static uint32_t ctx_index = 0;
  42. static eink_ctx_t *ctxs[2]; // 暂时只支持2种颜色, 有需要的话后续继续加
  43. // static u8g2_t luat_eink_u8g2;
  44. static void (eink_ui_draw_point)(void* userdata, int x, int y, uint32_t color) {
  45. Paint_DrawPixel(&ctxs[ctx_index]->paint, x, y, color);
  46. }
  47. static void (eink_ui_draw_line)(void* userdata, int x1, int y1, int x2, int y2, uint32_t color) {
  48. Paint_DrawLine(&ctxs[ctx_index]->paint, x1, y1, x2, y2, color);
  49. }
  50. static void (eink_ui_draw_block)(void* userdata, int x, int y, int w, int h, size_t bitw, void* data) {
  51. LLOGD("lcd_ui_draw_block NOT support yet");
  52. }
  53. static void (eink_ui_draw_fill)(void* userdata, int x, int y, int w, int h, uint32_t color) {
  54. Paint_DrawFilledRectangle(&ctxs[ctx_index]->paint, x, y, x+w, y+h, color);
  55. }
  56. static void (eink_ui_draw_flush)(void* userdata) {
  57. // TODO
  58. };
  59. const ui_draw_opts_t eink_ui_opts = {
  60. .draw_point = eink_ui_draw_point,
  61. .draw_line = eink_ui_draw_line,
  62. .draw_block = eink_ui_draw_block,
  63. .draw_fill = eink_ui_draw_fill,
  64. .draw_flush = eink_ui_draw_flush
  65. };
  66. eink_conf_t econf = {0};
  67. #define Pin_BUSY (econf.busy_pin)
  68. #define Pin_RES (econf.res_pin)
  69. #define Pin_DC (econf.dc_pin)
  70. #define Pin_CS (econf.cs_pin)
  71. #define SPI_ID (econf.spi_id)
  72. static int check_init(void) {
  73. if (ctxs[0] == NULL) {
  74. LLOGW("eink NOT init yet");
  75. return 0;
  76. }
  77. return 1;
  78. }
  79. /**
  80. 初始化eink
  81. @api eink.setup(full, spiid, pin_busy, pin_reset, pin_dc, pin_cs)
  82. @int 全屏刷新0,局部刷新1,默认是全屏刷新
  83. @int 所在的spi,默认是0
  84. @int Busy 忙信号管脚
  85. @int Reset 复位管脚
  86. @int DC 数据命令选择管脚
  87. @int CS 使能管脚
  88. @return boolean 成功返回true,否则返回false
  89. */
  90. static int l_eink_setup(lua_State *L) {
  91. int status = 0;
  92. econf.full_mode = luaL_optinteger(L, 1, 1);
  93. econf.spi_id = luaL_optinteger(L, 2, 0);
  94. econf.busy_pin = luaL_optinteger(L, 3, 18);
  95. econf.res_pin = luaL_optinteger(L, 4, 7);
  96. econf.dc_pin = luaL_optinteger(L, 5, 9);
  97. econf.cs_pin = luaL_optinteger(L, 6, 16);
  98. if (lua_type(L, 7) == LUA_TUSERDATA){
  99. //LLOGD("luat_spi_device_send");
  100. econf.userdata = (luat_spi_device_t*)lua_touserdata(L, 3);
  101. econf.port = LUAT_EINK_SPI_DEVICE;
  102. luat_gpio_mode(Pin_BUSY, Luat_GPIO_INPUT, Luat_GPIO_PULLUP, Luat_GPIO_LOW);
  103. luat_gpio_mode(Pin_RES, Luat_GPIO_OUTPUT, Luat_GPIO_PULLUP, Luat_GPIO_LOW);
  104. luat_gpio_mode(Pin_DC, Luat_GPIO_OUTPUT, Luat_GPIO_PULLUP, Luat_GPIO_LOW);
  105. status = 0;
  106. }else{
  107. //LLOGD("luat_spi_send");
  108. luat_spi_t spi_config = {0};
  109. spi_config.bandrate = 2000000U;//luaL_optinteger(L, 1, 2000000U); // 2000000U
  110. spi_config.id = SPI_ID;
  111. spi_config.cs = 255; // 默认无
  112. spi_config.CPHA = 0; // CPHA0
  113. spi_config.CPOL = 0; // CPOL0
  114. spi_config.dataw = 8; // 8bit
  115. spi_config.bit_dict = 1; // MSB=1, LSB=0
  116. spi_config.master = 1; // master=1,slave=0
  117. spi_config.mode = 1; // FULL=1, half=0
  118. //先关了再开一遍
  119. luat_spi_close(spi_config.id);
  120. //LLOGD("setup GPIO for epd");
  121. status = luat_spi_setup(&spi_config);
  122. luat_gpio_mode(Pin_BUSY, Luat_GPIO_INPUT, Luat_GPIO_PULLUP, Luat_GPIO_LOW);
  123. luat_gpio_mode(Pin_RES, Luat_GPIO_OUTPUT, Luat_GPIO_PULLUP, Luat_GPIO_LOW);
  124. luat_gpio_mode(Pin_DC, Luat_GPIO_OUTPUT, Luat_GPIO_PULLUP, Luat_GPIO_LOW);
  125. luat_gpio_mode(Pin_CS, Luat_GPIO_OUTPUT, Luat_GPIO_PULLUP, Luat_GPIO_LOW);
  126. }
  127. if (status != 0) {
  128. LLOGD("spi setup fail, eink init fail");
  129. return 0;
  130. }
  131. size_t colors = 0;
  132. if(status == 0)
  133. {
  134. if(econf.full_mode)
  135. status = EPD_Init(1, &epd_w, &epd_h, &colors);
  136. else
  137. status = EPD_Init(0, &epd_w, &epd_h, &colors);
  138. if (status != 0) {
  139. LLOGD("e-Paper init failed");
  140. return 0;
  141. }
  142. LLOGD("spi setup complete, now setup epd");
  143. if (colors > 2) {
  144. LLOGE("only 2 color eink supported yet");
  145. return 0;
  146. }
  147. for (size_t i = 0; i < colors; i++)
  148. {
  149. ctxs[i] = luat_heap_malloc( sizeof(eink_ctx_t) + (epd_w * epd_h + 7) / 8);
  150. if (ctxs[i] == NULL) {
  151. LLOGE("out of memory when malloc buff for eink");
  152. for (size_t j = 0; j < i - 1; j++)
  153. {
  154. luat_heap_free(ctxs[i]);
  155. ctxs[i] = NULL;
  156. }
  157. return 0;
  158. }
  159. Paint_Init(&ctxs[i]->paint, ctxs[i]->fb, epd_w, epd_h);
  160. Paint_Clear(&ctxs[i]->paint, UNCOLORED);
  161. ctxs[i]->paint.inited = 1;
  162. }
  163. }
  164. font_current = luat_fonts_default_font();
  165. lua_pushboolean(L, 1);
  166. return 1;
  167. }
  168. /**
  169. 进入休眠模式,再次使用时需要重新初始化
  170. @api eink.sleep()
  171. */
  172. static int l_eink_sleep(lua_State *L)
  173. {
  174. EPD_Sleep();
  175. return 0;
  176. }
  177. /**
  178. 清除绘图缓冲区,默认不会马上刷新到设备
  179. @api eink.clear(color, force)
  180. @number color 可选,默认1。刷屏颜色
  181. @bool force 可选,默认false。如果为true则马上清屏
  182. @return nil 无返回值
  183. */
  184. static int l_eink_clear(lua_State *L)
  185. {
  186. int colored = luaL_optinteger(L, 1, 1);
  187. if (check_init() == 0)
  188. return 0;
  189. Paint_Clear(&ctxs[ctx_index]->paint, colored);
  190. if(lua_toboolean(L, 2))
  191. EPD_Clear();
  192. return 0;
  193. }
  194. /**
  195. 设置窗口
  196. @api eink.setWin(width, height, rotate)
  197. @int width 宽度
  198. @int height 高度
  199. @int rotate 显示方向,0/1/2/3, 相当于旋转0度/90度/180度/270度
  200. @return nil 无返回值
  201. */
  202. static int l_eink_setWin(lua_State *L)
  203. {
  204. int width = luaL_checkinteger(L, 1);
  205. int height = luaL_checkinteger(L, 2);
  206. int rotate = luaL_checkinteger(L, 3);
  207. if (check_init() == 0)
  208. return 0;
  209. Paint_SetWidth(&ctxs[ctx_index]->paint, width);
  210. Paint_SetHeight(&ctxs[ctx_index]->paint, height);
  211. Paint_SetRotate(&ctxs[ctx_index]->paint, rotate);
  212. return 0;
  213. }
  214. /**
  215. 获取窗口信息
  216. @api eink.getWin()
  217. @return int width 宽
  218. @return int height 高
  219. @return int rotate 旋转方向
  220. */
  221. static int l_eink_getWin(lua_State *L)
  222. {
  223. if (check_init() == 0)
  224. return 0;
  225. int width = Paint_GetWidth(&ctxs[ctx_index]->paint);
  226. int height = Paint_GetHeight(&ctxs[ctx_index]->paint);
  227. int rotate = Paint_GetRotate(&ctxs[ctx_index]->paint);
  228. lua_pushinteger(L, width);
  229. lua_pushinteger(L, height);
  230. lua_pushinteger(L, rotate);
  231. return 3;
  232. }
  233. static void drawFastHLine(Paint* conf,int16_t x, int16_t y, int16_t len, uint16_t color){
  234. Paint_DrawHorizontalLine(conf,x, y, len,color);
  235. }
  236. static void drawFastVLine(Paint* conf,int16_t x, int16_t y, int16_t len, uint16_t color){
  237. Paint_DrawVerticalLine(conf,x, y, len,color);
  238. }
  239. /**
  240. 设置字体
  241. @api eink.setFont(font)
  242. @userdata 字体
  243. @usage
  244. -- 设置为字体,对之后的print有效
  245. eink.setFont(eink.font_opposansm12_chinese)
  246. */
  247. static int l_eink_set_font(lua_State *L) {
  248. if (check_init() == 0) {
  249. return 0;
  250. }
  251. if (!lua_islightuserdata(L, 1)) {
  252. LLOGE("only font pointer is allow");
  253. return 0;
  254. }
  255. const uint8_t *ptr = (const uint8_t *)lua_touserdata(L, 1);
  256. if (ptr == NULL) {
  257. LLOGE("only font pointer is allow");
  258. return 0;
  259. }
  260. font_current = (lv_font_t*)ptr;
  261. lua_pushboolean(L, 1);
  262. return 1;
  263. }
  264. /**
  265. 绘制字符串
  266. @api eink.print(x, y, str, colored)
  267. @int x坐标
  268. @int y坐标
  269. @string 字符串
  270. @int 颜色, 可以是0或者1, 默认是0
  271. @return nil 无返回值
  272. @usage
  273. -- 先设置字体, 然后写字
  274. -- 可用字体取决于具体的固件, 如果没有你想要的大小,可以云编译一份自定义固件
  275. -- font_opposansm8_chinese
  276. -- font_opposansm10_chinese
  277. -- font_opposansm12_chinese
  278. -- font_opposansm14_chinese
  279. -- font_opposansm16_chinese
  280. eink.setFont(eink.font_opposansm12_chinese)
  281. eink.print(10, 20, "LuatOS")
  282. */
  283. static int l_eink_print(lua_State *L)
  284. {
  285. int x, y;
  286. size_t sz;
  287. const char* str;
  288. x = luaL_checkinteger(L, 1);
  289. y = luaL_checkinteger(L, 2);
  290. str = (const char*)luaL_checklstring(L, 3, &sz);
  291. if (sz == 0)
  292. return 0;
  293. ui_draw_str_ctx_t ctx = {
  294. .font = font_current,
  295. .bg_color = 0,
  296. .front_color = 1, // Colored? 会不会写反了
  297. .draw_mode = 0,
  298. .opts = eink_ui_opts,
  299. .ui_h = epd_h,
  300. .ui_w = epd_w,
  301. .x = x,
  302. .y = y,
  303. .utf8_letters = str,
  304. .userdata = NULL,
  305. };
  306. int ret = luat_ufont_drawUTF8(&ctx);
  307. lua_pushinteger(L, ret);
  308. return 0;
  309. }
  310. /**
  311. 将缓冲区图像输出到屏幕
  312. @api eink.show(x, y, noClear)
  313. @int x 输出的x坐标,默认0
  314. @int y 输出的y坐标,默认0
  315. @bool 可选,默认false。如果为true则不进行清屏,直接刷上新内容
  316. @return nil 无返回值
  317. */
  318. static int l_eink_show(lua_State *L)
  319. {
  320. // int x = luaL_optinteger(L, 1, 0);
  321. // int y = luaL_optinteger(L, 2, 0);
  322. int no_clear = lua_toboolean(L, 3);
  323. /* Display the frame_buffer */
  324. //EPD_SetFrameMemory(&epd, frame_buffer, x, y, Paint_GetWidth(&ctxs[ctx_index]->paint), Paint_GetHeight(&ctxs[ctx_index]->paint));
  325. //EPD_DisplayFrame(&epd);
  326. if (check_init() == 0) {
  327. return 0;
  328. }
  329. if(!no_clear)
  330. EPD_Clear();
  331. if (ctxs[1] == NULL)
  332. EPD_Display(ctxs[0]->fb, NULL);
  333. else
  334. EPD_Display(ctxs[0]->fb, ctxs[1]->fb);
  335. return 0;
  336. }
  337. /**
  338. 直接输出数据到屏幕,支持双色数据
  339. @api eink.draw(buff, buff2, noclear)
  340. @userdata zbuff指针
  341. @userdata zbuff指针
  342. @bool 可选,默认false。如果为true则不进行清屏,直接刷上新内容
  343. @return nil 无返回值
  344. */
  345. static int l_eink_draw(lua_State *L)
  346. {
  347. luat_zbuff_t* buff = tozbuff(L);
  348. luat_zbuff_t* buff2 = buff;
  349. int no_clear = lua_toboolean(L, 3);
  350. if (lua_isuserdata(L, 2)) {
  351. buff2 = ((luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE));
  352. }
  353. if (check_init() == 0) {
  354. return 0;
  355. }
  356. if(!no_clear)
  357. EPD_Clear();
  358. EPD_Display(buff->addr, buff2->addr);
  359. return 0;
  360. }
  361. /**
  362. 缓冲区绘制线
  363. @api eink.line(x, y, x2, y2, colored)
  364. @int 起点x坐标
  365. @int 起点y坐标
  366. @int 终点x坐标
  367. @int 终点y坐标
  368. @return nil 无返回值
  369. @usage
  370. eink.line(0, 0, 10, 20, 0)
  371. */
  372. static int l_eink_line(lua_State *L)
  373. {
  374. int x = luaL_checkinteger(L, 1);
  375. int y = luaL_checkinteger(L, 2);
  376. int x2 = luaL_checkinteger(L, 3);
  377. int y2 = luaL_checkinteger(L, 4);
  378. int colored = luaL_optinteger(L, 5, 0);
  379. if (check_init() == 0) {
  380. return 0;
  381. }
  382. Paint_DrawLine(&ctxs[ctx_index]->paint, x, y, x2, y2, colored);
  383. return 0;
  384. }
  385. /**
  386. 缓冲区绘制矩形
  387. @api eink.rect(x, y, x2, y2, colored, fill)
  388. @int 左上顶点x坐标
  389. @int 左上顶点y坐标
  390. @int 右下顶点x坐标
  391. @int 右下顶点y坐标
  392. @int 默认是0
  393. @int 是否填充,默认是0,不填充
  394. @return nil 无返回值
  395. @usage
  396. eink.rect(0, 0, 10, 20)
  397. eink.rect(0, 0, 10, 20, 1) -- Filled
  398. */
  399. static int l_eink_rect(lua_State *L)
  400. {
  401. int x = luaL_checkinteger(L, 1);
  402. int y = luaL_checkinteger(L, 2);
  403. int x2 = luaL_checkinteger(L, 3);
  404. int y2 = luaL_checkinteger(L, 4);
  405. int colored = luaL_optinteger(L, 5, 0);
  406. int fill = luaL_optinteger(L, 6, 0);
  407. if (check_init() == 0) {
  408. return 0;
  409. }
  410. if(fill)
  411. Paint_DrawFilledRectangle(&ctxs[ctx_index]->paint, x, y, x2, y2, colored);
  412. else
  413. Paint_DrawRectangle(&ctxs[ctx_index]->paint, x, y, x2, y2, colored);
  414. return 0;
  415. }
  416. /**
  417. 缓冲区绘制圆形
  418. @api eink.circle(x, y, radius, colored, fill)
  419. @int 圆心x坐标
  420. @int 圆心y坐标
  421. @int 半径
  422. @int 默认是0
  423. @int 是否填充,默认是0,不填充
  424. @return nil 无返回值
  425. @usage
  426. eink.circle(0, 0, 10)
  427. eink.circle(0, 0, 10, 1, 1) -- Filled
  428. */
  429. static int l_eink_circle(lua_State *L)
  430. {
  431. int x = luaL_checkinteger(L, 1);
  432. int y = luaL_checkinteger(L, 2);
  433. int radius = luaL_checkinteger(L, 3);
  434. int colored = luaL_optinteger(L, 4, 0);
  435. int fill = luaL_optinteger(L, 5, 0);
  436. if (check_init() == 0) {
  437. return 0;
  438. }
  439. if(fill)
  440. Paint_DrawFilledCircle(&ctxs[ctx_index]->paint, x, y, radius, colored);
  441. else
  442. Paint_DrawCircle(&ctxs[ctx_index]->paint, x, y, radius, colored);
  443. return 0;
  444. }
  445. /**
  446. 缓冲区绘制QRCode
  447. @api eink.qrcode(x, y, str, size)
  448. @int x坐标
  449. @int y坐标
  450. @string 二维码的内容
  451. @int 可选,显示大小,不可小于21,默认21
  452. @return nil 无返回值
  453. */
  454. static int l_eink_qrcode(lua_State *L)
  455. {
  456. size_t len;
  457. int x = luaL_checkinteger(L, 1);
  458. int y = luaL_checkinteger(L, 2);
  459. const char* text = luaL_checklstring(L, 3, &len);
  460. int size = luaL_optinteger(L, 4,21);
  461. if (check_init() == 0) {
  462. return 0;
  463. }
  464. uint8_t *qrcode = luat_heap_malloc(qrcodegen_BUFFER_LEN_MAX);
  465. uint8_t *tempBuffer = luat_heap_malloc(qrcodegen_BUFFER_LEN_MAX);
  466. if (qrcode == NULL || tempBuffer == NULL) {
  467. if (qrcode)
  468. luat_heap_free(qrcode);
  469. if (tempBuffer)
  470. luat_heap_free(tempBuffer);
  471. LLOGE("qrcode out of memory");
  472. return 0;
  473. }
  474. bool ok = qrcodegen_encodeText(text, tempBuffer, qrcode, qrcodegen_Ecc_MEDIUM,
  475. qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true);
  476. if (ok){
  477. int qr_size = qrcodegen_getSize(qrcode);
  478. int scale = size / qr_size ;
  479. int margin = (size - qr_size * scale) / 2;
  480. x+=margin;
  481. y+=margin;
  482. for (int j = 0; j < qr_size; j++) {
  483. for (int i = 0; i < qr_size; i++) {
  484. if (qrcodegen_getModule(qrcode, i, j))
  485. Paint_DrawFilledRectangle(&ctxs[ctx_index]->paint,x+i*scale,y+j*scale,x+(i+1)*scale,y+(j+1)*scale,0);
  486. }
  487. }
  488. }
  489. if (qrcode)
  490. luat_heap_free(qrcode);
  491. if (tempBuffer)
  492. luat_heap_free(tempBuffer);
  493. return 0;
  494. }
  495. /**
  496. 缓冲区绘制电池
  497. @api eink.bat(x, y, bat)
  498. @int x坐标
  499. @int y坐标
  500. @int 电池电压,单位毫伏
  501. @return nil 无返回值
  502. */
  503. static int l_eink_bat(lua_State *L)
  504. {
  505. int x = luaL_checkinteger(L, 1);
  506. int y = luaL_checkinteger(L, 2);
  507. int bat = luaL_checkinteger(L, 3);
  508. int batnum = 0;
  509. // eink.rect(0, 3, 2, 6)
  510. // eink.rect(2, 0, 20, 9)
  511. // eink.rect(9, 1, 19, 8, 0, 1)
  512. if(bat < 4200 && bat > 4080)batnum = 100;
  513. if(bat < 4080 && bat > 4000)batnum = 90;
  514. if(bat < 4000 && bat > 3930)batnum = 80;
  515. if(bat < 3930 && bat > 3870)batnum = 70;
  516. if(bat < 3870 && bat > 3820)batnum = 60;
  517. if(bat < 3820 && bat > 3790)batnum = 50;
  518. if(bat < 3790 && bat > 3770)batnum = 40;
  519. if(bat < 3770 && bat > 3730)batnum = 30;
  520. if(bat < 3730 && bat > 3700)batnum = 20;
  521. if(bat < 3700 && bat > 3680)batnum = 15;
  522. if(bat < 3680 && bat > 3500)batnum = 10;
  523. if(bat < 3500 && bat > 2500)batnum = 5;
  524. batnum = 20 - (int)(batnum / 5) + 3;
  525. if (check_init() == 0) {
  526. return 0;
  527. }
  528. // w外框
  529. Paint_DrawRectangle(&ctxs[ctx_index]->paint, x+0, y+3, x+2, y+6, COLORED);
  530. Paint_DrawRectangle(&ctxs[ctx_index]->paint, x+2, y+0, x+23, y+9, COLORED);
  531. // 3 ~21 100 / 5
  532. Paint_DrawFilledRectangle(&ctxs[ctx_index]->paint, x+batnum, y+1, x+22, y+8, COLORED);
  533. return 0;
  534. }
  535. /**
  536. 缓冲区绘制天气图标
  537. @api eink.weather_icon(x, y, code)
  538. @int x坐标
  539. @int y坐标
  540. @int 天气代号
  541. @return nil 无返回值
  542. */
  543. static int l_eink_weather_icon(lua_State *L)
  544. {
  545. size_t len;
  546. int x = luaL_checkinteger(L, 1);
  547. int y = luaL_checkinteger(L, 2);
  548. int code = luaL_checkinteger(L, 3);
  549. const char* str = luaL_optlstring(L, 4, "nil", &len);
  550. const unsigned char * icon = gImage_999;
  551. if (strcmp(str, "xue") == 0)code = 401;
  552. if (strcmp(str, "lei") == 0)code = 302;
  553. if (strcmp(str, "shachen") == 0)code = 503;
  554. if (strcmp(str, "wu") == 0)code = 501;
  555. if (strcmp(str, "bingbao") == 0)code = 504;
  556. if (strcmp(str, "yun") == 0)code = 103;
  557. if (strcmp(str, "yu") == 0)code = 306;
  558. if (strcmp(str, "yin") == 0)code = 101;
  559. if (strcmp(str, "qing") == 0)code = 100;
  560. // xue、lei、shachen、wu、bingbao、yun、yu、yin、qing
  561. //if(code == 64)
  562. // for(int i = 0; i < 64; i++)
  563. // {
  564. // for (int j = 0; j < 8; j++)
  565. // {
  566. // for (int k = 0; k < 8; k++)
  567. // (gImage_103[i*8+j] << k )& 0x80 ? Paint_DrawPixel(&ctxs[ctx_index]->paint, x+j*8+k, y+i, COLORED) : Paint_DrawPixel(&ctxs[ctx_index]->paint, x+j*8+k, y+i, UNCOLORED);
  568. // }
  569. // }
  570. if (check_init() == 0) {
  571. return 0;
  572. }
  573. switch (code)
  574. {
  575. case 100:icon = gImage_100;break;
  576. case 101:icon = gImage_101;break;
  577. case 102:icon = gImage_102;break;
  578. case 103:icon = gImage_103;break;
  579. case 104:icon = gImage_104;break;
  580. case 200:icon = gImage_200;break;
  581. case 201:icon = gImage_201;break;
  582. case 205:icon = gImage_205;break;
  583. case 208:icon = gImage_208;break;
  584. case 301:icon = gImage_301;break;
  585. case 302:icon = gImage_302;break;
  586. case 303:icon = gImage_303;break;
  587. case 304:icon = gImage_304;break;
  588. case 305:icon = gImage_305;break;
  589. case 306:icon = gImage_306;break;
  590. case 307:icon = gImage_307;break;
  591. case 308:icon = gImage_308;break;
  592. case 309:icon = gImage_309;break;
  593. case 310:icon = gImage_310;break;
  594. case 311:icon = gImage_311;break;
  595. case 312:icon = gImage_312;break;
  596. case 313:icon = gImage_313;break;
  597. case 400:icon = gImage_400;break;
  598. case 401:icon = gImage_401;break;
  599. case 402:icon = gImage_402;break;
  600. case 403:icon = gImage_403;break;
  601. case 404:icon = gImage_404;break;
  602. case 405:icon = gImage_405;break;
  603. case 406:icon = gImage_406;break;
  604. case 407:icon = gImage_407;break;
  605. case 500:icon = gImage_500;break;
  606. case 501:icon = gImage_501;break;
  607. case 502:icon = gImage_502;break;
  608. case 503:icon = gImage_503;break;
  609. case 504:icon = gImage_504;break;
  610. case 507:icon = gImage_507;break;
  611. case 508:icon = gImage_508;break;
  612. case 900:icon = gImage_900;break;
  613. case 901:icon = gImage_901;break;
  614. case 999:icon = gImage_999;break;
  615. default:
  616. break;
  617. }
  618. for(int i = 0; i < 48; i++)
  619. {
  620. for (int j = 0; j < 6; j++)
  621. {
  622. for (int k = 0; k < 8; k++)
  623. (icon[i*6+j] << k )& 0x80 ? Paint_DrawPixel(&ctxs[ctx_index]->paint, x+j*8+k, y+i, COLORED) : Paint_DrawPixel(&ctxs[ctx_index]->paint, x+j*8+k, y+i, UNCOLORED);
  624. }
  625. }
  626. return 0;
  627. }
  628. /**
  629. 设置墨水屏驱动型号
  630. @api eink.model(m)
  631. @int 型号名称, 例如 eink.model(eink.MODEL_1in54_V2)
  632. @return nil 无返回值
  633. */
  634. static int l_eink_model(lua_State *L) {
  635. EPD_Model(luaL_checkinteger(L, 1));
  636. return 0;
  637. }
  638. #ifdef LUAT_USE_GTFONT
  639. #include "GT5SLCD2E_1A.h"
  640. extern void gtfont_draw_w(unsigned char *pBits,unsigned int x,unsigned int y,unsigned int widt,unsigned int high,int(*point)(void*),void* userdata,int mode);
  641. extern void gtfont_draw_gray_hz(unsigned char *data,unsigned short x,unsigned short y,unsigned short w ,unsigned short h,unsigned char grade, unsigned char HB_par,int(*point)(void*,uint16_t, uint16_t, uint32_t),void* userdata,int mode);
  642. static int l_eink_draw_gtfont_gb2312(lua_State *L) {
  643. unsigned char buf[128];
  644. int len;
  645. int i = 0;
  646. uint8_t strhigh,strlow ;
  647. uint16_t str;
  648. const char *fontCode = luaL_checklstring(L, 1,&len);
  649. unsigned char size = luaL_checkinteger(L, 2);
  650. int x = luaL_checkinteger(L, 3);
  651. int y = luaL_checkinteger(L, 4);
  652. while ( i < len){
  653. strhigh = *fontCode;
  654. fontCode++;
  655. strlow = *fontCode;
  656. str = (strhigh<<8)|strlow;
  657. fontCode++;
  658. get_font(buf, 1, str, size, size, size);
  659. gtfont_draw_w(buf , x ,y , size , size,Paint_DrawPixel,&ctxs[ctx_index]->paint,1);
  660. x+=size;
  661. i+=2;
  662. }
  663. return 0;
  664. }
  665. static int l_eink_draw_gtfont_gb2312_gray(lua_State* L) {
  666. unsigned char buf[2048];
  667. int len;
  668. int i = 0;
  669. uint8_t strhigh,strlow ;
  670. uint16_t str;
  671. const char *fontCode = luaL_checklstring(L, 1,&len);
  672. unsigned char size = luaL_checkinteger(L, 2);
  673. unsigned char font_g = luaL_checkinteger(L, 3);
  674. int x = luaL_checkinteger(L, 4);
  675. int y = luaL_checkinteger(L, 5);
  676. while ( i < len){
  677. strhigh = *fontCode;
  678. fontCode++;
  679. strlow = *fontCode;
  680. str = (strhigh<<8)|strlow;
  681. fontCode++;
  682. get_font(buf, 1, str, size*font_g, size*font_g, size*font_g);
  683. Gray_Process(buf,size,size,font_g);
  684. gtfont_draw_gray_hz(buf, x, y, size , size, font_g, 1,Paint_DrawPixel,&ctxs[ctx_index]->paint,1);
  685. x+=size;
  686. i+=2;
  687. }
  688. return 0;
  689. }
  690. #ifdef LUAT_USE_GTFONT_UTF8
  691. extern unsigned short unicodetogb2312 ( unsigned short chr);
  692. static int l_eink_draw_gtfont_utf8(lua_State *L) {
  693. unsigned char buf[128];
  694. int len;
  695. int i = 0;
  696. uint8_t strhigh,strlow ;
  697. uint16_t e,str;
  698. const char *fontCode = luaL_checklstring(L, 1,&len);
  699. unsigned char size = luaL_checkinteger(L, 2);
  700. int x = luaL_checkinteger(L, 3);
  701. int y = luaL_checkinteger(L, 4);
  702. for(;;){
  703. e = utf8_next((uint8_t)*fontCode);
  704. if ( e == 0x0ffff )
  705. break;
  706. fontCode++;
  707. if ( e != 0x0fffe ){
  708. uint16_t str = unicodetogb2312(e);
  709. get_font(buf, 1, str, size, size, size);
  710. gtfont_draw_w(buf , x ,y , size , size,Paint_DrawPixel,&ctxs[ctx_index]->paint,1);
  711. x+=size;
  712. }
  713. }
  714. return 0;
  715. }
  716. static int l_eink_draw_gtfont_utf8_gray(lua_State* L) {
  717. unsigned char buf[2048];
  718. int len;
  719. int i = 0;
  720. uint8_t strhigh,strlow ;
  721. uint16_t e,str;
  722. const char *fontCode = luaL_checklstring(L, 1,&len);
  723. unsigned char size = luaL_checkinteger(L, 2);
  724. unsigned char font_g = luaL_checkinteger(L, 3);
  725. int x = luaL_checkinteger(L, 4);
  726. int y = luaL_checkinteger(L, 5);
  727. for(;;){
  728. e = utf8_next((uint8_t)*fontCode);
  729. if ( e == 0x0ffff )
  730. break;
  731. fontCode++;
  732. if ( e != 0x0fffe ){
  733. uint16_t str = unicodetogb2312(e);
  734. get_font(buf, 1, str, size*font_g, size*font_g, size*font_g);
  735. Gray_Process(buf,size,size,font_g);
  736. gtfont_draw_gray_hz(buf, x, y, size , size, font_g, 1,Paint_DrawPixel,&ctxs[ctx_index]->paint,1);
  737. x+=size;
  738. }
  739. }
  740. return 0;
  741. }
  742. #endif // LUAT_USE_GTFONT_UTF8
  743. #endif // LUAT_USE_GTFONT
  744. static void eink_DrawHXBM(uint16_t x, uint16_t y, uint16_t len, const uint8_t *b){
  745. uint8_t mask = 1;
  746. if (check_init() == 0) {
  747. return;
  748. }
  749. while(len > 0) {
  750. if ( *b & mask ) drawFastHLine(&ctxs[ctx_index]->paint, x, y, 1,COLORED);
  751. else drawFastVLine(&ctxs[ctx_index]->paint, x, y, 1,UNCOLORED);
  752. x++;
  753. mask <<= 1;
  754. if ( mask == 0 ){
  755. mask = 1;
  756. b++;
  757. }
  758. len--;
  759. }
  760. }
  761. /*
  762. 绘制位图
  763. @api eink.drawXbm(x, y, w, h, data)
  764. @int X坐标
  765. @int y坐标
  766. @int 位图宽
  767. @int 位图高
  768. @int 位图数据,每一位代表一个像素
  769. @usage
  770. -- 取模使用PCtoLCD2002软件即可
  771. -- 在(0,0)为左上角,绘制 16x16 "今" 的位图
  772. eink.drawXbm(0, 0, 16,16, string.char(
  773. 0x80,0x00,0x80,0x00,0x40,0x01,0x20,0x02,0x10,0x04,0x48,0x08,0x84,0x10,0x83,0x60,
  774. 0x00,0x00,0xF8,0x0F,0x00,0x08,0x00,0x04,0x00,0x04,0x00,0x02,0x00,0x01,0x80,0x00
  775. ))
  776. */
  777. static int l_eink_drawXbm(lua_State *L){
  778. int x = luaL_checkinteger(L, 1);
  779. int y = luaL_checkinteger(L, 2);
  780. int w = luaL_checkinteger(L, 3);
  781. int h = luaL_checkinteger(L, 4);
  782. size_t len = 0;
  783. const char* data = luaL_checklstring(L, 5, &len);
  784. if (h < 1) return 0; // 行数必须大于0
  785. if (len*8/h < w) return 0; // 起码要填满一行
  786. if (len != h*w/8)return 0;
  787. if (check_init() == 0) {
  788. return 0;
  789. }
  790. uint8_t blen;
  791. blen = w;
  792. blen += 7;
  793. blen >>= 3;
  794. while( h > 0 ){
  795. eink_DrawHXBM(x, y, w, (const uint8_t*)data);
  796. data += blen;
  797. y++;
  798. h--;
  799. }
  800. lua_pushboolean(L, 1);
  801. return 1;
  802. }
  803. /*
  804. 切换颜色画板, 适合多色墨水屏
  805. @api eink.setCtx(index)
  806. @int 颜色索引, 黑色为0, 红色为1
  807. @usage
  808. -- 仅适合多色墨水屏, 对单色墨水屏(只有黑白)的无效
  809. eink.setCtx(1)
  810. -- 切换后, 所有drawXXX都会操作在指定颜色的画板
  811. */
  812. static int l_eink_set_ctx(lua_State *L) {
  813. int index = luaL_checkinteger(L, 1);
  814. if (index < 0 || index > 1) {
  815. LLOGE("invaild ctx index %d", index);
  816. return 0;
  817. }
  818. if (ctxs[index] == NULL) {
  819. LLOGE("invaild ctx index %d", index);
  820. return 0;
  821. }
  822. ctx_index = index;
  823. lua_pushboolean(L, 1);
  824. return 1;
  825. }
  826. #include "rotable2.h"
  827. static const rotable_Reg_t reg_eink[] =
  828. {
  829. { "setup", ROREG_FUNC(l_eink_setup)},
  830. { "sleep", ROREG_FUNC(l_eink_sleep)},
  831. { "clear", ROREG_FUNC(l_eink_clear)},
  832. { "setWin", ROREG_FUNC(l_eink_setWin)},
  833. { "getWin", ROREG_FUNC(l_eink_getWin)},
  834. { "print", ROREG_FUNC(l_eink_print)},
  835. { "show", ROREG_FUNC(l_eink_show)},
  836. { "rect", ROREG_FUNC(l_eink_rect)},
  837. { "circle", ROREG_FUNC(l_eink_circle)},
  838. { "line", ROREG_FUNC(l_eink_line)},
  839. { "setFont", ROREG_FUNC(l_eink_set_font)},
  840. { "qrcode", ROREG_FUNC(l_eink_qrcode)},
  841. { "bat", ROREG_FUNC(l_eink_bat)},
  842. { "weather_icon", ROREG_FUNC(l_eink_weather_icon)},
  843. { "model", ROREG_FUNC(l_eink_model)},
  844. { "drawXbm", ROREG_FUNC(l_eink_drawXbm)},
  845. { "draw", ROREG_FUNC(l_eink_draw)},
  846. { "setCtx", ROREG_FUNC(l_eink_set_ctx)},
  847. #ifdef LUAT_USE_GTFONT
  848. { "drawGtfontGb2312", ROREG_FUNC(l_eink_draw_gtfont_gb2312)},
  849. { "drawGtfontGb2312Gray", ROREG_FUNC(l_eink_draw_gtfont_gb2312_gray)},
  850. #ifdef LUAT_USE_GTFONT_UTF8
  851. { "drawGtfontUtf8", ROREG_FUNC(l_eink_draw_gtfont_utf8)},
  852. { "drawGtfontUtf8Gray", ROREG_FUNC(l_eink_draw_gtfont_utf8_gray)},
  853. #endif // LUAT_USE_GTFONT_UTF8
  854. #endif // LUAT_USE_GTFONT
  855. //@const MODEL_1in02d number 1.02寸d
  856. { "MODEL_1in02d", ROREG_INT(MODEL_1in02d)},
  857. //@const MODEL_1in54 number 1.54寸
  858. { "MODEL_1in54", ROREG_INT(MODEL_1in54)},
  859. //@const MODEL_1in54_V2 number 1.54寸_V2
  860. { "MODEL_1in54_V2", ROREG_INT(MODEL_1in54_V2)},
  861. //@const MODEL_1in54b number 1.54寸b
  862. { "MODEL_1in54b", ROREG_INT(MODEL_1in54b)},
  863. //@const MODEL_1in54b_V2 number 1.54寸b_V2
  864. { "MODEL_1in54b_V2", ROREG_INT(MODEL_1in54b_V2)},
  865. //@const MODEL_1in54_V3 number 1.54寸_V3
  866. { "MODEL_1in54_V3", ROREG_INT(MODEL_1in54_V3)},
  867. //@const MODEL_1in54c number 1.54寸c
  868. { "MODEL_1in54c", ROREG_INT(MODEL_1in54c)},
  869. //@const MODEL_1in54f number 1.54寸f
  870. { "MODEL_1in54f", ROREG_INT(MODEL_1in54f)},
  871. //@const MODEL_2in54b_V3 number 2.13寸b_V3
  872. { "MODEL_2in54b_V3", ROREG_INT(MODEL_2in13b_V3)},
  873. //@const MODEL_2in7 number 2.7寸
  874. { "MODEL_2in7", ROREG_INT(MODEL_2in7)},
  875. //@const MODEL_2in7b number 2.7寸b
  876. { "MODEL_2in7b", ROREG_INT(MODEL_2in7b)},
  877. //@const MODEL_2in9 number 2.9寸
  878. { "MODEL_2in9", ROREG_INT(MODEL_2in9)},
  879. //@const MODEL_2in9_V2 number 2.9寸_V2
  880. { "MODEL_2in9_V2", ROREG_INT(MODEL_2in9_V2)},
  881. //@const MODEL_2in9bc number 2.9寸bc
  882. { "MODEL_2in9bc", ROREG_INT(MODEL_2in9bc)},
  883. //@const MODEL_2in9b_V3 number 2.9寸b_V3
  884. { "MODEL_2in9b_V3", ROREG_INT(MODEL_2in9b_V3)},
  885. //@const MODEL_2in9d number 2.9寸d
  886. { "MODEL_2in9d", ROREG_INT(MODEL_2in9d)},
  887. //@const MODEL_2in9f number 2.9寸f
  888. { "MODEL_2in9f", ROREG_INT(MODEL_2in9ff)},
  889. //@const MODEL_3in7 number 3.7寸
  890. { "MODEL_3in7", ROREG_INT(MODEL_3in7)},
  891. // 默认只带8号字体
  892. //@const font_opposansm8 font 8号字体
  893. { "font_opposansm8", ROREG_PTR((void*)u8g2_font_opposansm8)},
  894. #ifdef USE_U8G2_OPPOSANSM_ENGLISH
  895. //@const font_unifont_t_symbols font 符号字体
  896. { "font_unifont_t_symbols", ROREG_PTR((void*)u8g2_font_unifont_t_symbols)},
  897. //@const font_open_iconic_weather_6x_t font 天气字体
  898. { "font_open_iconic_weather_6x_t", ROREG_PTR((void*)u8g2_font_open_iconic_weather_6x_t)},
  899. //@const font_opposansm10 font 10号字体
  900. //@const font_opposansm12 font 12号字体
  901. //@const font_opposansm16 font 16号字体
  902. //@const font_opposansm18 font 18号字体
  903. //@const font_opposansm20 font 20号字体
  904. //@const font_opposansm22 font 22号字体
  905. //@const font_opposansm24 font 24号字体
  906. //@const font_opposansm32 font 32号字体
  907. { "font_opposansm10", ROREG_PTR((void*)u8g2_font_opposansm10)},
  908. { "font_opposansm12", ROREG_PTR((void*)u8g2_font_opposansm12)},
  909. { "font_opposansm16", ROREG_PTR((void*)u8g2_font_opposansm16)},
  910. { "font_opposansm18", ROREG_PTR((void*)u8g2_font_opposansm18)},
  911. { "font_opposansm20", ROREG_PTR((void*)u8g2_font_opposansm20)},
  912. { "font_opposansm22", ROREG_PTR((void*)u8g2_font_opposansm22)},
  913. { "font_opposansm24", ROREG_PTR((void*)u8g2_font_opposansm24)},
  914. { "font_opposansm32", ROREG_PTR((void*)u8g2_font_opposansm32)},
  915. #endif
  916. #ifdef USE_U8G2_OPPOSANSM8_CHINESE
  917. //@const font_opposansm8_chinese font 8号中文字体
  918. { "font_opposansm8_chinese", ROREG_PTR((void*)u8g2_font_opposansm8_chinese)},
  919. #endif
  920. #ifdef USE_U8G2_OPPOSANSM10_CHINESE
  921. //@const font_opposansm8_chinese font 10号中文字体
  922. { "font_opposansm10_chinese", ROREG_PTR((void*)u8g2_font_opposansm10_chinese)},
  923. #endif
  924. #ifdef USE_U8G2_OPPOSANSM12_CHINESE
  925. //@const font_opposansm12_chinese font 12号中文字体
  926. { "font_opposansm12_chinese", ROREG_PTR((void*)u8g2_font_opposansm12_chinese)},
  927. #endif
  928. #ifdef USE_U8G2_OPPOSANSM16_CHINESE
  929. //@const font_opposansm16_chinese font 16号中文字体
  930. { "font_opposansm16_chinese", ROREG_PTR((void*)u8g2_font_opposansm16_chinese)},
  931. #endif
  932. #ifdef USE_U8G2_OPPOSANSM18_CHINESE
  933. //@const font_opposansm18_chinese font 18号中文字体
  934. { "font_opposansm18_chinese", ROREG_PTR((void*)u8g2_font_opposansm18_chinese)},
  935. #endif
  936. #ifdef USE_U8G2_OPPOSANSM20_CHINESE
  937. //@const font_opposansm20_chinese font 20号中文字体
  938. { "font_opposansm20_chinese", ROREG_PTR((void*)u8g2_font_opposansm20_chinese)},
  939. #endif
  940. #ifdef USE_U8G2_OPPOSANSM22_CHINESE
  941. //@const font_opposansm22_chinese font 22号中文字体
  942. { "font_opposansm22_chinese", ROREG_PTR((void*)u8g2_font_opposansm22_chinese)},
  943. #endif
  944. #ifdef USE_U8G2_OPPOSANSM24_CHINESE
  945. //@const font_opposansm24_chinese font 24号中文字体
  946. { "font_opposansm24_chinese", ROREG_PTR((void*)u8g2_font_opposansm24_chinese)},
  947. #endif
  948. #ifdef USE_U8G2_OPPOSANSM32_CHINESE
  949. //@const font_opposansm32_chinese font 32号中文字体
  950. { "font_opposansm32_chinese", ROREG_PTR((void*)u8g2_font_opposansm32_chinese)},
  951. #endif
  952. { "MODEL_1in02d", ROREG_INT(MODEL_1in02d)},
  953. { "MODEL_1in54", ROREG_INT(MODEL_1in54)},
  954. { "MODEL_1in54b", ROREG_INT(MODEL_1in54b)},
  955. { "MODEL_1in54b_V2", ROREG_INT(MODEL_1in54b_V2)},
  956. { "MODEL_1in54c", ROREG_INT(MODEL_1in54c)},
  957. { "MODEL_1in54f", ROREG_INT(MODEL_1in54f)},
  958. { "MODEL_1in54_V2", ROREG_INT(MODEL_1in54_V2)},
  959. { "MODEL_1in54_V3", ROREG_INT(MODEL_1in54_V3)},
  960. { "MODEL_2in13", ROREG_INT(MODEL_2in13)},
  961. { "MODEL_2in13bc", ROREG_INT(MODEL_2in13bc)},
  962. { "MODEL_2in13b_V3", ROREG_INT(MODEL_2in13b_V3)},
  963. { "MODEL_2in13d", ROREG_INT(MODEL_2in13d)},
  964. { "MODEL_2in13_V2", ROREG_INT(MODEL_2in13_V2)},
  965. { "MODEL_2in66", ROREG_INT(MODEL_2in66)},
  966. { "MODEL_2in66b", ROREG_INT(MODEL_2in66b)},
  967. { "MODEL_2in7", ROREG_INT(MODEL_2in7)},
  968. { "MODEL_2in7b", ROREG_INT(MODEL_2in7b)},
  969. { "MODEL_2in9", ROREG_INT(MODEL_2in9)},
  970. { "MODEL_2in9bc", ROREG_INT(MODEL_2in9bc)},
  971. { "MODEL_2in9b_V3", ROREG_INT(MODEL_2in9b_V3)},
  972. { "MODEL_2in9d", ROREG_INT(MODEL_2in9d)},
  973. { "MODEL_2in9ff", ROREG_INT(MODEL_2in9ff)},
  974. { "MODEL_2in9_V2", ROREG_INT(MODEL_2in9_V2)},
  975. { "MODEL_3in7", ROREG_INT(MODEL_3in7)},
  976. { "MODEL_4in2", ROREG_INT(MODEL_4in2)},
  977. { "MODEL_4in2bc", ROREG_INT(MODEL_4in2bc)},
  978. { "MODEL_4in2b_V2", ROREG_INT(MODEL_4in2b_V2)},
  979. { "MODEL_5in65f", ROREG_INT(MODEL_5in65f)},
  980. { "MODEL_5in83", ROREG_INT(MODEL_5in83)},
  981. { "MODEL_5in83bc", ROREG_INT(MODEL_5in83bc)},
  982. { "MODEL_5in83b_V2", ROREG_INT(MODEL_5in83b_V2)},
  983. { "MODEL_5in83_V2", ROREG_INT(MODEL_5in83_V2)},
  984. { "MODEL_7in5", ROREG_INT(MODEL_7in5)},
  985. { "MODEL_7in5bc", ROREG_INT(MODEL_7in5bc)},
  986. { "MODEL_7in5b_HD", ROREG_INT(MODEL_7in5b_HD)},
  987. { "MODEL_7in5b_V2", ROREG_INT(MODEL_7in5b_V2)},
  988. { "MODEL_7in5_HD", ROREG_INT(MODEL_7in5_HD)},
  989. { "MODEL_7in5_V2", ROREG_INT(MODEL_7in5_V2)},
  990. { NULL, ROREG_INT(0)}
  991. };
  992. LUAMOD_API int luaopen_eink( lua_State *L ){
  993. luat_newlib2(L, reg_eink);
  994. return 1;
  995. }