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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. */
  26. #include "dwin_lcd.h"
  27. #include "../common/dwin_set.h"
  28. #include "../common/dwin_font.h"
  29. #include "../common/dwin_color.h"
  30. #include "../common/encoder.h"
  31. #include "../../../libs/BL24CXX.h"
  32. #include "../../../inc/MarlinConfigPre.h"
  33. //#define DWIN_CREALITY_LCD_CUSTOM_ICONS
  34. enum processID : uint8_t {
  35. Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait
  36. };
  37. enum PopupID : uint8_t {
  38. Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot,
  39. Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, PIDWait, Resuming, ManualProbing,
  40. FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom
  41. };
  42. enum menuID : uint8_t {
  43. MainMenu,
  44. Prepare,
  45. Move,
  46. HomeMenu,
  47. ManualLevel,
  48. ZOffset,
  49. Preheat,
  50. ChangeFilament,
  51. MenuCustom,
  52. Control,
  53. TempMenu,
  54. PID,
  55. HotendPID,
  56. BedPID,
  57. #if HAS_PREHEAT
  58. #define _PREHEAT_ID(N) Preheat##N,
  59. REPEAT_1(PREHEAT_COUNT, _PREHEAT_ID)
  60. #endif
  61. Motion,
  62. HomeOffsets,
  63. MaxSpeed,
  64. MaxAcceleration,
  65. MaxJerk,
  66. Steps,
  67. Visual,
  68. ColorSettings,
  69. Advanced,
  70. ProbeMenu,
  71. Info,
  72. Leveling,
  73. LevelManual,
  74. LevelView,
  75. MeshViewer,
  76. LevelSettings,
  77. ManualMesh,
  78. UBLMesh,
  79. InfoMain,
  80. Tune,
  81. PreheatHotend
  82. };
  83. // Custom icons
  84. #if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS)
  85. // index of every custom icon should be >= CUSTOM_ICON_START
  86. #define CUSTOM_ICON_START ICON_Checkbox_F
  87. #define ICON_Checkbox_F 200
  88. #define ICON_Checkbox_T 201
  89. #define ICON_Fade 202
  90. #define ICON_Mesh 203
  91. #define ICON_Tilt 204
  92. #define ICON_Brightness 205
  93. #define ICON_AxisD 249
  94. #define ICON_AxisBR 250
  95. #define ICON_AxisTR 251
  96. #define ICON_AxisBL 252
  97. #define ICON_AxisTL 253
  98. #define ICON_AxisC 254
  99. #else
  100. #define ICON_Fade ICON_Version
  101. #define ICON_Mesh ICON_Version
  102. #define ICON_Tilt ICON_Version
  103. #define ICON_Brightness ICON_Version
  104. #define ICON_AxisD ICON_Axis
  105. #define ICON_AxisBR ICON_Axis
  106. #define ICON_AxisTR ICON_Axis
  107. #define ICON_AxisBL ICON_Axis
  108. #define ICON_AxisTL ICON_Axis
  109. #define ICON_AxisC ICON_Axis
  110. #endif
  111. enum colorID : uint8_t {
  112. Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black
  113. };
  114. #define Custom_Colors 10
  115. #define Color_Aqua RGB(0x00,0x3F,0x1F)
  116. #define Color_Light_White 0xBDD7
  117. #define Color_Green RGB(0x00,0x3F,0x00)
  118. #define Color_Light_Green 0x3460
  119. #define Color_Cyan 0x07FF
  120. #define Color_Light_Cyan 0x04F3
  121. #define Color_Blue 0x015F
  122. #define Color_Light_Blue 0x3A6A
  123. #define Color_Magenta 0xF81F
  124. #define Color_Light_Magenta 0x9813
  125. #define Color_Light_Red 0x8800
  126. #define Color_Orange 0xFA20
  127. #define Color_Light_Orange 0xFBC0
  128. #define Color_Light_Yellow 0x8BE0
  129. #define Color_Brown 0xCC27
  130. #define Color_Light_Brown 0x6204
  131. #define Color_Black 0x0000
  132. #define Color_Grey 0x18E3
  133. #define Check_Color 0x4E5C // Check-box check color
  134. #define Confirm_Color 0x34B9
  135. #define Cancel_Color 0x3186
  136. class CrealityDWINClass {
  137. public:
  138. static constexpr size_t eeprom_data_size = 48;
  139. static struct EEPROM_Settings { // use bit fields to save space, max 48 bytes
  140. bool time_format_textual : 1;
  141. #if ENABLED(AUTO_BED_LEVELING_UBL)
  142. uint8_t tilt_grid_size : 3;
  143. #endif
  144. uint16_t corner_pos : 10;
  145. uint8_t cursor_color : 4;
  146. uint8_t menu_split_line : 4;
  147. uint8_t menu_top_bg : 4;
  148. uint8_t menu_top_txt : 4;
  149. uint8_t highlight_box : 4;
  150. uint8_t progress_percent : 4;
  151. uint8_t progress_time : 4;
  152. uint8_t status_bar_text : 4;
  153. uint8_t status_area_text : 4;
  154. uint8_t coordinates_text : 4;
  155. uint8_t coordinates_split_line : 4;
  156. } eeprom_settings;
  157. static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" };
  158. static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" };
  159. static void Clear_Screen(uint8_t e=3);
  160. static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10);
  161. static void Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected=false, bool color=false);
  162. static uint16_t GetColor(uint8_t color, uint16_t original, bool light=false);
  163. static void Draw_Checkbox(uint8_t row, bool value);
  164. static void Draw_Title(const char * title);
  165. static void Draw_Title(FSTR_P const title);
  166. 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);
  167. 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);
  168. static void Draw_Menu(uint8_t menu, uint8_t select=0, uint8_t scroll=0);
  169. static void Redraw_Menu(bool lastprocess=true, bool lastselection=false, bool lastmenu=false);
  170. static void Redraw_Screen();
  171. static void Main_Menu_Icons();
  172. static void Draw_Main_Menu(uint8_t select=0);
  173. static void Print_Screen_Icons();
  174. static void Draw_Print_Screen();
  175. static void Draw_Print_Filename(const bool reset=false);
  176. static void Draw_Print_ProgressBar();
  177. #if ENABLED(SET_REMAINING_TIME)
  178. static void Draw_Print_ProgressRemain();
  179. #endif
  180. static void Draw_Print_ProgressElapsed();
  181. static void Draw_Print_confirm();
  182. static void Draw_SD_Item(uint8_t item, uint8_t row);
  183. static void Draw_SD_List(bool removed=false);
  184. static void Draw_Status_Area(bool icons=false);
  185. static void Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, uint8_t mode, uint8_t icon=0);
  186. static void Popup_Select();
  187. static void Update_Status_Bar(bool refresh=false);
  188. #if ENABLED(AUTO_BED_LEVELING_UBL)
  189. 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);
  190. static void Set_Mesh_Viewer_Status();
  191. #endif
  192. static FSTR_P Get_Menu_Title(uint8_t menu);
  193. static uint8_t Get_Menu_Size(uint8_t menu);
  194. static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true);
  195. static void Popup_Handler(PopupID popupid, bool option = false);
  196. static void Confirm_Handler(PopupID popupid);
  197. static void Main_Menu_Control();
  198. static void Menu_Control();
  199. static void Value_Control();
  200. static void Option_Control();
  201. static void File_Control();
  202. static void Print_Screen_Control();
  203. static void Popup_Control();
  204. static void Confirm_Control();
  205. static void Setup_Value(float value, float min, float max, float unit, uint8_t type);
  206. static void Modify_Value(float &value, float min, float max, float unit, void (*f)()=nullptr);
  207. static void Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()=nullptr);
  208. static void Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()=nullptr);
  209. static void Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()=nullptr);
  210. static void Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()=nullptr);
  211. static void Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()=nullptr);
  212. static void Modify_Option(uint8_t value, const char * const * options, uint8_t max);
  213. static void Update_Status(const char * const text);
  214. static void Start_Print(bool sd);
  215. static void Stop_Print();
  216. static void Update();
  217. static void State_Update();
  218. static void Screen_Update();
  219. static void AudioFeedback(const bool success=true);
  220. static void Save_Settings(char *buff);
  221. static void Load_Settings(const char *buff);
  222. static void Reset_Settings();
  223. };
  224. extern CrealityDWINClass CrealityDWIN;