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_state_screen.cpp 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /****************************
  2. * endstop_state_screen.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 "../config.h"
  22. #if ENABLED(TOUCH_UI_FTDI_EVE)
  23. #include "screens.h"
  24. using namespace FTDI;
  25. using namespace Theme;
  26. using namespace ExtUI;
  27. void EndstopStatesScreen::onEntry() {
  28. BaseScreen::onEntry();
  29. }
  30. void EndstopStatesScreen::onExit() {
  31. BaseScreen::onExit();
  32. }
  33. void EndstopStatesScreen::onRedraw(draw_mode_t) {
  34. CommandProcessor cmd;
  35. cmd.cmd(CLEAR_COLOR_RGB(bg_color))
  36. .cmd(COLOR_RGB(bg_text_enabled))
  37. .cmd(CLEAR(true,true,true))
  38. .tag(0);
  39. #define GRID_ROWS 7
  40. #define GRID_COLS 6
  41. #define PIN_BTN(X,Y,PIN,LABEL) button(BTN_POS(X,Y), BTN_SIZE(2,1), LABEL)
  42. #define PIN_ENABLED(X,Y,LABEL,PIN,INV) cmd.enabled(1).colors(READ(PIN##_PIN) != INV ? action_btn : normal_btn).PIN_BTN(X,Y,PIN,LABEL);
  43. #define PIN_DISABLED(X,Y,LABEL,PIN) cmd.enabled(0).PIN_BTN(X,Y,PIN,LABEL);
  44. cmd.font(
  45. #ifdef TOUCH_UI_PORTRAIT
  46. font_large
  47. #else
  48. font_medium
  49. #endif
  50. )
  51. .text(BTN_POS(1,1), BTN_SIZE(6,1), GET_TEXT_F(MSG_LCD_ENDSTOPS))
  52. .font(font_tiny);
  53. #if PIN_EXISTS(X_MAX)
  54. PIN_ENABLED (1, 2, PSTR(MSG_X_MAX), X_MAX, X_MAX_ENDSTOP_INVERTING)
  55. #else
  56. PIN_DISABLED(1, 2, PSTR(MSG_X_MAX), X_MAX)
  57. #endif
  58. #if PIN_EXISTS(Y_MAX)
  59. PIN_ENABLED (3, 2, PSTR(MSG_Y_MAX), Y_MAX, Y_MAX_ENDSTOP_INVERTING)
  60. #else
  61. PIN_DISABLED(3, 2, PSTR(MSG_Y_MAX), Y_MAX)
  62. #endif
  63. #if PIN_EXISTS(Z_MAX)
  64. PIN_ENABLED (5, 2, PSTR(MSG_Z_MAX), Z_MAX, Z_MAX_ENDSTOP_INVERTING)
  65. #else
  66. PIN_DISABLED(5, 2, PSTR(MSG_Z_MAX), Z_MAX)
  67. #endif
  68. #if PIN_EXISTS(X_MIN)
  69. PIN_ENABLED (1, 3, PSTR(MSG_X_MIN), X_MIN, X_MIN_ENDSTOP_INVERTING)
  70. #else
  71. PIN_DISABLED(1, 3, PSTR(MSG_X_MIN), X_MIN)
  72. #endif
  73. #if PIN_EXISTS(Y_MIN)
  74. PIN_ENABLED (3, 3, PSTR(MSG_Y_MIN), Y_MIN, Y_MIN_ENDSTOP_INVERTING)
  75. #else
  76. PIN_DISABLED(3, 3, PSTR(MSG_Y_MIN), Y_MIN)
  77. #endif
  78. #if PIN_EXISTS(Z_MIN)
  79. PIN_ENABLED (5, 3, PSTR(MSG_Z_MIN), Z_MIN, Z_MIN_ENDSTOP_INVERTING)
  80. #else
  81. PIN_DISABLED(5, 3, PSTR(MSG_Z_MIN), Z_MIN)
  82. #endif
  83. #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT)
  84. PIN_ENABLED (1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT, FIL_RUNOUT_INVERTING)
  85. #else
  86. PIN_DISABLED(1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT)
  87. #endif
  88. #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT2)
  89. PIN_ENABLED (3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2, FIL_RUNOUT_INVERTING)
  90. #else
  91. PIN_DISABLED(3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2)
  92. #endif
  93. #if PIN_EXISTS(Z_MIN_PROBE)
  94. PIN_ENABLED (5, 4, PSTR(MSG_Z_PROBE), Z_MIN_PROBE, Z_MIN_PROBE_ENDSTOP_INVERTING)
  95. #else
  96. PIN_DISABLED(5, 4, PSTR(MSG_Z_PROBE), Z_MIN_PROBE)
  97. #endif
  98. #if HAS_SOFTWARE_ENDSTOPS
  99. #undef EDGE_R
  100. #define EDGE_R 30
  101. cmd.cmd(COLOR_RGB(bg_text_enabled))
  102. .font(font_small)
  103. .text (BTN_POS(1,5), BTN_SIZE(3,1), GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS), OPT_RIGHTX | OPT_CENTERY)
  104. .colors(ui_toggle)
  105. .tag(2).toggle2(BTN_POS(4,5), BTN_SIZE(3,1), GET_TEXT_F(MSG_NO), GET_TEXT_F(MSG_YES), getSoftEndstopState());
  106. #undef EDGE_R
  107. #define EDGE_R 0
  108. #endif
  109. cmd.font(font_medium)
  110. .colors(action_btn)
  111. .tag(1).button( BTN_POS(1,7), BTN_SIZE(6,1), GET_TEXT_F(MSG_BACK));
  112. #undef GRID_COLS
  113. #undef GRID_ROWS
  114. }
  115. bool EndstopStatesScreen::onTouchEnd(uint8_t tag) {
  116. switch (tag) {
  117. case 1: GOTO_PREVIOUS(); break;
  118. #if HAS_SOFTWARE_ENDSTOPS
  119. case 2: setSoftEndstopState(!getSoftEndstopState());
  120. #endif
  121. default:
  122. return false;
  123. }
  124. return true;
  125. }
  126. void EndstopStatesScreen::onIdle() {
  127. constexpr uint32_t DIAGNOSTICS_UPDATE_INTERVAL = 100;
  128. if (refresh_timer.elapsed(DIAGNOSTICS_UPDATE_INTERVAL)) {
  129. onRefresh();
  130. refresh_timer.start();
  131. reset_menu_timeout();
  132. }
  133. BaseScreen::onIdle();
  134. }
  135. #endif // TOUCH_UI_FTDI_EVE