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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. #include "extui/lib/dgus/DGUSScreenHandler.h"
  33. extern const char NUL_STR[];
  34. namespace ExtUI {
  35. void onStartup() {
  36. dgusdisplay.InitDisplay();
  37. ScreenHandler.UpdateScreenVPData();
  38. }
  39. void onIdle() { ScreenHandler.loop(); }
  40. void onPrinterKilled(PGM_P const error, PGM_P const component) {
  41. ScreenHandler.sendinfoscreen(GET_TEXT(MSG_HALTED), error, NUL_STR, GET_TEXT(MSG_PLEASE_RESET), true, true, true, true);
  42. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_KILL);
  43. while (!ScreenHandler.loop()); // Wait while anything is left to be sent
  44. }
  45. void onMediaInserted() { TERN_(SDSUPPORT, ScreenHandler.SDCardInserted()); }
  46. void onMediaError() { TERN_(SDSUPPORT, ScreenHandler.SDCardError()); }
  47. void onMediaRemoved() { TERN_(SDSUPPORT, ScreenHandler.SDCardRemoved()); }
  48. void onPlayTone(const uint16_t frequency, const uint16_t duration) {}
  49. void onPrintTimerStarted() {}
  50. void onPrintTimerPaused() {}
  51. void onPrintTimerStopped() {}
  52. void onFilamentRunout(const extruder_t extruder) {}
  53. void onUserConfirmRequired(const char * const msg) {
  54. if (msg) {
  55. ScreenHandler.sendinfoscreen(PSTR("Please confirm."), nullptr, msg, nullptr, true, true, false, true);
  56. ScreenHandler.SetupConfirmAction(ExtUI::setUserConfirmed);
  57. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP);
  58. }
  59. else if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_POPUP ) {
  60. ScreenHandler.SetupConfirmAction(nullptr);
  61. ScreenHandler.PopToOldScreen();
  62. }
  63. }
  64. void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); }
  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) <= ExtUI::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) <= ExtUI::eeprom_data_size);
  80. // memcpy(&myDataStruct, buff, sizeof(myDataStruct));
  81. }
  82. void onConfigurationStoreWritten(bool success) {
  83. // Called after the entire EEPROM has been written,
  84. // whether successful or not.
  85. }
  86. void onConfigurationStoreRead(bool success) {
  87. // Called after the entire EEPROM has been read,
  88. // whether successful or not.
  89. }
  90. #if HAS_MESH
  91. void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
  92. // Called when any mesh points are updated
  93. }
  94. void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {
  95. // Called to indicate a special condition
  96. }
  97. #endif
  98. #if ENABLED(POWER_LOSS_RECOVERY)
  99. void onPowerLossResume() {
  100. // Called on resume from power-loss
  101. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POWER_LOSS);
  102. }
  103. #endif
  104. #if HAS_PID_HEATING
  105. void onPidTuning(const result_t rst) {
  106. // Called for temperature PID tuning result
  107. switch (rst) {
  108. case PID_BAD_EXTRUDER_NUM:
  109. ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_BAD_EXTRUDER_NUM));
  110. break;
  111. case PID_TEMP_TOO_HIGH:
  112. ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_TEMP_TOO_HIGH));
  113. break;
  114. case PID_TUNING_TIMEOUT:
  115. ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_TIMEOUT));
  116. break;
  117. case PID_DONE:
  118. ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_AUTOTUNE_DONE));
  119. break;
  120. }
  121. ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN);
  122. }
  123. #endif
  124. }
  125. #endif // HAS_DGUS_LCD