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.

malyan_extui.cpp 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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/malyan/malyan_extui.cpp
  24. */
  25. #include "../../../inc/MarlinConfigPre.h"
  26. #if ENABLED(MALYAN_LCD)
  27. #include "../ui_api.h"
  28. #include "malyan.h"
  29. //#include "../../marlinui.h"
  30. //#include "../../../sd/cardreader.h"
  31. //#include "../../../module/temperature.h"
  32. //#include "../../../module/stepper.h"
  33. //#include "../../../module/motion.h"
  34. //#include "../../../libs/duration_t.h"
  35. //#include "../../../module/printcounter.h"
  36. //#include "../../../gcode/queue.h"
  37. namespace ExtUI {
  38. void onStartup() {
  39. /**
  40. * The Malyan LCD actually runs as a separate MCU on Serial 1.
  41. * This code's job is to siphon the weird curly-brace commands from
  42. * it and translate into ExtUI operations where possible.
  43. */
  44. inbound_count = 0;
  45. #ifndef LCD_BAUDRATE
  46. #define LCD_BAUDRATE 500000
  47. #endif
  48. LCD_SERIAL.begin(LCD_BAUDRATE);
  49. // Signal init
  50. write_to_lcd(F("{SYS:STARTED}\r\n"));
  51. // send a version that says "unsupported"
  52. write_to_lcd(F("{VER:99}\r\n"));
  53. // No idea why it does this twice.
  54. write_to_lcd(F("{SYS:STARTED}\r\n"));
  55. update_usb_status(true);
  56. }
  57. void onIdle() {
  58. /**
  59. * - from printer on startup:
  60. * {SYS:STARTED}{VER:29}{SYS:STARTED}{R:UD}
  61. */
  62. // First report USB status.
  63. update_usb_status(false);
  64. // now drain commands...
  65. while (LCD_SERIAL.available())
  66. parse_lcd_byte((byte)LCD_SERIAL.read());
  67. #if ENABLED(SDSUPPORT)
  68. // The way last printing status works is simple:
  69. // The UI needs to see at least one TQ which is not 100%
  70. // and then when the print is complete, one which is.
  71. static uint8_t last_percent_done = 100;
  72. // If there was a print in progress, we need to emit the final
  73. // print status as {TQ:100}. Reset last percent done so a new print will
  74. // issue a percent of 0.
  75. const uint8_t percent_done = (ExtUI::isPrinting() || ExtUI::isPrintingFromMediaPaused()) ? ExtUI::getProgress_percent() : last_printing_status ? 100 : 0;
  76. if (percent_done != last_percent_done) {
  77. char message_buffer[16];
  78. sprintf_P(message_buffer, PSTR("{TQ:%03i}"), percent_done);
  79. write_to_lcd(message_buffer);
  80. last_percent_done = percent_done;
  81. last_printing_status = ExtUI::isPrinting();
  82. }
  83. #endif
  84. }
  85. void onPrinterKilled(FSTR_P const error, FSTR_P const component) {
  86. set_lcd_error(error, component);
  87. }
  88. #if HAS_PID_HEATING
  89. void onPidTuning(const result_t rst) {
  90. // Called for temperature PID tuning result
  91. //SERIAL_ECHOLNPGM("OnPidTuning:", rst);
  92. switch (rst) {
  93. case PID_STARTED:
  94. set_lcd_error(GET_TEXT_F(MSG_PID_AUTOTUNE));
  95. break;
  96. case PID_BAD_EXTRUDER_NUM:
  97. set_lcd_error(GET_TEXT_F(MSG_PID_BAD_EXTRUDER_NUM));
  98. break;
  99. case PID_TEMP_TOO_HIGH:
  100. set_lcd_error(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH));
  101. break;
  102. case PID_TUNING_TIMEOUT:
  103. set_lcd_error(GET_TEXT_F(MSG_PID_TIMEOUT));
  104. break;
  105. case PID_DONE:
  106. set_lcd_error(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE));
  107. break;
  108. }
  109. }
  110. #endif
  111. void onPrintTimerStarted() { write_to_lcd(F("{SYS:BUILD}")); }
  112. void onPrintTimerPaused() {}
  113. void onPrintTimerStopped() { write_to_lcd(F("{TQ:100}")); }
  114. // Not needed for Malyan LCD
  115. void onStatusChanged(const char * const) {}
  116. void onMediaInserted() {}
  117. void onMediaError() {}
  118. void onMediaRemoved() {}
  119. void onPlayTone(const uint16_t, const uint16_t) {}
  120. void onFilamentRunout(const extruder_t extruder) {}
  121. void onUserConfirmRequired(const char * const) {}
  122. void onHomingStart() {}
  123. void onHomingDone() {}
  124. void onPrintDone() {}
  125. void onFactoryReset() {}
  126. void onStoreSettings(char*) {}
  127. void onLoadSettings(const char*) {}
  128. void onPostprocessSettings() {}
  129. void onSettingsStored(bool) {}
  130. void onSettingsLoaded(bool) {}
  131. #if HAS_MESH
  132. void onLevelingStart() {}
  133. void onLevelingDone() {}
  134. void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {}
  135. void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {}
  136. #endif
  137. #if ENABLED(POWER_LOSS_RECOVERY)
  138. void onPowerLossResume() {}
  139. #endif
  140. void onSteppersDisabled() {}
  141. void onSteppersEnabled() {}
  142. }
  143. #endif // MALYAN_LCD