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.

DGUSDisplayDef.cpp 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. /**
  23. * lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp
  24. */
  25. #include "../../../../../inc/MarlinConfigPre.h"
  26. #if ENABLED(DGUS_LCD_UI_ORIGIN)
  27. #include "DGUSDisplayDef.h"
  28. #include "../DGUSDisplay.h"
  29. #include "../DGUSScreenHandler.h"
  30. #include "../../../../../module/temperature.h"
  31. #include "../../../../../module/motion.h"
  32. #include "../../../../../module/planner.h"
  33. #include "../../../../marlinui.h"
  34. #include "../../../ui_api.h"
  35. #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
  36. uint16_t distanceToMove = 10;
  37. #endif
  38. using namespace ExtUI;
  39. const uint16_t VPList_Boot[] PROGMEM = {
  40. VP_MARLIN_VERSION,
  41. 0x0000
  42. };
  43. const uint16_t VPList_Main[] PROGMEM = {
  44. /* VP_M117, for completeness, but it cannot be auto-uploaded. */
  45. 0x0000
  46. };
  47. const uint16_t VPList_Temp[] PROGMEM = {
  48. #if HOTENDS >= 1
  49. VP_T_E0_Is, VP_T_E0_Set,
  50. #endif
  51. #if HOTENDS >= 2
  52. VP_T_E1_Is, VP_T_E1_Set,
  53. #endif
  54. #if HAS_HEATED_BED
  55. VP_T_Bed_Is, VP_T_Bed_Set,
  56. #endif
  57. 0x0000
  58. };
  59. const uint16_t VPList_Status[] PROGMEM = {
  60. /* VP_M117, for completeness, but it cannot be auto-uploaded */
  61. #if HOTENDS >= 1
  62. VP_T_E0_Is, VP_T_E0_Set,
  63. #endif
  64. #if HOTENDS >= 2
  65. VP_T_E1_Is, VP_T_E1_Set,
  66. #endif
  67. #if HAS_HEATED_BED
  68. VP_T_Bed_Is, VP_T_Bed_Set,
  69. #endif
  70. #if HAS_FAN
  71. VP_Fan0_Percentage,
  72. #endif
  73. VP_XPos, VP_YPos, VP_ZPos,
  74. VP_Fan0_Percentage,
  75. VP_Feedrate_Percentage,
  76. VP_PrintProgress_Percentage,
  77. 0x0000
  78. };
  79. const uint16_t VPList_Status2[] PROGMEM = {
  80. // VP_M117, for completeness, but it cannot be auto-uploaded
  81. #if HOTENDS >= 1
  82. VP_Flowrate_E0,
  83. #endif
  84. #if HOTENDS >= 2
  85. VP_Flowrate_E1,
  86. #endif
  87. VP_PrintProgress_Percentage,
  88. VP_PrintTime,
  89. 0x0000
  90. };
  91. const uint16_t VPList_ManualMove[] PROGMEM = {
  92. VP_XPos, VP_YPos, VP_ZPos,
  93. 0x0000
  94. };
  95. const uint16_t VPList_ManualExtrude[] PROGMEM = {
  96. VP_EPos,
  97. 0x0000
  98. };
  99. const uint16_t VPList_FanAndFeedrate[] PROGMEM = {
  100. VP_Feedrate_Percentage, VP_Fan0_Percentage,
  101. 0x0000
  102. };
  103. const uint16_t VPList_SD_FlowRates[] PROGMEM = {
  104. VP_Flowrate_E0, VP_Flowrate_E1,
  105. 0x0000
  106. };
  107. const uint16_t VPList_SDFileList[] PROGMEM = {
  108. VP_SD_FileName0, VP_SD_FileName1, VP_SD_FileName2, VP_SD_FileName3, VP_SD_FileName4,
  109. 0x0000
  110. };
  111. const uint16_t VPList_SD_PrintManipulation[] PROGMEM = {
  112. VP_PrintProgress_Percentage, VP_PrintTime,
  113. 0x0000
  114. };
  115. const struct VPMapping VPMap[] PROGMEM = {
  116. { DGUSLCD_SCREEN_BOOT, VPList_Boot },
  117. { DGUSLCD_SCREEN_MAIN, VPList_Main },
  118. { DGUSLCD_SCREEN_TEMPERATURE, VPList_Temp },
  119. { DGUSLCD_SCREEN_STATUS, VPList_Status },
  120. { DGUSLCD_SCREEN_STATUS2, VPList_Status2 },
  121. { DGUSLCD_SCREEN_MANUALMOVE, VPList_ManualMove },
  122. { DGUSLCD_SCREEN_MANUALEXTRUDE, VPList_ManualExtrude },
  123. { DGUSLCD_SCREEN_FANANDFEEDRATE, VPList_FanAndFeedrate },
  124. { DGUSLCD_SCREEN_FLOWRATES, VPList_SD_FlowRates },
  125. { DGUSLCD_SCREEN_SDPRINTMANIPULATION, VPList_SD_PrintManipulation },
  126. { DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList },
  127. { 0 , nullptr } // List is terminated with an nullptr as table entry.
  128. };
  129. const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION;
  130. // Helper to define a DGUS_VP_Variable for common use cases.
  131. #define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=sizeof(VPADRVAR), \
  132. .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR }
  133. // Helper to define a DGUS_VP_Variable when the sizeo of the var cannot be determined automaticalyl (eg. a string)
  134. #define VPHELPER_STR(VPADR, VPADRVAR, STRLEN, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=STRLEN, \
  135. .set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR }
  136. const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
  137. // Helper to detect touch events
  138. VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr),
  139. VPHELPER(VP_SCREENCHANGE_ASK, nullptr, ScreenHandler.ScreenChangeHookIfIdle, nullptr),
  140. #if ENABLED(SDSUPPORT)
  141. VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, ScreenHandler.ScreenChangeHookIfSD, nullptr),
  142. #endif
  143. VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr),
  144. VPHELPER(VP_TEMP_ALL_OFF, nullptr, &ScreenHandler.HandleAllHeatersOff, nullptr),
  145. #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
  146. VPHELPER(VP_MOVE_OPTION, &distanceToMove, &ScreenHandler.HandleManualMoveOption, nullptr),
  147. #endif
  148. #if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
  149. VPHELPER(VP_MOVE_X, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr),
  150. VPHELPER(VP_MOVE_Y, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr),
  151. VPHELPER(VP_MOVE_Z, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr),
  152. VPHELPER(VP_HOME_ALL, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr),
  153. #else
  154. VPHELPER(VP_MOVE_X, nullptr, &ScreenHandler.HandleManualMove, nullptr),
  155. VPHELPER(VP_MOVE_Y, nullptr, &ScreenHandler.HandleManualMove, nullptr),
  156. VPHELPER(VP_MOVE_Z, nullptr, &ScreenHandler.HandleManualMove, nullptr),
  157. VPHELPER(VP_HOME_ALL, nullptr, &ScreenHandler.HandleManualMove, nullptr),
  158. #endif
  159. VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleMotorLockUnlock, nullptr),
  160. #if ENABLED(POWER_LOSS_RECOVERY)
  161. VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr),
  162. #endif
  163. VPHELPER(VP_SETTINGS, nullptr, &ScreenHandler.HandleSettings, nullptr),
  164. { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
  165. // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr
  166. { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay },
  167. // Temperature Data
  168. #if HOTENDS >= 1
  169. VPHELPER(VP_T_E0_Is, nullptr, nullptr, SET_VARIABLE(getActualTemp_celsius, E0, long)),
  170. VPHELPER(VP_T_E0_Set, nullptr, GET_VARIABLE(setTargetTemp_celsius, E0),
  171. SET_VARIABLE(getTargetTemp_celsius, E0)),
  172. VPHELPER(VP_Flowrate_E0, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
  173. VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
  174. VPHELPER(VP_MOVE_E0, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
  175. VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &ScreenHandler.HandleHeaterControl, nullptr),
  176. VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
  177. #if ENABLED(DGUS_PREHEAT_UI)
  178. VPHELPER(VP_E0_BED_PREHEAT, nullptr, &ScreenHandler.HandlePreheat, nullptr),
  179. #endif
  180. #if ENABLED(PIDTEMP)
  181. VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
  182. VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
  183. VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
  184. VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr),
  185. #endif
  186. #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
  187. VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload),
  188. #endif
  189. #endif
  190. #if HOTENDS >= 2
  191. VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendWordValueToDisplay),
  192. VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
  193. VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
  194. VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
  195. VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &ScreenHandler.HandleHeaterControl, nullptr),
  196. VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
  197. #if ENABLED(PIDTEMP)
  198. VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr),
  199. #endif
  200. #endif
  201. #if HAS_HEATED_BED
  202. VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
  203. VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
  204. VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr),
  205. VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
  206. #if ENABLED(PIDTEMPBED)
  207. VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
  208. VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
  209. VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
  210. #endif
  211. #endif
  212. // Fan Data
  213. #if HAS_FAN
  214. #define FAN_VPHELPER(N) \
  215. VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, &ScreenHandler.DGUSLCD_SendPercentageToDisplay), \
  216. VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &ScreenHandler.HandleFanControl, nullptr), \
  217. VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &ScreenHandler.DGUSLCD_SendFanStatusToDisplay),
  218. REPEAT(FAN_COUNT, FAN_VPHELPER)
  219. #endif
  220. // Feedrate
  221. VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ),
  222. // Position Data
  223. VPHELPER(VP_XPos, &current_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
  224. VPHELPER(VP_YPos, &current_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
  225. VPHELPER(VP_ZPos, &current_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
  226. // Print Progress
  227. VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay ),
  228. // Print Time
  229. VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay ),
  230. #if ENABLED(PRINTCOUNTER)
  231. VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay ),
  232. VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay ),
  233. #endif
  234. VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
  235. VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
  236. VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
  237. #if HOTENDS >= 1
  238. VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
  239. #endif
  240. #if HOTENDS >= 2
  241. VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
  242. #endif
  243. // SDCard File listing.
  244. #if ENABLED(SDSUPPORT)
  245. VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr),
  246. VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr),
  247. VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr),
  248. VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
  249. VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
  250. VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
  251. VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
  252. VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
  253. VPHELPER(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr),
  254. VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr),
  255. VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr),
  256. #if HAS_BED_PROBE
  257. VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
  258. #if ENABLED(BABYSTEPPING)
  259. VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr),
  260. #endif
  261. #endif
  262. #endif
  263. #if ENABLED(DGUS_UI_WAITING)
  264. VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, ScreenHandler.DGUSLCD_SendWaitingStatusToDisplay),
  265. #endif
  266. // Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content.
  267. { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
  268. { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
  269. { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
  270. { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
  271. VPHELPER(0, 0, 0, 0) // must be last entry.
  272. };
  273. #endif // DGUS_LCD_UI_ORIGIN