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.

dwin.h 10.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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. /**
  24. * DWIN by Creality3D
  25. */
  26. #include "../dwin_lcd.h"
  27. #include "rotary_encoder.h"
  28. #include "../../../libs/BL24CXX.h"
  29. #include "../../../inc/MarlinConfigPre.h"
  30. #if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT
  31. #define HAS_PREHEAT 1
  32. #if PREHEAT_COUNT < 2
  33. #error "Creality DWIN requires two material preheat presets."
  34. #endif
  35. #endif
  36. enum processID : uint8_t {
  37. // Process ID
  38. MainMenu,
  39. SelectFile,
  40. Prepare,
  41. Control,
  42. Leveling,
  43. PrintProcess,
  44. AxisMove,
  45. TemperatureID,
  46. Motion,
  47. Info,
  48. Tune,
  49. #if HAS_PREHEAT
  50. PLAPreheat,
  51. ABSPreheat,
  52. #endif
  53. MaxSpeed,
  54. MaxSpeed_value,
  55. MaxAcceleration,
  56. MaxAcceleration_value,
  57. MaxJerk,
  58. MaxJerk_value,
  59. Step,
  60. Step_value,
  61. // Last Process ID
  62. Last_Prepare,
  63. // Back Process ID
  64. Back_Main,
  65. Back_Print,
  66. // Date variable ID
  67. Move_X,
  68. Move_Y,
  69. Move_Z,
  70. #if HAS_HOTEND
  71. Extruder,
  72. ETemp,
  73. #endif
  74. Homeoffset,
  75. #if HAS_HEATED_BED
  76. BedTemp,
  77. #endif
  78. #if HAS_FAN
  79. FanSpeed,
  80. #endif
  81. PrintSpeed,
  82. // Window ID
  83. Print_window,
  84. Popup_Window
  85. };
  86. // Picture ID
  87. #define Start_Process 0
  88. #define Language_English 1
  89. #define Language_Chinese 2
  90. // ICON ID
  91. #define ICON 0x09
  92. #define ICON_LOGO 0
  93. #define ICON_Print_0 1
  94. #define ICON_Print_1 2
  95. #define ICON_Prepare_0 3
  96. #define ICON_Prepare_1 4
  97. #define ICON_Control_0 5
  98. #define ICON_Control_1 6
  99. #define ICON_Leveling_0 7
  100. #define ICON_Leveling_1 8
  101. #define ICON_HotendTemp 9
  102. #define ICON_BedTemp 10
  103. #define ICON_Speed 11
  104. #define ICON_Zoffset 12
  105. #define ICON_Back 13
  106. #define ICON_File 14
  107. #define ICON_PrintTime 15
  108. #define ICON_RemainTime 16
  109. #define ICON_Setup_0 17
  110. #define ICON_Setup_1 18
  111. #define ICON_Pause_0 19
  112. #define ICON_Pause_1 20
  113. #define ICON_Continue_0 21
  114. #define ICON_Continue_1 22
  115. #define ICON_Stop_0 23
  116. #define ICON_Stop_1 24
  117. #define ICON_Bar 25
  118. #define ICON_More 26
  119. #define ICON_Axis 27
  120. #define ICON_CloseMotor 28
  121. #define ICON_Homing 29
  122. #define ICON_SetHome 30
  123. #define ICON_PLAPreheat 31
  124. #define ICON_ABSPreheat 32
  125. #define ICON_Cool 33
  126. #define ICON_Language 34
  127. #define ICON_MoveX 35
  128. #define ICON_MoveY 36
  129. #define ICON_MoveZ 37
  130. #define ICON_Extruder 38
  131. #define ICON_Temperature 40
  132. #define ICON_Motion 41
  133. #define ICON_WriteEEPROM 42
  134. #define ICON_ReadEEPROM 43
  135. #define ICON_ResumeEEPROM 44
  136. #define ICON_Info 45
  137. #define ICON_SetEndTemp 46
  138. #define ICON_SetBedTemp 47
  139. #define ICON_FanSpeed 48
  140. #define ICON_SetPLAPreheat 49
  141. #define ICON_SetABSPreheat 50
  142. #define ICON_MaxSpeed 51
  143. #define ICON_MaxAccelerated 52
  144. #define ICON_MaxJerk 53
  145. #define ICON_Step 54
  146. #define ICON_PrintSize 55
  147. #define ICON_Version 56
  148. #define ICON_Contact 57
  149. #define ICON_StockConfiguraton 58
  150. #define ICON_MaxSpeedX 59
  151. #define ICON_MaxSpeedY 60
  152. #define ICON_MaxSpeedZ 61
  153. #define ICON_MaxSpeedE 62
  154. #define ICON_MaxAccX 63
  155. #define ICON_MaxAccY 64
  156. #define ICON_MaxAccZ 65
  157. #define ICON_MaxAccE 66
  158. #define ICON_MaxSpeedJerkX 67
  159. #define ICON_MaxSpeedJerkY 68
  160. #define ICON_MaxSpeedJerkZ 69
  161. #define ICON_MaxSpeedJerkE 70
  162. #define ICON_StepX 71
  163. #define ICON_StepY 72
  164. #define ICON_StepZ 73
  165. #define ICON_StepE 74
  166. #define ICON_Setspeed 75
  167. #define ICON_SetZOffset 76
  168. #define ICON_Rectangle 77
  169. #define ICON_BLTouch 78
  170. #define ICON_TempTooLow 79
  171. #define ICON_AutoLeveling 80
  172. #define ICON_TempTooHigh 81
  173. #define ICON_NoTips_C 82
  174. #define ICON_NoTips_E 83
  175. #define ICON_Continue_C 84
  176. #define ICON_Continue_E 85
  177. #define ICON_Cancel_C 86
  178. #define ICON_Cancel_E 87
  179. #define ICON_Confirm_C 88
  180. #define ICON_Confirm_E 89
  181. #define ICON_Info_0 90
  182. #define ICON_Info_1 91
  183. /**
  184. * 3-.0:The font size, 0x00-0x09, corresponds to the font size below:
  185. * 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28
  186. * 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64
  187. */
  188. #define font6x12 0x00
  189. #define font8x16 0x01
  190. #define font10x20 0x02
  191. #define font12x24 0x03
  192. #define font14x28 0x04
  193. #define font16x32 0x05
  194. #define font20x40 0x06
  195. #define font24x48 0x07
  196. #define font28x56 0x08
  197. #define font32x64 0x09
  198. // Color
  199. #define Color_White 0xFFFF
  200. #define Color_Bg_Window 0x31E8 // Popup background color
  201. #define Color_Bg_Blue 0x1125 // Dark blue background color
  202. #define Color_Bg_Black 0x0841 // Black background color
  203. #define Popup_Text_Color 0xD6BA // Popup font background color
  204. #define Line_Color 0x3A6A // Split line color
  205. #define Rectangle_Color 0xEE2F // Blue square cursor color
  206. #define Percent_Color 0xFE29 // Percentage color
  207. #define BarFill_Color 0x10E4 // Fill color of progress bar
  208. #define Select_Color 0x33BB // Selected color
  209. extern uint8_t checkkey;
  210. extern float zprobe_zoffset;
  211. extern char print_filename[16];
  212. extern millis_t dwin_heat_time;
  213. typedef struct {
  214. TERN_(HAS_HOTEND, int16_t E_Temp = 0);
  215. TERN_(HAS_HEATED_BED, int16_t Bed_Temp = 0);
  216. TERN_(HAS_PREHEAT, int16_t Fan_speed = 0);
  217. int16_t print_speed = 100;
  218. float Max_Feedspeed = 0;
  219. float Max_Acceleration = 0;
  220. float Max_Jerk = 0;
  221. float Max_Step = 0;
  222. float Move_X_scale = 0;
  223. float Move_Y_scale = 0;
  224. float Move_Z_scale = 0;
  225. #if HAS_HOTEND
  226. float Move_E_scale = 0;
  227. #endif
  228. float offset_value = 0;
  229. char show_mode = 0; // -1: Temperature control 0: Printing temperature
  230. } HMI_value_t;
  231. typedef struct {
  232. bool language_chinese; // 0: EN, 1: CN
  233. bool pause_flag:1;
  234. bool pause_action:1;
  235. bool print_finish:1;
  236. bool done_confirm_flag:1;
  237. bool select_flag:1;
  238. bool home_flag:1;
  239. bool heat_flag:1; // 0: heating done 1: during heating
  240. #if ENABLED(PREVENT_COLD_EXTRUSION)
  241. bool ETempTooLow_flag:1;
  242. #endif
  243. #if HAS_LEVELING
  244. bool leveling_offset_flag:1;
  245. #endif
  246. #if HAS_FAN
  247. AxisEnum feedspeed_axis;
  248. #endif
  249. AxisEnum acc_axis, jerk_axis, step_axis;
  250. } HMI_Flag;
  251. extern HMI_value_t HMI_ValueStruct;
  252. extern HMI_Flag HMI_flag;
  253. // Show ICO
  254. void ICON_Print(bool show);
  255. void ICON_Prepare(bool show);
  256. void ICON_Control(bool show);
  257. void ICON_Leveling(bool show);
  258. void ICON_StartInfo(bool show);
  259. void ICON_Setting(bool show);
  260. void ICON_Pause(bool show);
  261. void ICON_Continue(bool show);
  262. void ICON_Stop(bool show);
  263. #if HAS_HOTEND || HAS_HEATED_BED
  264. // Popup message window
  265. void DWIN_Popup_Temperature(const bool toohigh);
  266. #endif
  267. #if HAS_HOTEND
  268. void Popup_Window_ETempTooLow();
  269. #endif
  270. void Popup_Window_Resume();
  271. void Popup_Window_Home(const bool parking=false);
  272. void Popup_Window_Leveling();
  273. void Goto_PrintProcess();
  274. void Goto_MainMenu();
  275. // Variable control
  276. void HMI_Move_X();
  277. void HMI_Move_Y();
  278. void HMI_Move_Z();
  279. void HMI_Move_E();
  280. void HMI_Zoffset();
  281. TERN_(HAS_HOTEND, void HMI_ETemp());
  282. TERN_(HAS_HEATED_BED, void HMI_BedTemp());
  283. TERN_(HAS_FAN, void HMI_FanSpeed());
  284. void HMI_PrintSpeed();
  285. void HMI_MaxFeedspeedXYZE();
  286. void HMI_MaxAccelerationXYZE();
  287. void HMI_MaxJerkXYZE();
  288. void HMI_StepXYZE();
  289. void update_variable();
  290. void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
  291. // SD Card
  292. void HMI_SDCardInit();
  293. void HMI_SDCardUpdate();
  294. // Main Process
  295. void Icon_print(bool value);
  296. void Icon_control(bool value);
  297. void Icon_temperature(bool value);
  298. void Icon_leveling(bool value);
  299. // Other
  300. void Draw_Status_Area(const bool with_update); // Status Area
  301. void HMI_StartFrame(const bool with_update); // Prepare the menu view
  302. void HMI_MainMenu(); // Main process screen
  303. void HMI_SelectFile(); // File page
  304. void HMI_Printing(); // Print page
  305. void HMI_Prepare(); // Prepare page
  306. void HMI_Control(); // Control page
  307. void HMI_Leveling(); // Level the page
  308. void HMI_AxisMove(); // Axis movement menu
  309. void HMI_Temperature(); // Temperature menu
  310. void HMI_Motion(); // Sports menu
  311. void HMI_Info(); // Information menu
  312. void HMI_Tune(); // Adjust the menu
  313. #if HAS_PREHEAT
  314. void HMI_PLAPreheatSetting(); // PLA warm-up setting
  315. void HMI_ABSPreheatSetting(); // ABS warm-up setting
  316. #endif
  317. void HMI_MaxSpeed(); // Maximum speed submenu
  318. void HMI_MaxAcceleration(); // Maximum acceleration submenu
  319. void HMI_MaxJerk(); // Maximum jerk speed submenu
  320. void HMI_Step(); // Transmission ratio
  321. void HMI_Init();
  322. void DWIN_Update();
  323. void EachMomentUpdate();
  324. void DWIN_HandleScreen();
  325. void DWIN_CompletedHoming();
  326. void DWIN_CompletedLeveling();