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.

move_axis_screen.cpp 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /************************
  2. * move_axis_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: <https://www.gnu.org/licenses/>. *
  20. ****************************************************************************/
  21. #include "../config.h"
  22. #include "../screens.h"
  23. #include "../screen_data.h"
  24. #ifdef FTDI_MOVE_AXIS_SCREEN
  25. using namespace FTDI;
  26. using namespace ExtUI;
  27. constexpr static MoveAxisScreenData &mydata = screen_data.MoveAxisScreen;
  28. void BaseMoveAxisScreen::onEntry() {
  29. // Since Marlin keeps only one absolute position for all the extruders,
  30. // we have to keep track of the relative motion of individual extruders
  31. // ourselves. The relative distances are reset to zero whenever this
  32. // screen is entered.
  33. LOOP_L_N(i, ExtUI::extruderCount) {
  34. mydata.e_rel[i] = 0;
  35. }
  36. BaseNumericAdjustmentScreen::onEntry();
  37. }
  38. void MoveAxisScreen::onRedraw(draw_mode_t what) {
  39. widgets_t w(what);
  40. w.precision(1);
  41. w.units(GET_TEXT_F(MSG_UNITS_MM));
  42. w.heading( GET_TEXT_F(MSG_MOVE_AXIS));
  43. w.home_buttons(20);
  44. w.color(Theme::x_axis).adjuster( 2, GET_TEXT_F(MSG_AXIS_X), getAxisPosition_mm(X), canMove(X));
  45. w.color(Theme::y_axis).adjuster( 4, GET_TEXT_F(MSG_AXIS_Y), getAxisPosition_mm(Y), canMove(Y));
  46. w.color(Theme::z_axis).adjuster( 6, GET_TEXT_F(MSG_AXIS_Z), getAxisPosition_mm(Z), canMove(Z));
  47. w.color(Theme::e_axis);
  48. #if EXTRUDERS == 1
  49. w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E), mydata.e_rel[0], canMove(E0));
  50. #elif HAS_MULTI_EXTRUDER
  51. w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), mydata.e_rel[0], canMove(E0));
  52. w.adjuster( 10, GET_TEXT_F(MSG_AXIS_E2), mydata.e_rel[1], canMove(E1));
  53. #if EXTRUDERS > 2
  54. w.adjuster( 12, GET_TEXT_F(MSG_AXIS_E3), mydata.e_rel[2], canMove(E2));
  55. #endif
  56. #if EXTRUDERS > 3
  57. w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), mydata.e_rel[3], canMove(E3));
  58. #endif
  59. #endif
  60. #if Z_HOME_TO_MIN
  61. w.button(24, GET_TEXT_F(MSG_MOVE_Z_TO_TOP), !axis_should_home(Z_AXIS));
  62. #endif
  63. w.increments();
  64. }
  65. bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) {
  66. #define UI_INCREMENT_AXIS(axis) setManualFeedrate(axis, increment); UI_INCREMENT(AxisPosition_mm, axis);
  67. #define UI_DECREMENT_AXIS(axis) setManualFeedrate(axis, increment); UI_DECREMENT(AxisPosition_mm, axis);
  68. const float increment = getIncrement();
  69. switch (tag) {
  70. case 2: UI_DECREMENT_AXIS(X); break;
  71. case 3: UI_INCREMENT_AXIS(X); break;
  72. case 4: UI_DECREMENT_AXIS(Y); break;
  73. case 5: UI_INCREMENT_AXIS(Y); break;
  74. case 6: UI_DECREMENT_AXIS(Z); break;
  75. case 7: UI_INCREMENT_AXIS(Z); break;
  76. // For extruders, also update relative distances.
  77. case 8: UI_DECREMENT_AXIS(E0); mydata.e_rel[0] -= increment; break;
  78. case 9: UI_INCREMENT_AXIS(E0); mydata.e_rel[0] += increment; break;
  79. #if HAS_MULTI_EXTRUDER
  80. case 10: UI_DECREMENT_AXIS(E1); mydata.e_rel[1] -= increment; break;
  81. case 11: UI_INCREMENT_AXIS(E1); mydata.e_rel[1] += increment; break;
  82. #endif
  83. #if EXTRUDERS > 2
  84. case 12: UI_DECREMENT_AXIS(E2); mydata.e_rel[2] -= increment; break;
  85. case 13: UI_INCREMENT_AXIS(E2); mydata.e_rel[2] += increment; break;
  86. #endif
  87. #if EXTRUDERS > 3
  88. case 14: UI_DECREMENT_AXIS(E3); mydata.e_rel[3] -= increment; break;
  89. case 15: UI_INCREMENT_AXIS(E3); mydata.e_rel[3] += increment; break;
  90. #endif
  91. case 20: SpinnerDialogBox::enqueueAndWait(F("G28X")); break;
  92. case 21: SpinnerDialogBox::enqueueAndWait(F("G28Y")); break;
  93. case 22: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break;
  94. case 23: SpinnerDialogBox::enqueueAndWait(F("G28")); break;
  95. case 24: raiseZtoTop(); break;
  96. default:
  97. return false;
  98. }
  99. #undef UI_DECREMENT_AXIS
  100. #undef UI_INCREMENT_AXIS
  101. return true;
  102. }
  103. void BaseMoveAxisScreen::raiseZtoTop() {
  104. constexpr xyze_feedrate_t homing_feedrate = HOMING_FEEDRATE_MM_M;
  105. setAxisPosition_mm(Z_MAX_POS - 5, Z, homing_feedrate[Z_AXIS]);
  106. }
  107. float BaseMoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) {
  108. // Compute feedrate so that the tool lags the adjuster when it is
  109. // being held down, this allows enough margin for the planner to
  110. // connect segments and even out the motion.
  111. constexpr xyze_feedrate_t max_manual_feedrate = MANUAL_FEEDRATE;
  112. return min(max_manual_feedrate[axis] / 60.0f, ABS(increment_mm * (TOUCH_REPEATS_PER_SECOND) * 0.80f));
  113. }
  114. void BaseMoveAxisScreen::setManualFeedrate(ExtUI::axis_t axis, float increment_mm) {
  115. ExtUI::setFeedrate_mm_s(getManualFeedrate(X_AXIS + (axis - ExtUI::X), increment_mm));
  116. }
  117. void BaseMoveAxisScreen::setManualFeedrate(ExtUI::extruder_t, float increment_mm) {
  118. ExtUI::setFeedrate_mm_s(getManualFeedrate(E_AXIS, increment_mm));
  119. }
  120. void MoveAxisScreen::onIdle() {
  121. if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
  122. onRefresh();
  123. refresh_timer.start();
  124. }
  125. BaseScreen::onIdle();
  126. }
  127. #endif // FTDI_MOVE_AXIS_SCREEN