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.

draw_ui.cpp 41KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467
  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. #if ENABLED(TFT_LVGL_UI_SPI)
  25. #include "SPI_TFT.h"
  26. #endif
  27. #include "tft_lvgl_configuration.h"
  28. #include "pic_manager.h"
  29. #include "draw_ui.h"
  30. #include "mks_hardware_test.h"
  31. #include <SPI.h>
  32. #include "../../../../MarlinCore.h"
  33. #include "../../../../sd/cardreader.h"
  34. #include "../../../../module/motion.h"
  35. #include "../../../../module/planner.h"
  36. #if ENABLED(POWER_LOSS_RECOVERY)
  37. #include "../../../../feature/powerloss.h"
  38. #endif
  39. #if ENABLED(PARK_HEAD_ON_PAUSE)
  40. #include "../../../../feature/pause.h"
  41. #endif
  42. CFG_ITMES gCfgItems;
  43. UI_CFG uiCfg;
  44. DISP_STATE_STACK disp_state_stack;
  45. DISP_STATE disp_state = MAIN_UI;
  46. DISP_STATE last_disp_state;
  47. PRINT_TIME print_time;
  48. value_state value;
  49. uint32_t To_pre_view;
  50. uint8_t gcode_preview_over;
  51. uint8_t flash_preview_begin;
  52. uint8_t default_preview_flg;
  53. uint32_t size = 809;
  54. uint16_t row;
  55. uint8_t temperature_change_frequency;
  56. uint8_t printing_rate_update_flag;
  57. extern uint8_t once_flag;
  58. extern uint8_t sel_id;
  59. extern uint8_t public_buf[512];
  60. extern uint8_t bmp_public_buf[17 * 1024];
  61. extern void LCD_IO_WriteData(uint16_t RegValue);
  62. lv_point_t line_points[4][2] = {
  63. {{PARA_UI_POS_X, PARA_UI_POS_Y + PARA_UI_SIZE_Y}, {TFT_WIDTH, PARA_UI_POS_Y + PARA_UI_SIZE_Y}},
  64. {{PARA_UI_POS_X, PARA_UI_POS_Y*2 + PARA_UI_SIZE_Y}, {TFT_WIDTH, PARA_UI_POS_Y*2 + PARA_UI_SIZE_Y}},
  65. {{PARA_UI_POS_X, PARA_UI_POS_Y*3 + PARA_UI_SIZE_Y}, {TFT_WIDTH, PARA_UI_POS_Y*3 + PARA_UI_SIZE_Y}},
  66. {{PARA_UI_POS_X, PARA_UI_POS_Y*4 + PARA_UI_SIZE_Y}, {TFT_WIDTH, PARA_UI_POS_Y*4 + PARA_UI_SIZE_Y}}
  67. };
  68. void gCfgItems_init() {
  69. gCfgItems.multiple_language = MULTI_LANGUAGE_ENABLE;
  70. #if 1 // LCD_LANGUAGE == en
  71. gCfgItems.language = LANG_ENGLISH;
  72. #elif LCD_LANGUAGE == zh_CN
  73. gCfgItems.language = LANG_SIMPLE_CHINESE;
  74. #elif LCD_LANGUAGE == zh_TW
  75. gCfgItems.language = LANG_COMPLEX_CHINESE;
  76. #elif LCD_LANGUAGE == jp_kana
  77. gCfgItems.language = LANG_JAPAN;
  78. #elif LCD_LANGUAGE == de
  79. gCfgItems.language = LANG_GERMAN;
  80. #elif LCD_LANGUAGE == fr
  81. gCfgItems.language = LANG_FRENCH;
  82. #elif LCD_LANGUAGE == ru
  83. gCfgItems.language = LANG_RUSSIAN;
  84. #elif LCD_LANGUAGE == ko_KR
  85. gCfgItems.language = LANG_KOREAN;
  86. #elif LCD_LANGUAGE == tr
  87. gCfgItems.language = LANG_TURKISH;
  88. #elif LCD_LANGUAGE == es
  89. gCfgItems.language = LANG_SPANISH;
  90. #elif LCD_LANGUAGE == el
  91. gCfgItems.language = LANG_GREEK;
  92. #elif LCD_LANGUAGE == it
  93. gCfgItems.language = LANG_ITALY;
  94. #elif LCD_LANGUAGE == pt
  95. gCfgItems.language = LANG_PORTUGUESE;
  96. #endif
  97. gCfgItems.leveling_mode = 0;
  98. gCfgItems.from_flash_pic = 0;
  99. gCfgItems.curFilesize = 0;
  100. gCfgItems.finish_power_off = 0;
  101. gCfgItems.pause_reprint = 0;
  102. gCfgItems.pausePosX = -1;
  103. gCfgItems.pausePosY = -1;
  104. gCfgItems.pausePosZ = 5;
  105. W25QXX.SPI_FLASH_BufferRead((uint8_t *)&gCfgItems.spi_flash_flag, VAR_INF_ADDR, sizeof(gCfgItems.spi_flash_flag));
  106. if (gCfgItems.spi_flash_flag == GCFG_FLAG_VALUE) {
  107. W25QXX.SPI_FLASH_BufferRead((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
  108. }
  109. else {
  110. gCfgItems.spi_flash_flag = GCFG_FLAG_VALUE;
  111. W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
  112. W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
  113. }
  114. uiCfg.F[0] = 'N';
  115. uiCfg.F[1] = 'A';
  116. uiCfg.F[2] = 'N';
  117. uiCfg.F[3] = 'O';
  118. W25QXX.SPI_FLASH_BlockErase(REFLSHE_FLGA_ADD + 32 - 64*1024);
  119. W25QXX.SPI_FLASH_BufferWrite(uiCfg.F,REFLSHE_FLGA_ADD,4);
  120. }
  121. void gCfg_to_spiFlah() {
  122. W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
  123. W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
  124. }
  125. void ui_cfg_init() {
  126. uiCfg.curTempType = 0;
  127. uiCfg.curSprayerChoose = 0;
  128. uiCfg.stepHeat = 10;
  129. uiCfg.leveling_first_time = 0;
  130. uiCfg.para_ui_page = 0;
  131. uiCfg.extruStep = 5;
  132. uiCfg.extruSpeed = 10;
  133. uiCfg.move_dist = 1;
  134. uiCfg.moveSpeed = 3000;
  135. uiCfg.stepPrintSpeed = 10;
  136. }
  137. void update_spi_flash() {
  138. W25QXX.init(SPI_QUARTER_SPEED);
  139. W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
  140. W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
  141. }
  142. lv_style_t tft_style_scr;
  143. lv_style_t tft_style_label_pre;
  144. lv_style_t tft_style_label_rel;
  145. lv_style_t style_line;
  146. lv_style_t style_para_value_pre;
  147. lv_style_t style_para_value_rel;
  148. lv_style_t style_num_key_pre;
  149. lv_style_t style_num_key_rel;
  150. lv_style_t style_num_text;
  151. void tft_style_init() {
  152. lv_style_copy(&tft_style_scr, &lv_style_scr);
  153. tft_style_scr.body.main_color = LV_COLOR_BACKGROUND;
  154. tft_style_scr.body.grad_color = LV_COLOR_BACKGROUND;
  155. tft_style_scr.text.color = LV_COLOR_TEXT;
  156. tft_style_scr.text.sel_color = LV_COLOR_TEXT;
  157. tft_style_scr.line.width = 0;
  158. tft_style_scr.text.letter_space = 0;
  159. tft_style_scr.text.line_space = 0;
  160. lv_style_copy(&tft_style_label_pre, &lv_style_scr);
  161. lv_style_copy(&tft_style_label_rel, &lv_style_scr);
  162. tft_style_label_pre.body.main_color = LV_COLOR_BACKGROUND;
  163. tft_style_label_pre.body.grad_color = LV_COLOR_BACKGROUND;
  164. tft_style_label_pre.text.color = LV_COLOR_TEXT;
  165. tft_style_label_pre.text.sel_color = LV_COLOR_TEXT;
  166. tft_style_label_rel.body.main_color = LV_COLOR_BACKGROUND;
  167. tft_style_label_rel.body.grad_color = LV_COLOR_BACKGROUND;
  168. tft_style_label_rel.text.color = LV_COLOR_TEXT;
  169. tft_style_label_rel.text.sel_color = LV_COLOR_TEXT;
  170. tft_style_label_pre.text.font = TERN(HAS_SPI_FLASH_FONT, &gb2312_puhui32, LV_FONT_DEFAULT);
  171. tft_style_label_rel.text.font = TERN(HAS_SPI_FLASH_FONT, &gb2312_puhui32, LV_FONT_DEFAULT);
  172. tft_style_label_pre.line.width = 0;
  173. tft_style_label_rel.line.width = 0;
  174. tft_style_label_pre.text.letter_space = 0;
  175. tft_style_label_rel.text.letter_space = 0;
  176. tft_style_label_pre.text.line_space = -5;
  177. tft_style_label_rel.text.line_space = -5;
  178. lv_style_copy(&style_para_value_pre, &lv_style_scr);
  179. lv_style_copy(&style_para_value_rel, &lv_style_scr);
  180. style_para_value_pre.body.main_color = LV_COLOR_BACKGROUND;
  181. style_para_value_pre.body.grad_color = LV_COLOR_BACKGROUND;
  182. style_para_value_pre.text.color = LV_COLOR_BLACK;
  183. style_para_value_pre.text.sel_color = LV_COLOR_BLACK;
  184. style_para_value_rel.body.main_color = LV_COLOR_BACKGROUND;
  185. style_para_value_rel.body.grad_color = LV_COLOR_BACKGROUND;
  186. style_para_value_rel.text.color = LV_COLOR_BLACK;
  187. style_para_value_rel.text.sel_color = LV_COLOR_BLACK;
  188. style_para_value_pre.text.font = TERN(HAS_SPI_FLASH_FONT, &gb2312_puhui32, LV_FONT_DEFAULT);
  189. style_para_value_rel.text.font = TERN(HAS_SPI_FLASH_FONT, &gb2312_puhui32, LV_FONT_DEFAULT);
  190. style_para_value_pre.line.width = 0;
  191. style_para_value_rel.line.width = 0;
  192. style_para_value_pre.text.letter_space = 0;
  193. style_para_value_rel.text.letter_space = 0;
  194. style_para_value_pre.text.line_space = -5;
  195. style_para_value_rel.text.line_space = -5;
  196. lv_style_copy(&style_num_key_pre, &lv_style_scr);
  197. lv_style_copy(&style_num_key_rel, &lv_style_scr);
  198. style_num_key_pre.body.main_color = LV_COLOR_KEY_BACKGROUND;
  199. style_num_key_pre.body.grad_color = LV_COLOR_KEY_BACKGROUND;
  200. style_num_key_pre.text.color = LV_COLOR_TEXT;
  201. style_num_key_pre.text.sel_color = LV_COLOR_TEXT;
  202. style_num_key_rel.body.main_color = LV_COLOR_KEY_BACKGROUND;
  203. style_num_key_rel.body.grad_color = LV_COLOR_KEY_BACKGROUND;
  204. style_num_key_rel.text.color = LV_COLOR_TEXT;
  205. style_num_key_rel.text.sel_color = LV_COLOR_TEXT;
  206. #if HAS_SPI_FLASH_FONT
  207. style_num_key_pre.text.font = &gb2312_puhui32;
  208. style_num_key_rel.text.font = &gb2312_puhui32;
  209. #else
  210. style_num_key_pre.text.font = LV_FONT_DEFAULT;
  211. style_num_key_rel.text.font = LV_FONT_DEFAULT;
  212. #endif
  213. style_num_key_pre.line.width = 0;
  214. style_num_key_rel.line.width = 0;
  215. style_num_key_pre.text.letter_space = 0;
  216. style_num_key_rel.text.letter_space = 0;
  217. style_num_key_pre.text.line_space = -5;
  218. style_num_key_rel.text.line_space = -5;
  219. lv_style_copy(&style_num_text, &lv_style_scr);
  220. style_num_text.body.main_color = LV_COLOR_WHITE;
  221. style_num_text.body.grad_color = LV_COLOR_WHITE;
  222. style_num_text.text.color = LV_COLOR_BLACK;
  223. style_num_text.text.sel_color = LV_COLOR_BLACK;
  224. style_num_text.text.font = TERN(HAS_SPI_FLASH_FONT, &gb2312_puhui32, LV_FONT_DEFAULT);
  225. style_num_text.line.width = 0;
  226. style_num_text.text.letter_space = 0;
  227. style_num_text.text.line_space = -5;
  228. lv_style_copy(&style_line, &lv_style_plain);
  229. style_line.line.color = LV_COLOR_MAKE(0x49, 0x54, 0xff);
  230. style_line.line.width = 1;
  231. style_line.line.rounded = 1;
  232. }
  233. #define MAX_TITLE_LEN 28
  234. char public_buf_m[100] = {0};
  235. char public_buf_l[30];
  236. void titleText_cat(char *str, int strSize, char *addPart) {
  237. if (str == 0 || addPart == 0) return;
  238. if ((int)(strlen(str) + strlen(addPart)) >= strSize) return;
  239. strcat(str, addPart);
  240. }
  241. char *getDispText(int index) {
  242. ZERO(public_buf_l);
  243. switch (disp_state_stack._disp_state[index]) {
  244. case PRINT_READY_UI:
  245. strcpy(public_buf_l, main_menu.title);
  246. break;
  247. case PRINT_FILE_UI:
  248. strcpy(public_buf_l, file_menu.title);
  249. break;
  250. case PRINTING_UI:
  251. if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI
  252. #ifndef TFT35
  253. || disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI
  254. || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI
  255. #endif
  256. ) strcpy(public_buf_l, common_menu.print_special_title);
  257. else strcpy(public_buf_l, printing_menu.title);
  258. break;
  259. case MOVE_MOTOR_UI:
  260. strcpy(public_buf_l, move_menu.title);
  261. break;
  262. case OPERATE_UI:
  263. if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI
  264. #ifndef TFT35
  265. || disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI
  266. || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI
  267. #endif
  268. ) strcpy(public_buf_l, common_menu.operate_special_title);
  269. else strcpy(public_buf_l, operation_menu.title);
  270. break;
  271. case PAUSE_UI:
  272. if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI
  273. || disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI
  274. || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI
  275. ) strcpy(public_buf_l, common_menu.pause_special_title);
  276. else strcpy(public_buf_l, pause_menu.title);
  277. break;
  278. case EXTRUSION_UI:
  279. strcpy(public_buf_l, extrude_menu.title);
  280. break;
  281. case CHANGE_SPEED_UI:
  282. strcpy(public_buf_l, speed_menu.title);
  283. break;
  284. case FAN_UI:
  285. strcpy(public_buf_l, fan_menu.title);
  286. break;
  287. case PRE_HEAT_UI:
  288. if ((disp_state_stack._disp_state[disp_state_stack._disp_index - 1] == OPERATE_UI))
  289. strcpy(public_buf_l, preheat_menu.adjust_title);
  290. else strcpy(public_buf_l, preheat_menu.title);
  291. break;
  292. case SET_UI:
  293. strcpy(public_buf_l, set_menu.title);
  294. break;
  295. case ZERO_UI:
  296. strcpy(public_buf_l, home_menu.title);
  297. break;
  298. case SPRAYER_UI: break;
  299. case MACHINE_UI: break;
  300. case LANGUAGE_UI:
  301. strcpy(public_buf_l, language_menu.title);
  302. break;
  303. case ABOUT_UI:
  304. strcpy(public_buf_l, about_menu.title);
  305. break;
  306. case LOG_UI: break;
  307. case DISK_UI:
  308. strcpy(public_buf_l, filesys_menu.title);
  309. break;
  310. case DIALOG_UI:
  311. strcpy(public_buf_l, common_menu.dialog_confirm_title);
  312. break;
  313. case WIFI_UI:
  314. strcpy(public_buf_l, wifi_menu.title);
  315. break;
  316. case MORE_UI:
  317. case PRINT_MORE_UI:
  318. strcpy(public_buf_l, more_menu.title);
  319. break;
  320. case FILAMENTCHANGE_UI:
  321. strcpy(public_buf_l, filament_menu.title);
  322. break;
  323. case LEVELING_UI:
  324. case MESHLEVELING_UI:
  325. strcpy(public_buf_l, leveling_menu.title);
  326. break;
  327. case BIND_UI:
  328. strcpy(public_buf_l, cloud_menu.title);
  329. break;
  330. case ZOFFSET_UI:
  331. strcpy(public_buf_l, zoffset_menu.title);
  332. break;
  333. case TOOL_UI:
  334. strcpy(public_buf_l, tool_menu.title);
  335. break;
  336. case WIFI_LIST_UI:
  337. //strcpy(public_buf_l, list_menu.title);
  338. break;
  339. case MACHINE_PARA_UI:
  340. strcpy(public_buf_l, MachinePara_menu.title);
  341. break;
  342. case BABY_STEP_UI:
  343. strcpy(public_buf_l, operation_menu.babystep);
  344. break;
  345. case EEPROM_SETTINGS_UI:
  346. strcpy(public_buf_l, eeprom_menu.title);
  347. break;
  348. default: break;
  349. }
  350. return public_buf_l;
  351. }
  352. char *creat_title_text() {
  353. int index = 0;
  354. char *tmpText = 0;
  355. char tmpCurFileStr[20];
  356. ZERO(tmpCurFileStr);
  357. #if _LFN_UNICODE
  358. //cutFileName((TCHAR *)curFileName, 16, 16, (TCHAR *)tmpCurFileStr);
  359. #else
  360. cutFileName(list_file.long_name[sel_id], 16, 16, tmpCurFileStr);
  361. #endif
  362. ZERO(public_buf_m);
  363. while (index <= disp_state_stack._disp_index) {
  364. tmpText = getDispText(index);
  365. if ((*tmpText == 0) || (tmpText == 0)) {
  366. index++;
  367. continue;
  368. }
  369. titleText_cat(public_buf_m, sizeof(public_buf_m), tmpText);
  370. if (index < disp_state_stack._disp_index) titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)">");
  371. index++;
  372. }
  373. if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI
  374. /*|| disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI
  375. || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI*/
  376. ) {
  377. titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)":");
  378. titleText_cat(public_buf_m, sizeof(public_buf_m), tmpCurFileStr);
  379. }
  380. if (strlen(public_buf_m) > MAX_TITLE_LEN) {
  381. ZERO(public_buf_m);
  382. tmpText = getDispText(0);
  383. if (*tmpText != 0) {
  384. titleText_cat(public_buf_m, sizeof(public_buf_m), tmpText);
  385. titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)">...>");
  386. tmpText = getDispText(disp_state_stack._disp_index);
  387. if (*tmpText != 0) titleText_cat(public_buf_m, sizeof(public_buf_m), tmpText);
  388. }
  389. }
  390. return public_buf_m;
  391. }
  392. #if HAS_GCODE_PREVIEW
  393. uint32_t gPicturePreviewStart = 0;
  394. void preview_gcode_prehandle(char *path) {
  395. #if ENABLED(SDSUPPORT)
  396. //uint8_t re;
  397. //uint32_t read;
  398. uint32_t pre_read_cnt = 0;
  399. uint32_t *p1;
  400. char *cur_name;
  401. gPicturePreviewStart = 0;
  402. cur_name = strrchr(path, '/');
  403. card.openFileRead(cur_name);
  404. card.read(public_buf, 512);
  405. p1 = (uint32_t *)strstr((char *)public_buf, ";simage:");
  406. if (p1) {
  407. pre_read_cnt = (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0]));
  408. To_pre_view = pre_read_cnt;
  409. gcode_preview_over = 1;
  410. gCfgItems.from_flash_pic = 1;
  411. update_spi_flash();
  412. }
  413. else {
  414. gcode_preview_over = 0;
  415. default_preview_flg = 1;
  416. gCfgItems.from_flash_pic = 0;
  417. update_spi_flash();
  418. }
  419. card.closefile();
  420. #endif
  421. }
  422. #if 1
  423. void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
  424. #if ENABLED(SDSUPPORT)
  425. //uint8_t ress;
  426. //uint32_t write;
  427. volatile uint32_t i, j;
  428. volatile uint16_t *p_index;
  429. //int res;
  430. char *cur_name;
  431. cur_name = strrchr(path, '/');
  432. card.openFileRead(cur_name);
  433. if (gPicturePreviewStart <= 0) {
  434. while (1) {
  435. uint32_t br = card.read(public_buf, 400);
  436. uint32_t* p1 = (uint32_t *)strstr((char *)public_buf, ";gimage:");
  437. if (p1) {
  438. gPicturePreviewStart += (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0]));
  439. break;
  440. }
  441. else {
  442. gPicturePreviewStart += br;
  443. }
  444. if (br < 400) break;
  445. }
  446. }
  447. card.setIndex((gPicturePreviewStart + To_pre_view) + size * row + 8);
  448. #if ENABLED(TFT_LVGL_UI_SPI)
  449. SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
  450. #else
  451. ili9320_SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
  452. LCD_WriteRAM_Prepare();
  453. #endif
  454. j = i = 0;
  455. while (1) {
  456. card.read(public_buf, 400);
  457. for (i = 0; i < 400;) {
  458. bmp_public_buf[j] = ascii2dec_test((char*)&public_buf[i]) << 4 | ascii2dec_test((char*)&public_buf[i + 1]);
  459. i += 2;
  460. j++;
  461. }
  462. if (j >= 400) break;
  463. }
  464. #if ENABLED(TFT_LVGL_UI_SPI)
  465. for (i = 0; i < 400; i += 2) {
  466. p_index = (uint16_t *)(&bmp_public_buf[i]);
  467. if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
  468. }
  469. SPI_TFT.tftio.WriteSequence((uint16_t*)bmp_public_buf, 200);
  470. #else
  471. for (i = 0; i < 400;) {
  472. p_index = (uint16_t *)(&bmp_public_buf[i]);
  473. if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color;
  474. LCD_IO_WriteData(*p_index);
  475. i += 2;
  476. }
  477. #endif
  478. #if HAS_BAK_VIEW_IN_FLASH
  479. W25QXX.init(SPI_QUARTER_SPEED);
  480. if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
  481. W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
  482. #endif
  483. row++;
  484. if (row >= 200) {
  485. size = 809;
  486. row = 0;
  487. gcode_preview_over = 0;
  488. //flash_preview_begin = 1;
  489. card.closefile();
  490. /*
  491. if (gCurFileState.file_open_flag != 0xaa) {
  492. reset_file_info();
  493. res = f_open(file, curFileName, FA_OPEN_EXISTING | FA_READ);
  494. if (res == FR_OK) {
  495. f_lseek(file,PREVIEW_SIZE+To_pre_view);
  496. gCurFileState.file_open_flag = 0xaa;
  497. //bakup_file_path((uint8_t *)curFileName, strlen(curFileName));
  498. srcfp = file;
  499. mksReprint.mks_printer_state = MKS_WORKING;
  500. once_flag = 0;
  501. }
  502. }
  503. */
  504. char *cur_name;
  505. cur_name = strrchr(list_file.file_name[sel_id], '/');
  506. SdFile file;
  507. SdFile *curDir;
  508. card.endFilePrint();
  509. const char * const fname = card.diveToFile(true, curDir, cur_name);
  510. if (!fname) return;
  511. if (file.open(curDir, fname, O_READ)) {
  512. gCfgItems.curFilesize = file.fileSize();
  513. file.close();
  514. update_spi_flash();
  515. }
  516. card.openFileRead(cur_name);
  517. if (card.isFileOpen()) {
  518. feedrate_percentage = 100;
  519. //saved_feedrate_percentage = feedrate_percentage;
  520. planner.flow_percentage[0] = 100;
  521. planner.e_factor[0] = planner.flow_percentage[0] * 0.01;
  522. if (EXTRUDERS == 2) {
  523. planner.flow_percentage[1] = 100;
  524. planner.e_factor[1] = planner.flow_percentage[1] * 0.01;
  525. }
  526. card.startFileprint();
  527. TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
  528. once_flag = 0;
  529. }
  530. return;
  531. }
  532. card.closefile();
  533. #endif // SDSUPPORT
  534. }
  535. #else // if 1
  536. void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
  537. #if ENABLED(SDSUPPORT)
  538. //uint8_t ress;
  539. //uint32_t write;
  540. volatile uint32_t i, j;
  541. volatile uint16_t *p_index;
  542. //int res;
  543. char *cur_name;
  544. uint16_t Color;
  545. cur_name = strrchr(path, '/');
  546. card.openFileRead(cur_name);
  547. card.setIndex((PREVIEW_LITTLE_PIC_SIZE + To_pre_view) + size * row + 8);
  548. #if ENABLED(TFT_LVGL_UI_SPI)
  549. SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
  550. #else
  551. ili9320_SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
  552. LCD_WriteRAM_Prepare();
  553. #endif
  554. j = 0;
  555. i = 0;
  556. while (1) {
  557. card.read(public_buf, 400);
  558. for (i = 0; i < 400;) {
  559. bmp_public_buf[j] = ascii2dec_test((char*)&public_buf[i]) << 4 | ascii2dec_test((char*)&public_buf[i + 1]);
  560. i += 2;
  561. j++;
  562. }
  563. //if (i > 800) break;
  564. //#ifdef TFT70
  565. // if (j > 400) {
  566. // f_read(file, buff_pic, 1, &read);
  567. // break;
  568. // }
  569. //#elif defined(TFT35)
  570. if (j >= 400)
  571. //f_read(file, buff_pic, 1, &read);
  572. break;
  573. //#endif
  574. }
  575. #if ENABLED(TFT_LVGL_UI_SPI)
  576. for (i = 0; i < 400;) {
  577. p_index = (uint16_t *)(&bmp_public_buf[i]);
  578. Color = (*p_index >> 8);
  579. *p_index = Color | ((*p_index & 0xff) << 8);
  580. i += 2;
  581. if (*p_index == 0x0000) *p_index = 0xC318;
  582. }
  583. TFT_CS_L;
  584. TFT_DC_H;
  585. SPI.dmaSend(bmp_public_buf, 400, true);
  586. TFT_CS_H;
  587. #else
  588. for (i = 0; i < 400;) {
  589. p_index = (uint16_t *)(&bmp_public_buf[i]);
  590. if (*p_index == 0x0000) *p_index = 0x18C3;
  591. LCD_IO_WriteData(*p_index);
  592. i = i + 2;
  593. }
  594. #endif
  595. W25QXX.init(SPI_QUARTER_SPEED);
  596. if (row < 20)
  597. W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
  598. W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
  599. row++;
  600. if (row >= 200) {
  601. size = 809;
  602. row = 0;
  603. gcode_preview_over = 0;
  604. //flash_preview_begin = 1;
  605. card.closefile();
  606. /*
  607. if (gCurFileState.file_open_flag != 0xaa) {
  608. reset_file_info();
  609. res = f_open(file, curFileName, FA_OPEN_EXISTING | FA_READ);
  610. if (res == FR_OK) {
  611. f_lseek(file,PREVIEW_SIZE+To_pre_view);
  612. gCurFileState.file_open_flag = 0xaa;
  613. //bakup_file_path((uint8_t *)curFileName, strlen(curFileName));
  614. srcfp = file;
  615. mksReprint.mks_printer_state = MKS_WORKING;
  616. once_flag = 0;
  617. }
  618. }
  619. */
  620. char *cur_name;
  621. cur_name = strrchr(list_file.file_name[sel_id], '/');
  622. SdFile file;
  623. SdFile *curDir;
  624. card.endFilePrint();
  625. const char * const fname = card.diveToFile(true, curDir, cur_name);
  626. if (!fname) return;
  627. if (file.open(curDir, fname, O_READ)) {
  628. gCfgItems.curFilesize = file.fileSize();
  629. file.close();
  630. update_spi_flash();
  631. }
  632. card.openFileRead(cur_name);
  633. if (card.isFileOpen()) {
  634. feedrate_percentage = 100;
  635. //saved_feedrate_percentage = feedrate_percentage;
  636. planner.flow_percentage[0] = 100;
  637. planner.e_factor[0] = planner.flow_percentage[0] * 0.01;
  638. if (EXTRUDERS == 2) {
  639. planner.flow_percentage[1] = 100;
  640. planner.e_factor[1] = planner.flow_percentage[1] * 0.01;
  641. }
  642. card.startFileprint();
  643. TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
  644. once_flag = 0;
  645. }
  646. return;
  647. }
  648. card.closefile();
  649. #endif // SDSUPPORT
  650. }
  651. #endif // if 1
  652. void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
  653. int index;
  654. int y_off = 0;
  655. for (index = 0; index < 10; index++) { // 200*200
  656. #if HAS_BAK_VIEW_IN_FLASH
  657. if (sel == 1) {
  658. flash_view_Read(bmp_public_buf, 8000); // 20k
  659. }
  660. else {
  661. default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 20k
  662. }
  663. #else
  664. default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 20k
  665. #endif
  666. #if ENABLED(TFT_LVGL_UI_SPI)
  667. SPI_TFT.SetWindows(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
  668. SPI_TFT.tftio.WriteSequence((uint16_t*)(bmp_public_buf), DEFAULT_VIEW_MAX_SIZE / 20);
  669. #else
  670. int x_off = 0;
  671. uint16_t temp_p;
  672. int i = 0;
  673. uint16_t *p_index;
  674. ili9320_SetWindows(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
  675. LCD_WriteRAM_Prepare();
  676. for (int _y = y_off * 20; _y < (y_off + 1) * 20; _y++) {
  677. for (x_off = 0; x_off < 200; x_off++) {
  678. if (sel == 1) {
  679. temp_p = (uint16_t)(bmp_public_buf[i] | bmp_public_buf[i + 1] << 8);
  680. p_index = &temp_p;
  681. }
  682. else {
  683. p_index = (uint16_t *)(&bmp_public_buf[i]);
  684. }
  685. if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color;
  686. LCD_IO_WriteData(*p_index);
  687. i += 2;
  688. }
  689. if (i >= 8000) break;
  690. }
  691. #endif // TFT_LVGL_UI_SPI
  692. y_off++;
  693. }
  694. W25QXX.init(SPI_QUARTER_SPEED);
  695. }
  696. void disp_pre_gcode(int xpos_pixel, int ypos_pixel) {
  697. if (gcode_preview_over == 1) gcode_preview(list_file.file_name[sel_id], xpos_pixel, ypos_pixel);
  698. #if HAS_BAK_VIEW_IN_FLASH
  699. if (flash_preview_begin == 1) {
  700. flash_preview_begin = 0;
  701. Draw_default_preview(xpos_pixel, ypos_pixel, 1);
  702. }
  703. #endif
  704. #if HAS_GCODE_DEFAULT_VIEW_IN_FLASH
  705. if (default_preview_flg == 1) {
  706. Draw_default_preview(xpos_pixel, ypos_pixel, 0);
  707. default_preview_flg = 0;
  708. }
  709. #endif
  710. }
  711. #endif // HAS_GCODE_PREVIEW
  712. void print_time_run() {
  713. static uint8_t lastSec = 0;
  714. if (print_time.seconds >= 60) {
  715. print_time.seconds = 0;
  716. print_time.minutes++;
  717. if (print_time.minutes >= 60) {
  718. print_time.minutes = 0;
  719. print_time.hours++;
  720. }
  721. }
  722. if (disp_state == PRINTING_UI) {
  723. if (lastSec != print_time.seconds) disp_print_time();
  724. lastSec = print_time.seconds;
  725. }
  726. }
  727. void GUI_RefreshPage() {
  728. if ((systick_uptime_millis % 1000) == 0) temperature_change_frequency = 1;
  729. if ((systick_uptime_millis % 3000) == 0) printing_rate_update_flag = 1;
  730. switch (disp_state) {
  731. case MAIN_UI:
  732. //lv_draw_ready_print();
  733. break;
  734. case EXTRUSION_UI:
  735. if (temperature_change_frequency == 1) {
  736. temperature_change_frequency = 0;
  737. disp_hotend_temp();
  738. }
  739. break;
  740. case PRE_HEAT_UI:
  741. if (temperature_change_frequency == 1) {
  742. temperature_change_frequency = 0;
  743. disp_desire_temp();
  744. }
  745. break;
  746. case PRINT_READY_UI:
  747. /*
  748. if (gCfgItems.display_style == 2) {
  749. if (temperature_change_frequency) {
  750. temperature_change_frequency = 0;
  751. disp_restro_state();
  752. }
  753. }
  754. */
  755. break;
  756. case PRINT_FILE_UI: break;
  757. case PRINTING_UI:
  758. if (temperature_change_frequency) {
  759. temperature_change_frequency = 0;
  760. disp_ext_temp();
  761. disp_bed_temp();
  762. disp_fan_speed();
  763. disp_print_time();
  764. disp_fan_Zpos();
  765. }
  766. if (printing_rate_update_flag || marlin_state == MF_SD_COMPLETE) {
  767. printing_rate_update_flag = 0;
  768. if (gcode_preview_over == 0) setProBarRate();
  769. }
  770. break;
  771. case OPERATE_UI:
  772. /*
  773. if (temperature_change_frequency == 1) {
  774. temperature_change_frequency = 0;
  775. disp_temp_operate();
  776. }
  777. setProBarRateOpera();
  778. */
  779. break;
  780. case PAUSE_UI:
  781. /*
  782. if (temperature_change_frequency == 1) {
  783. temperature_change_frequency = 0;
  784. disp_temp_pause();
  785. }
  786. */
  787. break;
  788. case FAN_UI:
  789. if (temperature_change_frequency == 1) {
  790. temperature_change_frequency = 0;
  791. disp_fan_value();
  792. }
  793. break;
  794. case MOVE_MOTOR_UI:
  795. /*
  796. if (mksReprint.mks_printer_state == MKS_IDLE) {
  797. if ((z_high_count==1)&&(temper_error_flg != 1)) {
  798. z_high_count = 0;
  799. {
  800. memset((char *)gCfgItems.move_z_coordinate, ' ', sizeof(gCfgItems.move_z_coordinate));
  801. GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS);
  802. sprintf_P((char *)gCfgItems.move_z_coordinate, PSTR("Z: %.3f"), current_position[Z_AXIS]);
  803. GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS);
  804. }
  805. }
  806. }
  807. */
  808. break;
  809. case WIFI_UI:
  810. /*
  811. if (wifi_refresh_flg == 1) {
  812. disp_wifi_state();
  813. wifi_refresh_flg = 0;
  814. }
  815. */
  816. break;
  817. case BIND_UI:
  818. /*refresh_bind_ui();*/
  819. break;
  820. case FILAMENTCHANGE_UI:
  821. /*
  822. if (temperature_change_frequency) {
  823. temperature_change_frequency = 0;
  824. disp_filament_sprayer_temp();
  825. }
  826. */
  827. break;
  828. case DIALOG_UI:
  829. /*filament_dialog_handle();
  830. wifi_scan_handle();*/
  831. break;
  832. case MESHLEVELING_UI:
  833. /*disp_zpos();*/
  834. break;
  835. case HARDWARE_TEST_UI:
  836. break;
  837. case WIFI_LIST_UI:
  838. /*
  839. if (wifi_refresh_flg == 1) {
  840. disp_wifi_list();
  841. wifi_refresh_flg = 0;
  842. }
  843. */
  844. break;
  845. case KEY_BOARD_UI:
  846. /*update_password_disp();
  847. update_join_state_disp();*/
  848. break;
  849. case TIPS_UI:
  850. /*
  851. switch (tips_type) {
  852. case TIPS_TYPE_JOINING:
  853. if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[wifi_list.nameIndex]) == 0) {
  854. tips_disp.timer = TIPS_TIMER_STOP;
  855. tips_disp.timer_count = 0;
  856. Clear_Tips();
  857. tips_type = TIPS_TYPE_WIFI_CONECTED;
  858. draw_Tips();
  859. }
  860. if (tips_disp.timer_count >= 30) {
  861. tips_disp.timer = TIPS_TIMER_STOP;
  862. tips_disp.timer_count = 0;
  863. Clear_Tips();
  864. tips_type = TIPS_TYPE_TAILED_JOIN;
  865. draw_Tips();
  866. }
  867. break;
  868. case TIPS_TYPE_TAILED_JOIN:
  869. if (tips_disp.timer_count >= 3) {
  870. tips_disp.timer = TIPS_TIMER_STOP;
  871. tips_disp.timer_count = 0;
  872. last_disp_state = TIPS_UI;
  873. Clear_Tips();
  874. draw_Wifi_list();
  875. }
  876. break;
  877. case TIPS_TYPE_WIFI_CONECTED:
  878. if (tips_disp.timer_count >= 3) {
  879. tips_disp.timer = TIPS_TIMER_STOP;
  880. tips_disp.timer_count = 0;
  881. last_disp_state = TIPS_UI;
  882. Clear_Tips();
  883. draw_Wifi();
  884. }
  885. break;
  886. default: break;
  887. }
  888. */
  889. break;
  890. case BABY_STEP_UI:
  891. /*
  892. if (temperature_change_frequency == 1) {
  893. temperature_change_frequency = 0;
  894. disp_z_offset_value();
  895. }
  896. */
  897. break;
  898. default: break;
  899. }
  900. print_time_run();
  901. }
  902. void clear_cur_ui() {
  903. last_disp_state = disp_state_stack._disp_state[disp_state_stack._disp_index];
  904. switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) {
  905. case PRINT_READY_UI:
  906. //Get_Temperature_Flg = 0;
  907. lv_clear_ready_print();
  908. break;
  909. case PRINT_FILE_UI:
  910. lv_clear_print_file();
  911. break;
  912. case PRINTING_UI:
  913. lv_clear_printing();
  914. break;
  915. case MOVE_MOTOR_UI:
  916. lv_clear_move_motor();
  917. break;
  918. case OPERATE_UI:
  919. lv_clear_operation();
  920. break;
  921. case PAUSE_UI:
  922. //Clear_pause();
  923. break;
  924. case EXTRUSION_UI:
  925. lv_clear_extrusion();
  926. break;
  927. case PRE_HEAT_UI:
  928. lv_clear_preHeat();
  929. break;
  930. case CHANGE_SPEED_UI:
  931. lv_clear_change_speed();
  932. break;
  933. case FAN_UI:
  934. lv_clear_fan();
  935. break;
  936. case SET_UI:
  937. lv_clear_set();
  938. break;
  939. case ZERO_UI:
  940. lv_clear_home();
  941. break;
  942. case SPRAYER_UI:
  943. //Clear_Sprayer();
  944. break;
  945. case MACHINE_UI:
  946. //Clear_Machine();
  947. break;
  948. case LANGUAGE_UI:
  949. lv_clear_language();
  950. break;
  951. case ABOUT_UI:
  952. lv_clear_about();
  953. break;
  954. case LOG_UI:
  955. //Clear_Connect();
  956. break;
  957. case DISK_UI:
  958. //Clear_Disk();
  959. break;
  960. case WIFI_UI:
  961. //Clear_Wifi();
  962. break;
  963. case MORE_UI:
  964. //Clear_more();
  965. break;
  966. case FILETRANSFER_UI:
  967. //Clear_fileTransfer();
  968. break;
  969. case DIALOG_UI:
  970. lv_clear_dialog();
  971. break;
  972. case FILETRANSFERSTATE_UI:
  973. //Clear_WifiFileTransferdialog();
  974. break;
  975. case PRINT_MORE_UI:
  976. //Clear_Printmore();
  977. break;
  978. case LEVELING_UI:
  979. lv_clear_manualLevel();
  980. break;
  981. case BIND_UI:
  982. //Clear_Bind();
  983. break;
  984. case ZOFFSET_UI:
  985. //Clear_Zoffset();
  986. break;
  987. case TOOL_UI:
  988. lv_clear_tool();
  989. break;
  990. case MESHLEVELING_UI:
  991. //Clear_MeshLeveling();
  992. break;
  993. case HARDWARE_TEST_UI:
  994. //Clear_Hardwaretest();
  995. break;
  996. case WIFI_LIST_UI:
  997. //Clear_Wifi_list();
  998. break;
  999. case KEY_BOARD_UI:
  1000. //Clear_Keyboard();
  1001. break;
  1002. case TIPS_UI:
  1003. //Clear_Tips();
  1004. break;
  1005. case MACHINE_PARA_UI:
  1006. lv_clear_machine_para();
  1007. break;
  1008. case MACHINE_SETTINGS_UI:
  1009. lv_clear_machine_settings();
  1010. break;
  1011. case TEMPERATURE_SETTINGS_UI:
  1012. //Clear_TemperatureSettings();
  1013. break;
  1014. case MOTOR_SETTINGS_UI:
  1015. lv_clear_motor_settings();
  1016. break;
  1017. case MACHINETYPE_UI:
  1018. //Clear_MachineType();
  1019. break;
  1020. case STROKE_UI:
  1021. //Clear_Stroke();
  1022. break;
  1023. case HOME_DIR_UI:
  1024. //Clear_HomeDir();
  1025. break;
  1026. case ENDSTOP_TYPE_UI:
  1027. //Clear_EndstopType();
  1028. break;
  1029. case FILAMENT_SETTINGS_UI:
  1030. //Clear_FilamentSettings();
  1031. break;
  1032. case LEVELING_SETTIGNS_UI:
  1033. //Clear_LevelingSettings();
  1034. break;
  1035. case LEVELING_PARA_UI:
  1036. //Clear_LevelingPara();
  1037. break;
  1038. case DELTA_LEVELING_PARA_UI:
  1039. //Clear_DeltaLevelPara();
  1040. break;
  1041. case XYZ_LEVELING_PARA_UI:
  1042. //Clear_XYZLevelPara();
  1043. break;
  1044. case MAXFEEDRATE_UI:
  1045. lv_clear_max_feedrate_settings();
  1046. break;
  1047. case STEPS_UI:
  1048. lv_clear_step_settings();
  1049. break;
  1050. case ACCELERATION_UI:
  1051. lv_clear_acceleration_settings();
  1052. break;
  1053. case JERK_UI:
  1054. #if HAS_CLASSIC_JERK
  1055. lv_clear_jerk_settings();
  1056. #endif
  1057. break;
  1058. case MOTORDIR_UI:
  1059. //Clear_MotorDir();
  1060. break;
  1061. case HOMESPEED_UI:
  1062. //Clear_HomeSpeed();
  1063. break;
  1064. case NOZZLE_CONFIG_UI:
  1065. //Clear_NozzleConfig();
  1066. break;
  1067. case HOTBED_CONFIG_UI:
  1068. //Clear_HotbedConfig();
  1069. break;
  1070. case ADVANCED_UI:
  1071. lv_clear_advance_settings();
  1072. break;
  1073. case DOUBLE_Z_UI:
  1074. //Clear_DoubleZ();
  1075. break;
  1076. case ENABLE_INVERT_UI:
  1077. //Clear_EnableInvert();
  1078. break;
  1079. case NUMBER_KEY_UI:
  1080. lv_clear_number_key();
  1081. break;
  1082. case BABY_STEP_UI:
  1083. //Clear_babyStep();
  1084. break;
  1085. case PAUSE_POS_UI:
  1086. lv_clear_pause_position();
  1087. break;
  1088. #if HAS_TRINAMIC_CONFIG
  1089. case TMC_CURRENT_UI:
  1090. lv_clear_tmc_current_settings();
  1091. break;
  1092. #endif
  1093. case EEPROM_SETTINGS_UI:
  1094. lv_clear_eeprom_settings();
  1095. break;
  1096. #if HAS_STEALTHCHOP
  1097. case TMC_MODE_UI:
  1098. lv_clear_tmc_step_mode_settings();
  1099. break;
  1100. #endif
  1101. default:
  1102. break;
  1103. }
  1104. //GUI_Clear();
  1105. }
  1106. void draw_return_ui() {
  1107. if (disp_state_stack._disp_index > 0) {
  1108. disp_state_stack._disp_index--;
  1109. switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) {
  1110. case PRINT_READY_UI:
  1111. lv_draw_ready_print();
  1112. break;
  1113. case PRINT_FILE_UI:
  1114. lv_draw_print_file();
  1115. break;
  1116. case PRINTING_UI:
  1117. if (gCfgItems.from_flash_pic == 1) flash_preview_begin = 1;
  1118. else default_preview_flg = 1;
  1119. lv_draw_printing();
  1120. break;
  1121. case MOVE_MOTOR_UI:
  1122. lv_draw_move_motor();
  1123. break;
  1124. case OPERATE_UI:
  1125. lv_draw_operation();
  1126. break;
  1127. #if 1
  1128. case PAUSE_UI:
  1129. //draw_pause();
  1130. break;
  1131. #endif
  1132. case EXTRUSION_UI:
  1133. lv_draw_extrusion();
  1134. break;
  1135. case PRE_HEAT_UI:
  1136. lv_draw_preHeat();
  1137. break;
  1138. case CHANGE_SPEED_UI:
  1139. lv_draw_change_speed();
  1140. break;
  1141. case FAN_UI:
  1142. lv_draw_fan();
  1143. break;
  1144. case SET_UI:
  1145. lv_draw_set();
  1146. break;
  1147. case ZERO_UI:
  1148. lv_draw_home();
  1149. break;
  1150. case SPRAYER_UI:
  1151. //draw_Sprayer();
  1152. break;
  1153. case MACHINE_UI:
  1154. //draw_Machine();
  1155. break;
  1156. case LANGUAGE_UI:
  1157. lv_draw_language();
  1158. break;
  1159. case ABOUT_UI:
  1160. lv_draw_about();
  1161. break;
  1162. #if tan_mask
  1163. case LOG_UI:
  1164. //draw_Connect();
  1165. break;
  1166. #endif
  1167. case CALIBRATE_UI:
  1168. //draw_calibrate();
  1169. break;
  1170. case DISK_UI:
  1171. //draw_Disk();
  1172. break;
  1173. case WIFI_UI:
  1174. //draw_Wifi();
  1175. break;
  1176. case MORE_UI:
  1177. //draw_More();
  1178. break;
  1179. case PRINT_MORE_UI:
  1180. //draw_printmore();
  1181. break;
  1182. case FILAMENTCHANGE_UI:
  1183. //draw_FilamentChange();
  1184. break;
  1185. case LEVELING_UI:
  1186. lv_draw_manualLevel();
  1187. break;
  1188. case BIND_UI:
  1189. //draw_bind();
  1190. break;
  1191. #if tan_mask
  1192. case ZOFFSET_UI:
  1193. //draw_Zoffset();
  1194. break;
  1195. #endif
  1196. case TOOL_UI:
  1197. lv_draw_tool();
  1198. break;
  1199. case MESHLEVELING_UI:
  1200. //draw_meshleveling();
  1201. break;
  1202. case HARDWARE_TEST_UI:
  1203. //draw_Hardwaretest();
  1204. break;
  1205. case WIFI_LIST_UI:
  1206. //draw_Wifi_list();
  1207. break;
  1208. case KEY_BOARD_UI:
  1209. //draw_Keyboard();
  1210. break;
  1211. case TIPS_UI:
  1212. //draw_Tips();
  1213. break;
  1214. case MACHINE_PARA_UI:
  1215. lv_draw_machine_para();
  1216. break;
  1217. case MACHINE_SETTINGS_UI:
  1218. lv_draw_machine_settings();
  1219. break;
  1220. case TEMPERATURE_SETTINGS_UI:
  1221. //draw_TemperatureSettings();
  1222. break;
  1223. case MOTOR_SETTINGS_UI:
  1224. lv_draw_motor_settings();
  1225. break;
  1226. case MACHINETYPE_UI:
  1227. //draw_MachineType();
  1228. break;
  1229. case STROKE_UI:
  1230. //draw_Stroke();
  1231. break;
  1232. case HOME_DIR_UI:
  1233. //draw_HomeDir();
  1234. break;
  1235. case ENDSTOP_TYPE_UI:
  1236. //draw_EndstopType();
  1237. break;
  1238. case FILAMENT_SETTINGS_UI:
  1239. //draw_FilamentSettings();
  1240. break;
  1241. case LEVELING_SETTIGNS_UI:
  1242. //draw_LevelingSettings();
  1243. break;
  1244. case LEVELING_PARA_UI:
  1245. //draw_LevelingPara();
  1246. break;
  1247. case DELTA_LEVELING_PARA_UI:
  1248. //draw_DeltaLevelPara();
  1249. break;
  1250. case XYZ_LEVELING_PARA_UI:
  1251. //draw_XYZLevelPara();
  1252. break;
  1253. case MAXFEEDRATE_UI:
  1254. lv_draw_max_feedrate_settings();
  1255. break;
  1256. case STEPS_UI:
  1257. lv_draw_step_settings();
  1258. break;
  1259. case ACCELERATION_UI:
  1260. lv_draw_acceleration_settings();
  1261. break;
  1262. case JERK_UI:
  1263. #if HAS_CLASSIC_JERK
  1264. lv_draw_jerk_settings();
  1265. #endif
  1266. break;
  1267. case MOTORDIR_UI:
  1268. //draw_MotorDir();
  1269. break;
  1270. case HOMESPEED_UI:
  1271. //draw_HomeSpeed();
  1272. break;
  1273. case NOZZLE_CONFIG_UI:
  1274. //draw_NozzleConfig();
  1275. break;
  1276. case HOTBED_CONFIG_UI:
  1277. //draw_HotbedConfig();
  1278. break;
  1279. case ADVANCED_UI:
  1280. lv_draw_advance_settings();
  1281. break;
  1282. case DOUBLE_Z_UI:
  1283. //draw_DoubleZ();
  1284. break;
  1285. case ENABLE_INVERT_UI:
  1286. //draw_EnableInvert();
  1287. break;
  1288. case NUMBER_KEY_UI:
  1289. lv_draw_number_key();
  1290. break;
  1291. case DIALOG_UI:
  1292. //draw_dialog(DialogType);
  1293. break;
  1294. case BABY_STEP_UI:
  1295. //draw_babyStep();
  1296. break;
  1297. case PAUSE_POS_UI:
  1298. lv_draw_pause_position();
  1299. break;
  1300. #if HAS_TRINAMIC_CONFIG
  1301. case TMC_CURRENT_UI:
  1302. lv_draw_tmc_current_settings();
  1303. break;
  1304. #endif
  1305. case EEPROM_SETTINGS_UI:
  1306. lv_draw_eeprom_settings();
  1307. break;
  1308. #if HAS_STEALTHCHOP
  1309. case TMC_MODE_UI:
  1310. lv_draw_tmc_step_mode_settings();
  1311. break;
  1312. #endif
  1313. default: break;
  1314. }
  1315. }
  1316. }
  1317. #if ENABLED(SDSUPPORT)
  1318. void sd_detection() {
  1319. static bool last_sd_status;
  1320. const bool sd_status = IS_SD_INSERTED();
  1321. if (sd_status != last_sd_status) {
  1322. last_sd_status = sd_status;
  1323. if (sd_status) card.mount(); else card.release();
  1324. }
  1325. }
  1326. #endif
  1327. void lv_ex_line(lv_obj_t * line, lv_point_t *points) {
  1328. /*Copy the previous line and apply the new style*/
  1329. lv_line_set_points(line, points, 2); /*Set the points*/
  1330. lv_line_set_style(line, LV_LINE_STYLE_MAIN, &style_line);
  1331. lv_obj_align(line, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
  1332. }
  1333. extern volatile uint32_t systick_uptime_millis;
  1334. void print_time_count() {
  1335. if ((systick_uptime_millis % 1000) == 0)
  1336. if (print_time.start == 1) print_time.seconds++;
  1337. }
  1338. void LV_TASK_HANDLER() {
  1339. //lv_tick_inc(1);
  1340. lv_task_handler();
  1341. if (mks_test_flag == 0x1e) mks_hardware_test();
  1342. #if HAS_GCODE_PREVIEW
  1343. disp_pre_gcode(2, 36);
  1344. #endif
  1345. GUI_RefreshPage();
  1346. //sd_detection();
  1347. }
  1348. #endif // HAS_TFT_LVGL_UI