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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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(LULZBOT_TOUCH_UI)
  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(LABEL,PIN,INV,X,Y) cmd.enabled(1).colors(READ(PIN##_PIN) != INV ? action_btn : normal_btn).PIN_BTN(X,Y,PIN,LABEL);
  43. #define PIN_DISABLED(LABEL,PIN,INV,X,Y) cmd.enabled(0).PIN_BTN(X,Y,PIN,LABEL);
  44. #ifdef TOUCH_UI_PORTRAIT
  45. cmd.font(font_large)
  46. #else
  47. cmd.font(font_medium)
  48. #endif
  49. .text(BTN_POS(1,1), BTN_SIZE(6,1), GET_TEXTF(ENDSTOPS))
  50. .font(font_tiny);
  51. #if PIN_EXISTS(X_MAX)
  52. PIN_ENABLED (GET_TEXTF(X_MAX), X_MAX,X_MAX_ENDSTOP_INVERTING,1,2)
  53. #else
  54. PIN_DISABLED(GET_TEXTF(X_MAX),X_MAX,X_MAX_ENDSTOP_INVERTING,1,2)
  55. #endif
  56. #if PIN_EXISTS(Y_MAX)
  57. PIN_ENABLED (GET_TEXTF(Y_MAX),Y_MAX,Y_MAX_ENDSTOP_INVERTING,3,2)
  58. #else
  59. PIN_DISABLED(GET_TEXTF(Y_MAX),Y_MAX,Y_MAX_ENDSTOP_INVERTING,3,2)
  60. #endif
  61. #if PIN_EXISTS(Z_MAX)
  62. PIN_ENABLED (GET_TEXTF(Z_MAX),Z_MAX,Z_MAX_ENDSTOP_INVERTING,5,2)
  63. #else
  64. PIN_DISABLED(GET_TEXTF(Z_MAX),Z_MAX,Z_MAX_ENDSTOP_INVERTING,5,2)
  65. #endif
  66. #if PIN_EXISTS(X_MIN)
  67. PIN_ENABLED (GET_TEXTF(X_MIN),X_MIN,X_MIN_ENDSTOP_INVERTING,1,3)
  68. #else
  69. PIN_DISABLED(GET_TEXTF(X_MIN),X_MIN,X_MIN_ENDSTOP_INVERTING,1,3)
  70. #endif
  71. #if PIN_EXISTS(Y_MIN)
  72. PIN_ENABLED (GET_TEXTF(Y_MIN),Y_MIN,Y_MIN_ENDSTOP_INVERTING,3,3)
  73. #else
  74. PIN_DISABLED(GET_TEXTF(Y_MIN),Y_MIN,Y_MIN_ENDSTOP_INVERTING,3,3)
  75. #endif
  76. #if PIN_EXISTS(Z_MIN)
  77. PIN_ENABLED (GET_TEXTF(Z_MIN),Z_MIN,Z_MIN_ENDSTOP_INVERTING,5,3)
  78. #else
  79. PIN_DISABLED(GET_TEXTF(Z_MIN),Z_MIN,Z_MIN_ENDSTOP_INVERTING,5,3)
  80. #endif
  81. #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT)
  82. PIN_ENABLED (GET_TEXTF(RUNOUT_1),FIL_RUNOUT, FIL_RUNOUT_INVERTING,1,4)
  83. #else
  84. PIN_DISABLED(GET_TEXTF(RUNOUT_1),FIL_RUNOUT, FIL_RUNOUT_INVERTING,1,4)
  85. #endif
  86. #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT2)
  87. PIN_ENABLED (GET_TEXTF(RUNOUT_2),FIL_RUNOUT2,FIL_RUNOUT_INVERTING,3,4)
  88. #else
  89. PIN_DISABLED(GET_TEXTF(RUNOUT_2),FIL_RUNOUT2,FIL_RUNOUT_INVERTING,3,4)
  90. #endif
  91. #if PIN_EXISTS(Z_MIN_PROBE)
  92. PIN_ENABLED (GET_TEXTF(Z_PROBE),Z_MIN_PROBE,Z_MIN_PROBE_ENDSTOP_INVERTING,5,4)
  93. #else
  94. PIN_DISABLED(GET_TEXTF(Z_PROBE),Z_MIN_PROBE,Z_MIN_PROBE_ENDSTOP_INVERTING,5,4)
  95. #endif
  96. #if HAS_SOFTWARE_ENDSTOPS
  97. #undef EDGE_R
  98. #define EDGE_R 30
  99. cmd.font(font_small)
  100. .text (BTN_POS(1,5), BTN_SIZE(3,1), GET_TEXTF(SOFT_ENDSTOPS), OPT_RIGHTX | OPT_CENTERY)
  101. .colors(ui_toggle)
  102. .tag(2).toggle2(BTN_POS(4,5), BTN_SIZE(3,1), GET_TEXTF(NO), GET_TEXTF(YES), getSoftEndstopState());
  103. #undef EDGE_R
  104. #define EDGE_R 0
  105. #endif
  106. cmd.font(font_medium)
  107. .colors(action_btn)
  108. .tag(1).button( BTN_POS(1,7), BTN_SIZE(6,1), GET_TEXTF(BACK));
  109. #undef GRID_COLS
  110. #undef GRID_ROWS
  111. }
  112. bool EndstopStatesScreen::onTouchEnd(uint8_t tag) {
  113. switch (tag) {
  114. case 1: GOTO_PREVIOUS(); break;
  115. #if HAS_SOFTWARE_ENDSTOPS
  116. case 2: setSoftEndstopState(!getSoftEndstopState());
  117. #endif
  118. default:
  119. return false;
  120. }
  121. return true;
  122. }
  123. void EndstopStatesScreen::onIdle() {
  124. constexpr uint32_t DIAGNOSTICS_UPDATE_INTERVAL = 100;
  125. if (refresh_timer.elapsed(DIAGNOSTICS_UPDATE_INTERVAL)) {
  126. onRefresh();
  127. refresh_timer.start();
  128. reset_menu_timeout();
  129. }
  130. BaseScreen::onIdle();
  131. }
  132. #endif // LULZBOT_TOUCH_UI