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.h 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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. #pragma once
  23. #include <lvgl.h>
  24. #include <stdint.h>
  25. #include <string.h>
  26. // the colors of the last MKS Ui
  27. #undef LV_COLOR_BACKGROUND
  28. #define LV_COLOR_BACKGROUND LV_COLOR_MAKE(0x1A, 0x1A, 0x1A) // LV_COLOR_MAKE(0x00, 0x00, 0x00)
  29. #define TFT_LV_PARA_BACK_BODY_COLOR LV_COLOR_MAKE(0x4A, 0x52, 0xFF)
  30. #include "tft_lvgl_configuration.h"
  31. #include "tft_multi_language.h"
  32. #include "pic_manager.h"
  33. #include "draw_ready_print.h"
  34. #include "draw_language.h"
  35. #include "draw_set.h"
  36. #include "draw_tool.h"
  37. #include "draw_print_file.h"
  38. #include "draw_dialog.h"
  39. #include "draw_printing.h"
  40. #include "draw_operation.h"
  41. #include "draw_preHeat.h"
  42. #include "draw_extrusion.h"
  43. #include "draw_home.h"
  44. #include "draw_move_motor.h"
  45. #include "draw_fan.h"
  46. #include "draw_about.h"
  47. #include "draw_change_speed.h"
  48. #include "draw_manuaLevel.h"
  49. #include "draw_error_message.h"
  50. #include "printer_operation.h"
  51. #include "draw_machine_para.h"
  52. #include "draw_machine_settings.h"
  53. #include "draw_motor_settings.h"
  54. #include "draw_advance_settings.h"
  55. #include "draw_acceleration_settings.h"
  56. #include "draw_number_key.h"
  57. #include "draw_jerk_settings.h"
  58. #include "draw_pause_position.h"
  59. #include "draw_step_settings.h"
  60. #include "draw_tmc_current_settings.h"
  61. #include "draw_eeprom_settings.h"
  62. #include "draw_max_feedrate_settings.h"
  63. #include "draw_tmc_step_mode_settings.h"
  64. #include "draw_level_settings.h"
  65. #include "draw_manual_level_pos_settings.h"
  66. #include "draw_auto_level_offset_settings.h"
  67. #include "draw_filament_change.h"
  68. #include "draw_filament_settings.h"
  69. #include "draw_homing_sensitivity_settings.h"
  70. #include "draw_baby_stepping.h"
  71. #include "draw_keyboard.h"
  72. #include "draw_encoder_settings.h"
  73. #if ENABLED(USE_WIFI_FUNCTION)
  74. #include "wifiSerial.h"
  75. #include "wifi_module.h"
  76. #include "wifi_upload.h"
  77. #include "draw_wifi_settings.h"
  78. #include "draw_wifi.h"
  79. #include "draw_wifi_list.h"
  80. #include "draw_wifi_tips.h"
  81. #endif
  82. #include "../../inc/MarlinConfigPre.h"
  83. #define FILE_SYS_USB 0
  84. #define FILE_SYS_SD 1
  85. #define TICK_CYCLE 1
  86. #define PARA_SEL_ICON_TEXT_COLOR LV_COLOR_MAKE(0x4A, 0x52, 0xFF);
  87. #define TFT35
  88. #ifdef TFT35
  89. #define TFT_WIDTH 480
  90. #define TFT_HEIGHT 320
  91. #define titleHeight 36 // TFT_screen.title_high
  92. #define INTERVAL_H 2 // TFT_screen.gap_h // 2
  93. #define INTERVAL_V 2 // TFT_screen.gap_v // 2
  94. #define BTN_X_PIXEL 117 // TFT_screen.btn_x_pixel
  95. #define BTN_Y_PIXEL 140 // TFT_screen.btn_y_pixel
  96. #define SIMPLE_FIRST_PAGE_GRAP 30
  97. #define BUTTON_TEXT_Y_OFFSET -20
  98. #define TITLE_XPOS 3 // TFT_screen.title_xpos
  99. #define TITLE_YPOS 5 // TFT_screen.title_ypos
  100. #define FILE_BTN_CNT 6
  101. #define OTHER_BTN_XPIEL 117
  102. #define OTHER_BTN_YPIEL 92
  103. #define FILE_PRE_PIC_X_OFFSET 8
  104. #define FILE_PRE_PIC_Y_OFFSET 0
  105. #define PREVIEW_LITTLE_PIC_SIZE 40910 // 400*100+9*101+1
  106. #define PREVIEW_SIZE 202720 // (PREVIEW_LITTLE_PIC_SIZE+800*200+201*9+1)
  107. // machine parameter ui
  108. #define PARA_UI_POS_X 10
  109. #define PARA_UI_POS_Y 50
  110. #define PARA_UI_SIZE_X 450
  111. #define PARA_UI_SIZE_Y 40
  112. #define PARA_UI_ARROW_V 12
  113. #define PARA_UI_BACL_POS_X 400
  114. #define PARA_UI_BACL_POS_Y 270
  115. #define PARA_UI_TURN_PAGE_POS_X 320
  116. #define PARA_UI_TURN_PAGE_POS_Y 270
  117. #define PARA_UI_VALUE_SIZE_X 370
  118. #define PARA_UI_VALUE_POS_X 400
  119. #define PARA_UI_VALUE_V 5
  120. #define PARA_UI_STATE_POS_X 380
  121. #define PARA_UI_STATE_V 2
  122. #define PARA_UI_VALUE_SIZE_X_2 200
  123. #define PARA_UI_VALUE_POS_X_2 320
  124. #define PARA_UI_VALUE_V_2 5
  125. #define PARA_UI_VALUE_BTN_X_SIZE 70
  126. #define PARA_UI_VALUE_BTN_Y_SIZE 28
  127. #define PARA_UI_BACK_BTN_X_SIZE 70
  128. #define PARA_UI_BACK_BTN_Y_SIZE 40
  129. #else // ifdef TFT35
  130. #define TFT_WIDTH 320
  131. #define TFT_HEIGHT 240
  132. #endif // ifdef TFT35
  133. #ifdef __cplusplus
  134. extern "C" { /* C-declarations for C++ */
  135. #endif
  136. extern char public_buf_m[100];
  137. extern char public_buf_l[30];
  138. typedef struct {
  139. uint32_t spi_flash_flag;
  140. uint8_t disp_rotation_180;
  141. bool multiple_language;
  142. uint8_t language;
  143. uint8_t leveling_mode;
  144. bool from_flash_pic;
  145. bool finish_power_off;
  146. bool pause_reprint;
  147. uint8_t wifi_mode_sel;
  148. uint8_t fileSysType;
  149. uint8_t wifi_type;
  150. bool cloud_enable;
  151. bool encoder_enable;
  152. int levelingPos[5][2];
  153. int filamentchange_load_length;
  154. int filamentchange_load_speed;
  155. int filamentchange_unload_length;
  156. int filamentchange_unload_speed;
  157. int filament_limit_temper;
  158. float pausePosX;
  159. float pausePosY;
  160. float pausePosZ;
  161. uint32_t curFilesize;
  162. } CFG_ITMES;
  163. typedef struct {
  164. uint8_t curTempType : 1,
  165. curSprayerChoose : 3,
  166. stepHeat : 4;
  167. uint8_t leveling_first_time : 1,
  168. para_ui_page:1,
  169. configWifi:1,
  170. command_send:1,
  171. filament_load_heat_flg:1,
  172. filament_heat_completed_load:1,
  173. filament_unload_heat_flg:1,
  174. filament_heat_completed_unload:1;
  175. uint8_t filament_loading_completed:1,
  176. filament_unloading_completed:1,
  177. filament_loading_time_flg:1,
  178. filament_unloading_time_flg:1,
  179. curSprayerChoose_bak:4;
  180. uint8_t wifi_name[32];
  181. uint8_t wifi_key[64];
  182. uint8_t cloud_hostUrl[96];
  183. uint8_t extruStep;
  184. uint8_t extruSpeed;
  185. uint8_t print_state;
  186. uint8_t stepPrintSpeed;
  187. uint8_t waitEndMoves;
  188. uint8_t dialogType;
  189. uint8_t F[4];
  190. uint8_t filament_rate;
  191. uint16_t moveSpeed;
  192. uint16_t cloud_port;
  193. uint16_t moveSpeed_bak;
  194. uint32_t totalSend;
  195. uint32_t filament_loading_time;
  196. uint32_t filament_unloading_time;
  197. uint32_t filament_loading_time_cnt;
  198. uint32_t filament_unloading_time_cnt;
  199. float move_dist;
  200. float desireSprayerTempBak;
  201. float current_x_position_bak;
  202. float current_y_position_bak;
  203. float current_e_position_bak;
  204. } UI_CFG;
  205. typedef enum {
  206. MAIN_UI,
  207. PRINT_READY_UI,
  208. PRINT_FILE_UI,
  209. PRINTING_UI,
  210. MOVE_MOTOR_UI,
  211. OPERATE_UI,
  212. PAUSE_UI,
  213. EXTRUSION_UI,
  214. FAN_UI,
  215. PRE_HEAT_UI,
  216. CHANGE_SPEED_UI,
  217. TEMP_UI,
  218. SET_UI,
  219. ZERO_UI,
  220. SPRAYER_UI,
  221. MACHINE_UI,
  222. LANGUAGE_UI,
  223. ABOUT_UI,
  224. LOG_UI,
  225. DISK_UI,
  226. CALIBRATE_UI,
  227. DIALOG_UI,
  228. WIFI_UI,
  229. MORE_UI,
  230. FILETRANSFER_UI,
  231. FILETRANSFERSTATE_UI,
  232. PRINT_MORE_UI,
  233. FILAMENTCHANGE_UI,
  234. LEVELING_UI,
  235. MESHLEVELING_UI,
  236. BIND_UI,
  237. #if HAS_BED_PROBE
  238. NOZZLE_PROBE_OFFSET_UI,
  239. #endif
  240. TOOL_UI,
  241. HARDWARE_TEST_UI,
  242. WIFI_LIST_UI,
  243. KEY_BOARD_UI,
  244. WIFI_TIPS_UI,
  245. MACHINE_PARA_UI,
  246. MACHINE_SETTINGS_UI,
  247. TEMPERATURE_SETTINGS_UI,
  248. MOTOR_SETTINGS_UI,
  249. MACHINETYPE_UI,
  250. STROKE_UI,
  251. HOME_DIR_UI,
  252. ENDSTOP_TYPE_UI,
  253. FILAMENT_SETTINGS_UI,
  254. LEVELING_SETTIGNS_UI,
  255. LEVELING_PARA_UI,
  256. DELTA_LEVELING_PARA_UI,
  257. MANUAL_LEVELING_POSIGION_UI,
  258. MAXFEEDRATE_UI,
  259. STEPS_UI,
  260. ACCELERATION_UI,
  261. JERK_UI,
  262. MOTORDIR_UI,
  263. HOMESPEED_UI,
  264. NOZZLE_CONFIG_UI,
  265. HOTBED_CONFIG_UI,
  266. ADVANCED_UI,
  267. DOUBLE_Z_UI,
  268. ENABLE_INVERT_UI,
  269. NUMBER_KEY_UI,
  270. BABY_STEP_UI,
  271. ERROR_MESSAGE_UI,
  272. PAUSE_POS_UI,
  273. TMC_CURRENT_UI,
  274. TMC_MODE_UI,
  275. EEPROM_SETTINGS_UI,
  276. WIFI_SETTINGS_UI,
  277. HOMING_SENSITIVITY_UI,
  278. ENCODER_SETTINGS_UI
  279. } DISP_STATE;
  280. typedef struct {
  281. DISP_STATE _disp_state[100];
  282. int _disp_index;
  283. } DISP_STATE_STACK;
  284. typedef struct {
  285. int16_t days;
  286. uint16_t hours;
  287. uint8_t minutes;
  288. volatile int8_t seconds;
  289. int8_t ms_10;
  290. int8_t start;
  291. } PRINT_TIME;
  292. extern PRINT_TIME print_time;
  293. typedef enum {
  294. PrintAcceleration,
  295. RetractAcceleration,
  296. TravelAcceleration,
  297. XAcceleration,
  298. YAcceleration,
  299. ZAcceleration,
  300. E0Acceleration,
  301. E1Acceleration,
  302. XMaxFeedRate,
  303. YMaxFeedRate,
  304. ZMaxFeedRate,
  305. E0MaxFeedRate,
  306. E1MaxFeedRate,
  307. XJerk,
  308. YJerk,
  309. ZJerk,
  310. EJerk,
  311. Xstep,
  312. Ystep,
  313. Zstep,
  314. E0step,
  315. E1step,
  316. Xcurrent,
  317. Ycurrent,
  318. Zcurrent,
  319. E0current,
  320. E1current,
  321. pause_pos_x,
  322. pause_pos_y,
  323. pause_pos_z,
  324. level_pos_x1,
  325. level_pos_y1,
  326. level_pos_x2,
  327. level_pos_y2,
  328. level_pos_x3,
  329. level_pos_y3,
  330. level_pos_x4,
  331. level_pos_y4,
  332. level_pos_x5,
  333. level_pos_y5
  334. #if HAS_BED_PROBE
  335. ,
  336. x_offset,
  337. y_offset,
  338. z_offset
  339. #endif
  340. ,
  341. load_length,
  342. load_speed,
  343. unload_length,
  344. unload_speed,
  345. filament_temp,
  346. x_sensitivity,
  347. y_sensitivity,
  348. z_sensitivity,
  349. z2_sensitivity
  350. } num_key_value_state;
  351. extern num_key_value_state value;
  352. typedef enum {
  353. wifiName,
  354. wifiPassWord,
  355. wifiConfig,
  356. gcodeCommand
  357. } keyboard_value_state;
  358. extern keyboard_value_state keyboard_value;
  359. extern CFG_ITMES gCfgItems;
  360. extern UI_CFG uiCfg;
  361. extern DISP_STATE disp_state;
  362. extern DISP_STATE last_disp_state;
  363. extern DISP_STATE_STACK disp_state_stack;
  364. extern lv_style_t tft_style_scr;
  365. extern lv_style_t tft_style_label_pre;
  366. extern lv_style_t tft_style_label_rel;
  367. extern lv_style_t style_line;
  368. extern lv_style_t style_para_value_pre;
  369. extern lv_style_t style_para_value_rel;
  370. extern lv_style_t style_num_key_pre;
  371. extern lv_style_t style_num_key_rel;
  372. extern lv_style_t style_num_text;
  373. extern lv_style_t style_sel_text;
  374. extern lv_style_t style_para_value;
  375. extern lv_style_t style_para_back;
  376. extern lv_style_t lv_bar_style_indic;
  377. extern lv_point_t line_points[4][2];
  378. extern void gCfgItems_init();
  379. extern void ui_cfg_init();
  380. extern void tft_style_init();
  381. extern char *creat_title_text(void);
  382. extern void preview_gcode_prehandle(char *path);
  383. extern void update_spi_flash();
  384. extern void update_gcode_command(int addr,uint8_t *s);
  385. extern void get_gcode_command(int addr,uint8_t *d);
  386. #if HAS_GCODE_PREVIEW
  387. extern void disp_pre_gcode(int xpos_pixel, int ypos_pixel);
  388. #endif
  389. extern void GUI_RefreshPage();
  390. extern void clear_cur_ui();
  391. extern void draw_return_ui();
  392. extern void sd_detection();
  393. extern void gCfg_to_spiFlah();
  394. extern void print_time_count();
  395. extern void LV_TASK_HANDLER();
  396. extern void lv_ex_line(lv_obj_t * line, lv_point_t *points);
  397. #ifdef __cplusplus
  398. } /* C-declarations for C++ */
  399. #endif