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.

extui_dgus_lcd.cpp 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * extui_dgus_lcd.cpp
  24. *
  25. * DGUS implementation for Marlin by coldtobi, Feb-May 2019
  26. */
  27. #include "../inc/MarlinConfigPre.h"
  28. #if HAS_DGUS_LCD
  29. #include "extui/ui_api.h"
  30. #include "extui/lib/dgus/DGUSDisplay.h"
  31. #include "extui/lib/dgus/DGUSDisplayDef.h"
  32. extern const char NUL_STR[];
  33. namespace ExtUI {
  34. void onStartup() {
  35. dgusdisplay.InitDisplay();
  36. ScreenHandler.UpdateScreenVPData();
  37. }
  38. void onIdle() { ScreenHandler.loop(); }
  39. void onPrinterKilled(PGM_P error, PGM_P component) {
  40. ScreenHandler.sendinfoscreen(GET_TEXT(MSG_HALTED), error, NUL_STR, GET_TEXT(MSG_PLEASE_RESET), true, true, true, true);
  41. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_KILL);
  42. while (!ScreenHandler.loop()); // Wait while anything is left to be sent
  43. }
  44. void onMediaInserted() {
  45. #if ENABLED(SDSUPPORT)
  46. ScreenHandler.SDCardInserted();
  47. #endif
  48. }
  49. void onMediaError() {
  50. #if ENABLED(SDSUPPORT)
  51. ScreenHandler.SDCardError();
  52. #endif
  53. }
  54. void onMediaRemoved() {
  55. #if ENABLED(SDSUPPORT)
  56. ScreenHandler.SDCardRemoved();
  57. #endif
  58. }
  59. void onPlayTone(const uint16_t frequency, const uint16_t duration) {}
  60. void onPrintTimerStarted() {}
  61. void onPrintTimerPaused() {}
  62. void onPrintTimerStopped() {}
  63. void onFilamentRunout(const extruder_t extruder) {}
  64. void onUserConfirmRequired(const char * const msg) {
  65. if (msg) {
  66. ScreenHandler.sendinfoscreen(PSTR("Please confirm."), nullptr, msg, nullptr, true, true, false, true);
  67. ScreenHandler.SetupConfirmAction(ExtUI::setUserConfirmed);
  68. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP);
  69. }
  70. else if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_POPUP ) {
  71. ScreenHandler.SetupConfirmAction(nullptr);
  72. ScreenHandler.PopToOldScreen();
  73. }
  74. }
  75. void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); }
  76. void onFactoryReset() {}
  77. void onStoreSettings(char *buff) {
  78. // Called when saving to EEPROM (i.e. M500). If the ExtUI needs
  79. // permanent data to be stored, it can write up to eeprom_data_size bytes
  80. // into buff.
  81. // Example:
  82. // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size);
  83. // memcpy(buff, &myDataStruct, sizeof(myDataStruct));
  84. }
  85. void onLoadSettings(const char *buff) {
  86. // Called while loading settings from EEPROM. If the ExtUI
  87. // needs to retrieve data, it should copy up to eeprom_data_size bytes
  88. // from buff
  89. // Example:
  90. // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size);
  91. // memcpy(&myDataStruct, buff, sizeof(myDataStruct));
  92. }
  93. void onConfigurationStoreWritten(bool success) {
  94. // Called after the entire EEPROM has been written,
  95. // whether successful or not.
  96. }
  97. void onConfigurationStoreRead(bool success) {
  98. // Called after the entire EEPROM has been read,
  99. // whether successful or not.
  100. }
  101. void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
  102. // Called when any mesh points are updated
  103. }
  104. #if ENABLED(POWER_LOSS_RECOVERY)
  105. void OnPowerLossResume() {
  106. // Called on resume from power-loss
  107. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POWER_LOSS);
  108. }
  109. #endif
  110. #if HAS_PID_HEATING
  111. void OnPidTuning(const result_t rst) {
  112. // Called for temperature PID tuning result
  113. SERIAL_ECHOLNPAIR("OnPidTuning:",rst);
  114. switch(rst) {
  115. case PID_BAD_EXTRUDER_NUM:
  116. ScreenHandler.setstatusmessagePGM(PSTR(STR_PID_BAD_EXTRUDER_NUM));
  117. break;
  118. case PID_TEMP_TOO_HIGH:
  119. ScreenHandler.setstatusmessagePGM(PSTR(STR_PID_TEMP_TOO_HIGH));
  120. break;
  121. case PID_TUNING_TIMEOUT:
  122. ScreenHandler.setstatusmessagePGM(PSTR(STR_PID_TIMEOUT));
  123. break;
  124. case PID_DONE:
  125. ScreenHandler.setstatusmessagePGM(PSTR(STR_PID_AUTOTUNE_FINISHED));
  126. break;
  127. }
  128. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN);
  129. }
  130. #endif
  131. }
  132. #endif // HAS_DGUS_LCD