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 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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: <http://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 (AT_SCREEN(StatusScreen))
  45. StatusScreen::setStatusMessage(GET_TEXT_F(MSG_MEDIA_REMOVED));
  46. sound.play(media_removed, PLAY_ASYNCHRONOUS);
  47. if (AT_SCREEN(FilesScreen)) {
  48. GOTO_SCREEN(StatusScreen)
  49. }
  50. }
  51. void onMediaError() {
  52. sound.play(sad_trombone, PLAY_ASYNCHRONOUS);
  53. AlertDialogBox::showError(F("Unable to read media."));
  54. }
  55. void onStatusChanged(const char* lcd_msg) {
  56. StatusScreen::setStatusMessage(lcd_msg);
  57. }
  58. void onStatusChanged(progmem_str lcd_msg) {
  59. StatusScreen::setStatusMessage(lcd_msg);
  60. }
  61. void onPrintTimerStarted() {
  62. InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_STARTED);
  63. }
  64. void onPrintTimerStopped() {
  65. InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FINISHED);
  66. }
  67. void onPrintTimerPaused() {
  68. }
  69. void onFilamentRunout(const extruder_t extruder) {
  70. char lcd_msg[30];
  71. sprintf_P(lcd_msg, PSTR("Extruder %d Filament Error"), extruder + 1);
  72. StatusScreen::setStatusMessage(lcd_msg);
  73. InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED);
  74. }
  75. void onFactoryReset() {
  76. InterfaceSettingsScreen::defaultSettings();
  77. }
  78. void onStoreSettings(char *buff) {
  79. InterfaceSettingsScreen::saveSettings(buff);
  80. }
  81. void onLoadSettings(const char *buff) {
  82. InterfaceSettingsScreen::loadSettings(buff);
  83. }
  84. void onConfigurationStoreWritten(bool success) {
  85. #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE
  86. if (success && InterfaceSettingsScreen::backupEEPROM()) {
  87. SERIAL_ECHOLNPGM("Made backup of EEPROM to SPI Flash");
  88. }
  89. #else
  90. UNUSED(success);
  91. #endif
  92. }
  93. void onConfigurationStoreRead(bool) {
  94. }
  95. void onPlayTone(const uint16_t frequency, const uint16_t duration) {
  96. sound.play_tone(frequency, duration);
  97. }
  98. void onUserConfirmRequired(const char * const msg) {
  99. if (msg)
  100. ConfirmUserRequestAlertBox::show(msg);
  101. else
  102. ConfirmUserRequestAlertBox::hide();
  103. }
  104. #if HAS_LEVELING && HAS_MESH
  105. void onMeshUpdate(const int8_t, const int8_t, const float) {
  106. }
  107. #endif
  108. #if HAS_PID_HEATING
  109. void OnPidTuning(const result_t rst) {
  110. // Called for temperature PID tuning result
  111. SERIAL_ECHOLNPAIR("OnPidTuning:", rst);
  112. switch (rst) {
  113. case PID_BAD_EXTRUDER_NUM:
  114. StatusScreen::setStatusMessage(STR_PID_BAD_EXTRUDER_NUM);
  115. break;
  116. case PID_TEMP_TOO_HIGH:
  117. StatusScreen::setStatusMessage(STR_PID_TEMP_TOO_HIGH);
  118. break;
  119. case PID_TUNING_TIMEOUT:
  120. StatusScreen::setStatusMessage(STR_PID_TIMEOUT);
  121. break;
  122. case PID_DONE:
  123. StatusScreen::setStatusMessage(STR_PID_AUTOTUNE_FINISHED);
  124. break;
  125. }
  126. GOTO_SCREEN(StatusScreen);
  127. }
  128. #endif // HAS_PID_HEATING
  129. }
  130. #endif // TOUCH_UI_FTDI_EVE