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 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2021 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. * lcd/e3v2/jyersui/dwin.h
  25. * JYERSUI Author: Jacob Myers
  26. *
  27. * JYERSUI Enhanced by LCH-77
  28. * Version: 1.9
  29. * Date: Jun 16, 2022
  30. */
  31. #include "dwin_defines.h"
  32. #include "../../../inc/MarlinConfig.h"
  33. enum processID : uint8_t {
  34. Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait, Locked, Cancel, Keyboard
  35. };
  36. enum PopupID : uint8_t {
  37. Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot,
  38. Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, Resuming, ManualProbing,
  39. FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom, ESDiagPopup, PrintConfirm,
  40. PIDWait, PIDWaitH, PIDWaitB, BadextruderNumber, TempTooHigh, PIDTimeout, PIDDone
  41. };
  42. enum menuID : uint8_t {
  43. MainMenu,
  44. Prepare,
  45. Move,
  46. HomeMenu,
  47. ManualLevel,
  48. ZOffset,
  49. Preheat,
  50. ChangeFilament,
  51. HostActions,
  52. MenuCustom,
  53. Control,
  54. TempMenu,
  55. PID,
  56. HotendPID,
  57. BedPID,
  58. #if HAS_PREHEAT
  59. #define _PREHEAT_ID(N) Preheat##N,
  60. REPEAT_1(PREHEAT_COUNT, _PREHEAT_ID)
  61. #endif
  62. Motion,
  63. HomeOffsets,
  64. MaxSpeed,
  65. MaxAcceleration,
  66. #if HAS_CLASSIC_JERK
  67. MaxJerk,
  68. #endif
  69. #if HAS_JUNCTION_DEVIATION
  70. JDmenu,
  71. #endif
  72. Steps,
  73. #if ENABLED(FWRETRACT)
  74. FwRetraction,
  75. #endif
  76. Visual,
  77. ColorSettings,
  78. HostSettings,
  79. ActionCommands,
  80. Advanced,
  81. #if HAS_BED_PROBE
  82. ProbeMenu,
  83. #endif
  84. Info,
  85. #if HAS_MESH
  86. Leveling,
  87. LevelManual,
  88. LevelView,
  89. MeshViewer,
  90. LevelSettings,
  91. #if ENABLED(PROBE_MANUALLY)
  92. ManualMesh,
  93. #endif
  94. #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE
  95. UBLMesh,
  96. #endif
  97. #endif
  98. InfoMain,
  99. Tune,
  100. PreheatHotend,
  101. #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU)
  102. Ledsmenu,
  103. #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS)
  104. CaseLightmenu,
  105. #endif
  106. #if ENABLED(LED_CONTROL_MENU)
  107. LedControlmenu,
  108. #if HAS_COLOR_LEDS
  109. #if ENABLED(LED_COLOR_PRESETS)
  110. LedControlpresets,
  111. #else
  112. LedControlcustom,
  113. #endif
  114. #endif
  115. #endif
  116. #endif
  117. };
  118. typedef struct {
  119. // Flags
  120. bool flag_tune = false;
  121. bool auto_fw_retract = false;
  122. bool printing = false;
  123. bool paused = false;
  124. bool sdprint = false;
  125. bool livemove = false;
  126. bool liveadjust = false;
  127. bool probe_deployed = false;
  128. // Auxiliary values
  129. AxisEnum axis = X_AXIS; // Axis Select
  130. int16_t pausetemp = 0;
  131. int16_t pausebed = 0;
  132. int16_t pausefan = 0;
  133. uint8_t preheatmode = 0;
  134. uint8_t zoffsetmode = 0;
  135. float zoffsetvalue = 0;
  136. uint8_t gridpoint;
  137. float corner_avg;
  138. float corner_pos;
  139. float zval;
  140. #if ENABLED(PREHEAT_BEFORE_LEVELING)
  141. uint8_t LevelingTempmode = 0;
  142. #endif
  143. #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS)
  144. uint32_t LED_Color = Def_Leds_Color;
  145. #endif
  146. #if HAS_PID_HEATING
  147. uint16_t PID_e_temp = 180;
  148. uint16_t PID_bed_temp = 60;
  149. #endif
  150. } temp_val_t;
  151. extern temp_val_t temp_val;
  152. #define Custom_Colors 10
  153. enum colorID : uint8_t {
  154. Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black
  155. };
  156. enum pidresult_t : uint8_t { PID_STARTED, PID_EXTR_START, PID_BED_START, PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, PID_DONE };
  157. class CrealityDWINClass {
  158. public:
  159. static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" };
  160. static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" };
  161. static constexpr const char * const zoffset_modes[3] = { "No Live" , "OnClick", " Live" };
  162. #if ENABLED(PREHEAT_BEFORE_LEVELING)
  163. static constexpr const char * const preheat_levmodes[4] = { " Both", " Hotend", " Bed", " None" };
  164. #endif
  165. static void Clear_Screen(uint8_t e=3);
  166. static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10);
  167. static void Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected=false, bool color=false);
  168. static uint16_t GetColor(uint8_t color, uint16_t original, bool light=false);
  169. static void Draw_Checkbox(uint8_t row, bool value);
  170. static void Draw_Title(const char * title);
  171. static void Draw_Title(FSTR_P const title);
  172. static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, const char * const label1=nullptr, const char * const label2=nullptr, bool more=false, bool centered=false);
  173. static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, FSTR_P const flabel1=nullptr, FSTR_P const flabel2=nullptr, bool more=false, bool centered=false);
  174. static void Draw_Menu(uint8_t menu, uint8_t select=0, uint8_t scroll=0);
  175. static void Redraw_Menu(bool lastprocess=true, bool lastselection=false, bool lastmenu=false);
  176. static void Redraw_Screen();
  177. static void Main_Menu_Icons();
  178. static void Draw_Main_Menu(uint8_t select=0);
  179. static void Print_Screen_Icons();
  180. static void Draw_Print_Screen();
  181. static void Draw_Print_Filename(const bool reset=false);
  182. static void Draw_Print_ProgressBar();
  183. #if ENABLED(USE_M73_REMAINING_TIME)
  184. static void Draw_Print_ProgressRemain();
  185. #endif
  186. static void Draw_Print_ProgressElapsed();
  187. static void Draw_PrintDone_confirm();
  188. static void Draw_SD_Item(uint8_t item, uint8_t row);
  189. static void Draw_SD_List(bool removed=false);
  190. static void Draw_Status_Area(bool icons=false);
  191. static void Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, uint8_t mode, uint8_t icon=0);
  192. static void Popup_Select();
  193. static void Update_Status_Bar(bool refresh=false);
  194. #if ENABLED(AUTO_BED_LEVELING_UBL)
  195. static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7);
  196. static void Set_Mesh_Viewer_Status();
  197. #endif
  198. static FSTR_P Get_Menu_Title(uint8_t menu);
  199. static uint8_t Get_Menu_Size(uint8_t menu);
  200. static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true);
  201. static void Popup_Handler(PopupID popupid, bool option=false);
  202. static void Confirm_Handler(PopupID popupid, bool option=false);
  203. static void Main_Menu_Control();
  204. static void Menu_Control();
  205. static void Value_Control();
  206. static void Option_Control();
  207. static void File_Control();
  208. static void Print_Screen_Control();
  209. static void Popup_Control();
  210. static void Confirm_Control();
  211. static void Setup_Value(float value, float min, float max, float unit, uint8_t type);
  212. static void Modify_Value(float &value, float min, float max, float unit, void (*f)()=nullptr);
  213. static void Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()=nullptr);
  214. static void Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()=nullptr);
  215. static void Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()=nullptr);
  216. static void Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()=nullptr);
  217. static void Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()=nullptr);
  218. static void Modify_Option(uint8_t value, const char * const * options, uint8_t max);
  219. static void Update_Status(const char * const text);
  220. static void Update_Status(FSTR_P text);
  221. static void Start_Print(bool sd);
  222. static void Stop_Print();
  223. static void Update();
  224. static void State_Update();
  225. static void Screen_Update();
  226. static void AudioFeedback(const bool success=true);
  227. static void Save_Settings(char *buff);
  228. static void Load_Settings(const char *buff);
  229. static void Reset_Settings();
  230. static void PreheatBefore();
  231. #if HAS_ESDIAG
  232. static void DWIN_EndstopsDiag();
  233. #endif
  234. #if HAS_LOCKSCREEN
  235. static void DWIN_LockScreen();
  236. static void DWIN_UnLockScreen();
  237. static void HMI_LockScreen();
  238. #endif
  239. static void DWIN_RebootScreen();
  240. static void RebootPrinter();
  241. static void Update_Print_Filename(const char * const text);
  242. #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS)
  243. static void ApplyLEDColor();
  244. #endif
  245. #if HAS_HOSTACTION_MENUS
  246. static void Draw_String(char * string, uint8_t row, bool selected=false, bool below=false);
  247. static const uint64_t Encode_String(const char * string);
  248. static void Decode_String(uint64_t num, char * string);
  249. static void Draw_Keyboard(bool restrict, bool numeric, uint8_t selected=0, bool uppercase=false, bool lock=false);
  250. static void Draw_Keys(uint8_t index, bool selected, bool uppercase=false, bool lock=false);
  251. static void Modify_String(char * string, uint8_t maxlength, bool restrict);
  252. static void Keyboard_Control();
  253. #endif
  254. #if HAS_PIDPLOT
  255. static void DWIN_Draw_PIDPopup(const pidresult_t pidresult);
  256. #endif
  257. #if HAS_PID_HEATING
  258. static void DWIN_PidTuning(const pidresult_t pidresult);
  259. #endif
  260. };
  261. extern CrealityDWINClass CrealityDWIN;