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.7KB

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