My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

draw_ui.cpp 43KB

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