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.

dgus_extui.cpp 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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/dgus/dgus_extui.cpp
  24. */
  25. #include "../../../inc/MarlinConfigPre.h"
  26. #if HAS_DGUS_LCD_CLASSIC
  27. #include "../ui_api.h"
  28. #include "DGUSDisplay.h"
  29. #include "DGUSDisplayDef.h"
  30. #include "DGUSScreenHandler.h"
  31. namespace ExtUI {
  32. void onStartup() {
  33. dgusdisplay.InitDisplay();
  34. ScreenHandler.UpdateScreenVPData();
  35. }
  36. void onIdle() { ScreenHandler.loop(); }
  37. void onPrinterKilled(FSTR_P const error, FSTR_P const) {
  38. ScreenHandler.sendinfoscreen(GET_TEXT_F(MSG_HALTED), error, FPSTR(NUL_STR), GET_TEXT_F(MSG_PLEASE_RESET), true, true, true, true);
  39. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_KILL);
  40. while (!ScreenHandler.loop()); // Wait while anything is left to be sent
  41. }
  42. void onMediaInserted() { TERN_(SDSUPPORT, ScreenHandler.SDCardInserted()); }
  43. void onMediaError() { TERN_(SDSUPPORT, ScreenHandler.SDCardError()); }
  44. void onMediaRemoved() { TERN_(SDSUPPORT, ScreenHandler.SDCardRemoved()); }
  45. void onPlayTone(const uint16_t frequency, const uint16_t duration) {}
  46. void onPrintTimerStarted() {}
  47. void onPrintTimerPaused() {}
  48. void onPrintTimerStopped() {}
  49. void onFilamentRunout(const extruder_t extruder) {}
  50. void onUserConfirmRequired(const char * const msg) {
  51. if (msg) {
  52. ScreenHandler.sendinfoscreen(F("Please confirm."), nullptr, msg, nullptr, true, true, false, true);
  53. ScreenHandler.SetupConfirmAction(setUserConfirmed);
  54. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP);
  55. }
  56. else if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_POPUP) {
  57. ScreenHandler.SetupConfirmAction(nullptr);
  58. ScreenHandler.PopToOldScreen();
  59. }
  60. }
  61. void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); }
  62. void onHomingStart() {}
  63. void onHomingDone() {}
  64. void onPrintDone() {}
  65. void onFactoryReset() {}
  66. void onStoreSettings(char *buff) {
  67. // Called when saving to EEPROM (i.e. M500). If the ExtUI needs
  68. // permanent data to be stored, it can write up to eeprom_data_size bytes
  69. // into buff.
  70. // Example:
  71. // static_assert(sizeof(myDataStruct) <= eeprom_data_size);
  72. // memcpy(buff, &myDataStruct, sizeof(myDataStruct));
  73. }
  74. void onLoadSettings(const char *buff) {
  75. // Called while loading settings from EEPROM. If the ExtUI
  76. // needs to retrieve data, it should copy up to eeprom_data_size bytes
  77. // from buff
  78. // Example:
  79. // static_assert(sizeof(myDataStruct) <= eeprom_data_size);
  80. // memcpy(&myDataStruct, buff, sizeof(myDataStruct));
  81. }
  82. void onPostprocessSettings() {
  83. // Called after loading or resetting stored settings
  84. }
  85. void onSettingsStored(bool success) {
  86. // Called after the entire EEPROM has been written,
  87. // whether successful or not.
  88. }
  89. void onSettingsLoaded(bool success) {
  90. // Called after the entire EEPROM has been read,
  91. // whether successful or not.
  92. }
  93. #if HAS_MESH
  94. void onLevelingStart() {}
  95. void onLevelingDone() {}
  96. void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
  97. // Called when any mesh points are updated
  98. }
  99. void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) {
  100. // Called to indicate a special condition
  101. }
  102. #endif
  103. #if ENABLED(POWER_LOSS_RECOVERY)
  104. void onPowerLossResume() {
  105. // Called on resume from power-loss
  106. IF_DISABLED(DGUS_LCD_UI_MKS, ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POWER_LOSS));
  107. }
  108. #endif
  109. #if HAS_PID_HEATING
  110. void onPidTuning(const result_t rst) {
  111. // Called for temperature PID tuning result
  112. switch (rst) {
  113. case PID_STARTED:
  114. ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_AUTOTUNE));
  115. break;
  116. case PID_BAD_EXTRUDER_NUM:
  117. ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_BAD_EXTRUDER_NUM));
  118. break;
  119. case PID_TEMP_TOO_HIGH:
  120. ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_TEMP_TOO_HIGH));
  121. break;
  122. case PID_TUNING_TIMEOUT:
  123. ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_TIMEOUT));
  124. break;
  125. case PID_DONE:
  126. ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_AUTOTUNE_DONE));
  127. break;
  128. }
  129. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN);
  130. }
  131. #endif
  132. void onSteppersDisabled() {}
  133. void onSteppersEnabled() {}
  134. }
  135. #endif // HAS_DGUS_LCD_CLASSIC