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.

marlin_events.cpp 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*********************
  2. * marlin_events.cpp *
  3. *********************/
  4. /****************************************************************************
  5. * Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
  6. * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
  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. * To view a copy of the GNU General Public License, go to the following *
  19. * location: <https://www.gnu.org/licenses/>. *
  20. ****************************************************************************/
  21. #include "compat.h"
  22. #if ENABLED(TOUCH_UI_FTDI_EVE)
  23. #include "screens/screens.h"
  24. namespace ExtUI {
  25. using namespace Theme;
  26. using namespace FTDI;
  27. void onStartup() {
  28. EventLoop::setup();
  29. }
  30. void onIdle() {
  31. EventLoop::loop();
  32. }
  33. void onPrinterKilled(PGM_P const error, PGM_P const component) {
  34. char str[strlen_P(error) + strlen_P(component) + 3];
  35. sprintf_P(str, PSTR(S_FMT ": " S_FMT), error, component);
  36. KillScreen::show(str);
  37. }
  38. void onMediaInserted() {
  39. if (AT_SCREEN(StatusScreen))
  40. StatusScreen::setStatusMessage(GET_TEXT_F(MSG_MEDIA_INSERTED));
  41. sound.play(media_inserted, PLAY_ASYNCHRONOUS);
  42. }
  43. void onMediaRemoved() {
  44. if (isPrintingFromMedia()) {
  45. stopPrint();
  46. InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED);
  47. }
  48. else
  49. sound.play(media_removed, PLAY_ASYNCHRONOUS);
  50. if (AT_SCREEN(StatusScreen) || isPrintingFromMedia())
  51. StatusScreen::setStatusMessage(GET_TEXT_F(MSG_MEDIA_REMOVED));
  52. #if ENABLED(SDSUPPORT)
  53. if (AT_SCREEN(FilesScreen)) GOTO_SCREEN(StatusScreen);
  54. #endif
  55. }
  56. void onMediaError() {
  57. sound.play(sad_trombone, PLAY_ASYNCHRONOUS);
  58. AlertDialogBox::showError(F("Unable to read media."));
  59. }
  60. void onStatusChanged(const char* lcd_msg) {
  61. StatusScreen::setStatusMessage(lcd_msg);
  62. }
  63. void onStatusChanged(progmem_str lcd_msg) {
  64. StatusScreen::setStatusMessage(lcd_msg);
  65. }
  66. void onPrintTimerStarted() {
  67. InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_STARTED);
  68. }
  69. void onPrintTimerStopped() {
  70. InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FINISHED);
  71. }
  72. void onPrintTimerPaused() {
  73. }
  74. void onFilamentRunout(const extruder_t extruder) {
  75. char lcd_msg[30];
  76. sprintf_P(lcd_msg, PSTR("Extruder %d Filament Error"), extruder + 1);
  77. StatusScreen::setStatusMessage(lcd_msg);
  78. InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED, FTDI::PLAY_SYNCHRONOUS);
  79. }
  80. void onFactoryReset() {
  81. InterfaceSettingsScreen::defaultSettings();
  82. }
  83. void onStoreSettings(char *buff) {
  84. InterfaceSettingsScreen::saveSettings(buff);
  85. }
  86. void onLoadSettings(const char *buff) {
  87. InterfaceSettingsScreen::loadSettings(buff);
  88. }
  89. void onConfigurationStoreWritten(bool success) {
  90. #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE
  91. if (success && InterfaceSettingsScreen::backupEEPROM()) {
  92. SERIAL_ECHOLNPGM("Made backup of EEPROM to SPI Flash");
  93. }
  94. #else
  95. UNUSED(success);
  96. #endif
  97. }
  98. void onConfigurationStoreRead(bool) {
  99. }
  100. void onPlayTone(const uint16_t frequency, const uint16_t duration) {
  101. sound.play_tone(frequency, duration);
  102. }
  103. void onUserConfirmRequired(const char * const msg) {
  104. if (msg)
  105. ConfirmUserRequestAlertBox::show(msg);
  106. else
  107. ConfirmUserRequestAlertBox::hide();
  108. }
  109. #if HAS_LEVELING && HAS_MESH
  110. void onMeshUpdate(const int8_t x, const int8_t y, const float val) {
  111. BedMeshScreen::onMeshUpdate(x, y, val);
  112. }
  113. void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) {
  114. BedMeshScreen::onMeshUpdate(x, y, state);
  115. }
  116. #endif
  117. #if ENABLED(POWER_LOSS_RECOVERY)
  118. void onPowerLossResume() {
  119. // Called on resume from power-loss
  120. }
  121. #endif
  122. #if HAS_PID_HEATING
  123. void onPidTuning(const result_t rst) {
  124. // Called for temperature PID tuning result
  125. //SERIAL_ECHOLNPAIR("OnPidTuning:", rst);
  126. switch (rst) {
  127. case PID_BAD_EXTRUDER_NUM:
  128. StatusScreen::setStatusMessage(GET_TEXT_F(MSG_PID_BAD_EXTRUDER_NUM));
  129. break;
  130. case PID_TEMP_TOO_HIGH:
  131. StatusScreen::setStatusMessage(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH));
  132. break;
  133. case PID_TUNING_TIMEOUT:
  134. StatusScreen::setStatusMessage(GET_TEXT_F(MSG_PID_TIMEOUT));
  135. break;
  136. case PID_DONE:
  137. StatusScreen::setStatusMessage(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE));
  138. break;
  139. }
  140. GOTO_SCREEN(StatusScreen);
  141. }
  142. #endif // HAS_PID_HEATING
  143. }
  144. #endif // TOUCH_UI_FTDI_EVE