My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tft_lvgl_configuration.cpp 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../../inc/MarlinConfigPre.h"
  23. #if HAS_TFT_LVGL_UI
  24. #include "SPI_TFT.h"
  25. #include "tft_lvgl_configuration.h"
  26. #include "draw_ready_print.h"
  27. #include "pic_manager.h"
  28. #include "mks_hardware.h"
  29. #include "draw_ui.h"
  30. #include "SPIFlashStorage.h"
  31. #include <lvgl.h>
  32. #include "../../../MarlinCore.h"
  33. #include "../../../inc/MarlinConfig.h"
  34. #include HAL_PATH(../../../HAL, tft/xpt2046.h)
  35. #include "../../marlinui.h"
  36. XPT2046 touch;
  37. #if ENABLED(POWER_LOSS_RECOVERY)
  38. #include "../../../feature/powerloss.h"
  39. #endif
  40. #if HAS_SERVOS
  41. #include "../../../module/servo.h"
  42. #endif
  43. #if EITHER(PROBE_TARE, HAS_Z_SERVO_PROBE)
  44. #include "../../../module/probe.h"
  45. #endif
  46. #if ENABLED(TOUCH_SCREEN_CALIBRATION)
  47. #include "../../tft_io/touch_calibration.h"
  48. #include "draw_touch_calibration.h"
  49. #endif
  50. #if ENABLED(MKS_WIFI_MODULE)
  51. #include "wifi_module.h"
  52. #endif
  53. #include <SPI.h>
  54. #ifndef TFT_WIDTH
  55. #define TFT_WIDTH 480
  56. #endif
  57. #ifndef TFT_HEIGHT
  58. #define TFT_HEIGHT 320
  59. #endif
  60. #if HAS_SPI_FLASH_FONT
  61. void init_gb2312_font();
  62. #endif
  63. static lv_disp_buf_t disp_buf;
  64. lv_group_t* g;
  65. #if ENABLED(SDSUPPORT)
  66. void UpdateAssets();
  67. #endif
  68. uint16_t DeviceCode = 0x9488;
  69. extern uint8_t sel_id;
  70. uint8_t bmp_public_buf[14 * 1024];
  71. uint8_t public_buf[513];
  72. extern bool flash_preview_begin, default_preview_flg, gcode_preview_over;
  73. void SysTick_Callback() {
  74. lv_tick_inc(1);
  75. print_time_count();
  76. #if ENABLED(MKS_WIFI_MODULE)
  77. if (tips_disp.timer == TIPS_TIMER_START)
  78. tips_disp.timer_count++;
  79. #endif
  80. if (uiCfg.filament_loading_time_flg) {
  81. uiCfg.filament_loading_time_cnt++;
  82. uiCfg.filament_rate = uint32_t(100.0f * uiCfg.filament_loading_time_cnt / SEC_TO_MS(uiCfg.filament_loading_time) + 0.5f);
  83. if (uiCfg.filament_loading_time_cnt >= SEC_TO_MS(uiCfg.filament_loading_time)) {
  84. uiCfg.filament_loading_time_cnt = 0;
  85. uiCfg.filament_loading_time_flg = false;
  86. uiCfg.filament_loading_completed = true;
  87. }
  88. }
  89. if (uiCfg.filament_unloading_time_flg) {
  90. uiCfg.filament_unloading_time_cnt++;
  91. uiCfg.filament_rate = uint32_t(100.0f * uiCfg.filament_unloading_time_cnt / SEC_TO_MS(uiCfg.filament_unloading_time) + 0.5f);
  92. if (uiCfg.filament_unloading_time_cnt >= SEC_TO_MS(uiCfg.filament_unloading_time)) {
  93. uiCfg.filament_unloading_time_cnt = 0;
  94. uiCfg.filament_unloading_time_flg = false;
  95. uiCfg.filament_unloading_completed = true;
  96. uiCfg.filament_rate = 100;
  97. }
  98. }
  99. }
  100. void tft_lvgl_init() {
  101. W25QXX.init(SPI_QUARTER_SPEED);
  102. gCfgItems_init();
  103. ui_cfg_init();
  104. disp_language_init();
  105. hal.watchdog_refresh(); // LVGL init takes time
  106. // Init TFT first!
  107. SPI_TFT.spi_init(SPI_FULL_SPEED);
  108. SPI_TFT.LCD_init();
  109. hal.watchdog_refresh(); // LVGL init takes time
  110. #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
  111. uint16_t usb_flash_loop = 1000;
  112. #if ENABLED(MULTI_VOLUME) && !HAS_SD_HOST_DRIVE
  113. SET_INPUT_PULLUP(SD_DETECT_PIN);
  114. card.changeMedia(IS_SD_INSERTED() ? &card.media_driver_sdcard : &card.media_driver_usbFlash);
  115. #endif
  116. do {
  117. card.media_driver_usbFlash.idle();
  118. hal.watchdog_refresh();
  119. delay(2);
  120. } while (!card.media_driver_usbFlash.isInserted() && usb_flash_loop--);
  121. card.mount();
  122. #elif HAS_LOGO_IN_FLASH
  123. delay(1000);
  124. hal.watchdog_refresh();
  125. delay(1000);
  126. #endif
  127. hal.watchdog_refresh(); // LVGL init takes time
  128. #if ENABLED(SDSUPPORT)
  129. UpdateAssets();
  130. hal.watchdog_refresh(); // LVGL init takes time
  131. TERN_(MKS_TEST, mks_test_get());
  132. #endif
  133. touch.Init();
  134. lv_init();
  135. lv_disp_buf_init(&disp_buf, bmp_public_buf, nullptr, LV_HOR_RES_MAX * 14); // Initialize the display buffer
  136. lv_disp_drv_t disp_drv; // Descriptor of a display driver
  137. lv_disp_drv_init(&disp_drv); // Basic initialization
  138. disp_drv.flush_cb = my_disp_flush; // Set your driver function
  139. disp_drv.buffer = &disp_buf; // Assign the buffer to the display
  140. lv_disp_drv_register(&disp_drv); // Finally register the driver
  141. lv_indev_drv_t indev_drv;
  142. lv_indev_drv_init(&indev_drv); // Descriptor of a input device driver
  143. indev_drv.type = LV_INDEV_TYPE_POINTER; // Touch pad is a pointer-like device
  144. indev_drv.read_cb = my_touchpad_read; // Set your driver function
  145. lv_indev_drv_register(&indev_drv); // Finally register the driver
  146. #if HAS_ROTARY_ENCODER
  147. g = lv_group_create();
  148. lv_indev_drv_t enc_drv;
  149. lv_indev_drv_init(&enc_drv);
  150. enc_drv.type = LV_INDEV_TYPE_ENCODER;
  151. enc_drv.read_cb = my_mousewheel_read;
  152. lv_indev_t * enc_indev = lv_indev_drv_register(&enc_drv);
  153. lv_indev_set_group(enc_indev, g);
  154. #endif
  155. lv_fs_drv_t spi_flash_drv;
  156. lv_fs_drv_init(&spi_flash_drv);
  157. spi_flash_drv.letter = 'F';
  158. spi_flash_drv.open_cb = spi_flash_open_cb;
  159. spi_flash_drv.close_cb = spi_flash_close_cb;
  160. spi_flash_drv.read_cb = spi_flash_read_cb;
  161. spi_flash_drv.seek_cb = spi_flash_seek_cb;
  162. spi_flash_drv.tell_cb = spi_flash_tell_cb;
  163. lv_fs_drv_register(&spi_flash_drv);
  164. lv_fs_drv_t sd_drv;
  165. lv_fs_drv_init(&sd_drv);
  166. sd_drv.letter = 'S';
  167. sd_drv.open_cb = sd_open_cb;
  168. sd_drv.close_cb = sd_close_cb;
  169. sd_drv.read_cb = sd_read_cb;
  170. sd_drv.seek_cb = sd_seek_cb;
  171. sd_drv.tell_cb = sd_tell_cb;
  172. lv_fs_drv_register(&sd_drv);
  173. systick_attach_callback(SysTick_Callback);
  174. TERN_(HAS_SPI_FLASH_FONT, init_gb2312_font());
  175. tft_style_init();
  176. filament_pin_setup();
  177. lv_encoder_pin_init();
  178. #if ENABLED(MKS_WIFI_MODULE)
  179. mks_esp_wifi_init();
  180. mks_wifi_firmware_update();
  181. #endif
  182. TERN_(HAS_SERVOS, servo_init());
  183. TERN_(HAS_Z_SERVO_PROBE, probe.servo_probe_init());
  184. bool ready = true;
  185. #if ENABLED(POWER_LOSS_RECOVERY)
  186. recovery.load();
  187. if (recovery.valid()) {
  188. ready = false;
  189. if (gCfgItems.from_flash_pic)
  190. flash_preview_begin = true;
  191. else
  192. default_preview_flg = true;
  193. uiCfg.print_state = REPRINTING;
  194. #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
  195. strncpy(public_buf_m, recovery.info.sd_filename, sizeof(public_buf_m));
  196. card.printLongPath(public_buf_m);
  197. strncpy(list_file.long_name[sel_id], card.longFilename, sizeof(list_file.long_name[0]));
  198. #else
  199. strncpy(list_file.long_name[sel_id], recovery.info.sd_filename, sizeof(list_file.long_name[0]));
  200. #endif
  201. lv_draw_printing();
  202. }
  203. #endif
  204. if (ready) lv_draw_ready_print();
  205. #if BOTH(MKS_TEST, SDSUPPORT)
  206. if (mks_test_flag == 0x1E) mks_gpio_test();
  207. #endif
  208. }
  209. static lv_disp_drv_t* disp_drv_p;
  210. #if ENABLED(USE_SPI_DMA_TC)
  211. bool lcd_dma_trans_lock = false;
  212. #endif
  213. void dmc_tc_handler(struct __DMA_HandleTypeDef * hdma) {
  214. #if ENABLED(USE_SPI_DMA_TC)
  215. lv_disp_flush_ready(disp_drv_p);
  216. lcd_dma_trans_lock = false;
  217. TFT_SPI::Abort();
  218. #endif
  219. }
  220. void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {
  221. uint16_t width = area->x2 - area->x1 + 1,
  222. height = area->y2 - area->y1 + 1;
  223. disp_drv_p = disp;
  224. SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height);
  225. #if ENABLED(USE_SPI_DMA_TC)
  226. lcd_dma_trans_lock = true;
  227. SPI_TFT.tftio.WriteSequenceIT((uint16_t*)color_p, width * height);
  228. TFT_SPI::DMAtx.XferCpltCallback = dmc_tc_handler;
  229. #else
  230. SPI_TFT.tftio.WriteSequence((uint16_t*)color_p, width * height);
  231. lv_disp_flush_ready(disp_drv_p); // Indicate you are ready with the flushing
  232. #endif
  233. W25QXX.init(SPI_QUARTER_SPEED);
  234. }
  235. #if ENABLED(USE_SPI_DMA_TC)
  236. bool get_lcd_dma_lock() { return lcd_dma_trans_lock; }
  237. #endif
  238. void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color) {
  239. uint16_t width, height;
  240. width = x2 - x1 + 1;
  241. height = y2 - y1 + 1;
  242. SPI_TFT.setWindow((uint16_t)x1, (uint16_t)y1, width, height);
  243. SPI_TFT.tftio.WriteMultiple(bk_color.full, width * height);
  244. W25QXX.init(SPI_QUARTER_SPEED);
  245. }
  246. #define TICK_CYCLE 1
  247. unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick) {
  248. return TICK_CYCLE * (lastTick <= curTick ? (curTick - lastTick) : (0xFFFFFFFF - lastTick + curTick));
  249. }
  250. static bool get_point(int16_t *x, int16_t *y) {
  251. if (!touch.getRawPoint(x, y)) return false;
  252. #if ENABLED(TOUCH_SCREEN_CALIBRATION)
  253. const calibrationState state = touch_calibration.get_calibration_state();
  254. if (state >= CALIBRATION_TOP_LEFT && state <= CALIBRATION_BOTTOM_RIGHT) {
  255. if (touch_calibration.handleTouch(*x, *y)) lv_update_touch_calibration_screen();
  256. return false;
  257. }
  258. *x = int16_t((int32_t(*x) * touch_calibration.calibration.x) >> 16) + touch_calibration.calibration.offset_x;
  259. *y = int16_t((int32_t(*y) * touch_calibration.calibration.y) >> 16) + touch_calibration.calibration.offset_y;
  260. #else
  261. *x = int16_t((int32_t(*x) * TOUCH_CALIBRATION_X) >> 16) + TOUCH_OFFSET_X;
  262. *y = int16_t((int32_t(*y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y;
  263. #endif
  264. return true;
  265. }
  266. bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) {
  267. static int16_t last_x = 0, last_y = 0;
  268. if (get_point(&last_x, &last_y)) {
  269. #if TFT_ROTATION == TFT_ROTATE_180
  270. data->point.x = TFT_WIDTH - last_x;
  271. data->point.y = TFT_HEIGHT - last_y;
  272. #else
  273. data->point.x = last_x;
  274. data->point.y = last_y;
  275. #endif
  276. data->state = LV_INDEV_STATE_PR;
  277. }
  278. else {
  279. #if TFT_ROTATION == TFT_ROTATE_180
  280. data->point.x = TFT_WIDTH - last_x;
  281. data->point.y = TFT_HEIGHT - last_y;
  282. #else
  283. data->point.x = last_x;
  284. data->point.y = last_y;
  285. #endif
  286. data->state = LV_INDEV_STATE_REL;
  287. }
  288. return false; // Return `false` since no data is buffering or left to read
  289. }
  290. int16_t enc_diff = 0;
  291. lv_indev_state_t state = LV_INDEV_STATE_REL;
  292. bool my_mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) {
  293. (void) indev_drv; // Unused
  294. data->state = state;
  295. data->enc_diff = enc_diff;
  296. enc_diff = 0;
  297. return false; // No more data to read so return false
  298. }
  299. extern uint8_t currentFlashPage;
  300. // spi_flash
  301. uint32_t pic_read_base_addr = 0, pic_read_addr_offset = 0;
  302. lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) {
  303. static char last_path_name[30];
  304. if (strcasecmp(last_path_name, path) != 0) {
  305. pic_read_base_addr = lv_get_pic_addr((uint8_t *)path);
  306. strcpy(last_path_name, path);
  307. }
  308. else {
  309. W25QXX.init(SPI_QUARTER_SPEED);
  310. currentFlashPage = 0;
  311. }
  312. pic_read_addr_offset = pic_read_base_addr;
  313. return LV_FS_RES_OK;
  314. }
  315. lv_fs_res_t spi_flash_close_cb (lv_fs_drv_t * drv, void * file_p) {
  316. lv_fs_res_t res = LV_FS_RES_OK;
  317. /* Add your code here */
  318. pic_read_addr_offset = pic_read_base_addr;
  319. return res;
  320. }
  321. lv_fs_res_t spi_flash_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br) {
  322. lv_pic_test((uint8_t *)buf, pic_read_addr_offset, btr);
  323. *br = btr;
  324. return LV_FS_RES_OK;
  325. }
  326. lv_fs_res_t spi_flash_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos) {
  327. #if HAS_SPI_FLASH_COMPRESSION
  328. if (pos == 4) {
  329. uint8_t bmp_header[4];
  330. SPIFlash.beginRead(pic_read_base_addr);
  331. SPIFlash.readData(bmp_header, 4);
  332. currentFlashPage = 1;
  333. }
  334. pic_read_addr_offset = pic_read_base_addr;
  335. #else
  336. pic_read_addr_offset = pic_read_base_addr + pos;
  337. #endif
  338. return LV_FS_RES_OK;
  339. }
  340. lv_fs_res_t spi_flash_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) {
  341. *pos_p = pic_read_addr_offset - pic_read_base_addr;
  342. return LV_FS_RES_OK;
  343. }
  344. // sd
  345. char *cur_namefff;
  346. uint32_t sd_read_base_addr = 0, sd_read_addr_offset = 0, small_image_size = 409;
  347. lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) {
  348. char name_buf[100];
  349. *name_buf = '/';
  350. strcpy(name_buf + 1, path);
  351. char *temp = strstr(name_buf, ".bin");
  352. if (temp) strcpy(temp, ".GCO");
  353. sd_read_base_addr = lv_open_gcode_file((char *)name_buf);
  354. sd_read_addr_offset = sd_read_base_addr;
  355. if (sd_read_addr_offset == UINT32_MAX) return LV_FS_RES_NOT_EX;
  356. // find small image size
  357. card.read(public_buf, 512);
  358. public_buf[511] = '\0';
  359. const char* eol = strpbrk((const char*)public_buf, "\n\r");
  360. small_image_size = (uintptr_t)eol - (uintptr_t)((uint32_t *)(&public_buf[0])) + 1;
  361. return LV_FS_RES_OK;
  362. }
  363. lv_fs_res_t sd_close_cb (lv_fs_drv_t * drv, void * file_p) {
  364. /* Add your code here */
  365. lv_close_gcode_file();
  366. return LV_FS_RES_OK;
  367. }
  368. lv_fs_res_t sd_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br) {
  369. if (btr == 200) {
  370. lv_gcode_file_read((uint8_t *)buf);
  371. //pic_read_addr_offset += 208;
  372. *br = 200;
  373. }
  374. else if (btr == 4) {
  375. uint8_t header_pic[4] = { 0x04, 0x90, 0x81, 0x0C };
  376. memcpy(buf, header_pic, 4);
  377. *br = 4;
  378. }
  379. return LV_FS_RES_OK;
  380. }
  381. lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos) {
  382. sd_read_addr_offset = sd_read_base_addr + (pos - 4) / 200 * small_image_size;
  383. lv_gcode_file_seek(sd_read_addr_offset);
  384. return LV_FS_RES_OK;
  385. }
  386. lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) {
  387. if (sd_read_addr_offset) *pos_p = 0;
  388. else *pos_p = (sd_read_addr_offset - sd_read_base_addr) / small_image_size * 200 + 4;
  389. return LV_FS_RES_OK;
  390. }
  391. void lv_encoder_pin_init() {
  392. #if BUTTON_EXISTS(EN1)
  393. SET_INPUT_PULLUP(BTN_EN1);
  394. #endif
  395. #if BUTTON_EXISTS(EN2)
  396. SET_INPUT_PULLUP(BTN_EN2);
  397. #endif
  398. #if BUTTON_EXISTS(ENC)
  399. SET_INPUT_PULLUP(BTN_ENC);
  400. #endif
  401. #if BUTTON_EXISTS(BACK)
  402. SET_INPUT_PULLUP(BTN_BACK);
  403. #endif
  404. #if BUTTON_EXISTS(UP)
  405. SET_INPUT(BTN_UP);
  406. #endif
  407. #if BUTTON_EXISTS(DOWN)
  408. SET_INPUT(BTN_DOWN);
  409. #endif
  410. #if BUTTON_EXISTS(LEFT)
  411. SET_INPUT(BTN_LEFT);
  412. #endif
  413. #if BUTTON_EXISTS(RIGHT)
  414. SET_INPUT(BTN_RIGHT);
  415. #endif
  416. }
  417. #if 1 // HAS_ENCODER_ACTION
  418. void lv_update_encoder() {
  419. static uint32_t encoder_time1;
  420. uint32_t tmpTime, diffTime = 0;
  421. tmpTime = millis();
  422. diffTime = getTickDiff(tmpTime, encoder_time1);
  423. if (diffTime > 50) {
  424. #if HAS_ENCODER_WHEEL
  425. #if ANY_BUTTON(EN1, EN2, ENC, BACK)
  426. uint8_t newbutton = 0;
  427. if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
  428. if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
  429. if (BUTTON_PRESSED(ENC)) newbutton |= EN_C;
  430. if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;
  431. #else
  432. constexpr uint8_t newbutton = 0;
  433. #endif
  434. static uint8_t buttons = 0;
  435. buttons = newbutton;
  436. static uint8_t lastEncoderBits;
  437. #define encrot0 0
  438. #define encrot1 1
  439. #define encrot2 2
  440. uint8_t enc = 0;
  441. if (buttons & EN_A) enc |= B01;
  442. if (buttons & EN_B) enc |= B10;
  443. if (enc != lastEncoderBits) {
  444. switch (enc) {
  445. case encrot1:
  446. if (lastEncoderBits == encrot0) {
  447. enc_diff--;
  448. encoder_time1 = tmpTime;
  449. }
  450. break;
  451. case encrot2:
  452. if (lastEncoderBits == encrot0) {
  453. enc_diff++;
  454. encoder_time1 = tmpTime;
  455. }
  456. break;
  457. }
  458. lastEncoderBits = enc;
  459. }
  460. static uint8_t last_button_state = LV_INDEV_STATE_REL;
  461. const uint8_t enc_c = (buttons & EN_C) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
  462. if (enc_c != last_button_state) {
  463. state = enc_c ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
  464. last_button_state = enc_c;
  465. }
  466. #endif // HAS_ENCODER_WHEEL
  467. } // next_button_update_ms
  468. }
  469. #endif // HAS_ENCODER_ACTION
  470. #if __PLAT_NATIVE_SIM__
  471. #include <lv_misc/lv_log.h>
  472. typedef void (*lv_log_print_g_cb_t)(lv_log_level_t level, const char *, uint32_t, const char *);
  473. extern "C" void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb) {}
  474. #endif
  475. #endif // HAS_TFT_LVGL_UI