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.

endstop_diag.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2022 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. * DWIN End Stops diagnostic page
  24. * Author: Miguel A. Risco-Castillo
  25. * Version: 1.0
  26. * Date: 2021/11/06
  27. *
  28. * Modded for JYERSUI by LCH-77
  29. */
  30. #include "../../../inc/MarlinConfigPre.h"
  31. #if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
  32. #include "dwin_defines.h"
  33. #if HAS_ESDIAG
  34. #include "endstop_diag.h"
  35. #include "dwinui.h"
  36. #include "dwin.h"
  37. #if HAS_FILAMENT_SENSOR
  38. #include "../../../feature/runout.h"
  39. #endif
  40. #if HAS_BED_PROBE
  41. #include "../../../module/probe.h"
  42. #endif
  43. ESDiagClass ESDiag;
  44. void draw_es_label(FSTR_P const flabel=nullptr) {
  45. DWINUI::cursor.x = 40;
  46. if (flabel) DWINUI::Draw_String(F(flabel));
  47. DWINUI::Draw_String(F(": "));
  48. DWINUI::MoveBy(0, 25);
  49. }
  50. void draw_es_state(const bool is_hit) {
  51. const uint8_t LM = 130;
  52. DWINUI::cursor.x = LM;
  53. DWIN_Draw_Rectangle(1, Color_Bg_Window, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20);
  54. is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN));
  55. DWINUI::MoveBy(0, 25);
  56. }
  57. void ESDiagClass::Draw() {
  58. CrealityDWINClass::Clear_Screen(1);
  59. CrealityDWINClass::Draw_Title(F("End-stops Diagnostic"));
  60. DWINUI::ClearMainArea();
  61. DWIN_Draw_Rectangle(0, Color_White, 14, 60, 258, 330);
  62. DWINUI::Draw_Button(BTN_Continue, 86, 250);
  63. DWINUI::cursor.y = 80;
  64. #define ES_LABEL(S) draw_es_label(F(STR_##S))
  65. #if HAS_X_MIN
  66. ES_LABEL(X_MIN);
  67. #endif
  68. #if HAS_Y_MIN
  69. ES_LABEL(Y_MIN);
  70. #endif
  71. #if HAS_Z_MIN
  72. ES_LABEL(Z_MIN);
  73. #endif
  74. #if HAS_FILAMENT_SENSOR
  75. draw_es_label(F(STR_FILAMENT));
  76. #endif
  77. Update();
  78. }
  79. void ESDiagClass::Update() {
  80. DWINUI::cursor.y = 80;
  81. #define ES_REPORT(S) draw_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING)
  82. #if HAS_X_MIN
  83. ES_REPORT(X_MIN);
  84. #endif
  85. #if HAS_Y_MIN
  86. ES_REPORT(Y_MIN);
  87. #endif
  88. #if HAS_Z_MIN
  89. ES_REPORT(Z_MIN);
  90. #endif
  91. #if HAS_FILAMENT_SENSOR
  92. draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE);
  93. #endif
  94. DWIN_UpdateLCD();
  95. }
  96. #endif // HAS_ES_DIAG
  97. #endif // DWIN_CREALITY_LCD_JYERSUI