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

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