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.

M166.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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. #include "../../../inc/MarlinConfig.h"
  23. #if ENABLED(GRADIENT_MIX)
  24. #include "../../gcode.h"
  25. #include "../../../module/motion.h"
  26. #include "../../../module/planner.h"
  27. #include "../../../feature/mixing.h"
  28. inline void echo_mix() {
  29. SERIAL_ECHOPAIR(" (", mixer.mix[0], "%|", mixer.mix[1], "%)");
  30. }
  31. inline void echo_zt(const int t, const float &z) {
  32. mixer.update_mix_from_vtool(t);
  33. SERIAL_ECHOPAIR_P(SP_Z_STR, z, SP_T_STR, t);
  34. echo_mix();
  35. }
  36. /**
  37. * M166: Set a simple gradient mix for a two-component mixer
  38. * based on the Geeetech A10M implementation by Jone Liu.
  39. *
  40. * S[bool] - Enable / disable gradients
  41. * A[float] - Starting Z for the gradient
  42. * Z[float] - Ending Z for the gradient. (Must be greater than the starting Z.)
  43. * I[index] - V-Tool to use as the starting mix.
  44. * J[index] - V-Tool to use as the ending mix.
  45. *
  46. * T[index] - A V-Tool index to use as an alias for the Gradient (Requires GRADIENT_VTOOL)
  47. * T with no index clears the setting. Note: This can match the I or J value.
  48. *
  49. * Example: M166 S1 A0 Z20 I0 J1
  50. */
  51. void GcodeSuite::M166() {
  52. if (parser.seenval('A')) mixer.gradient.start_z = parser.value_float();
  53. if (parser.seenval('Z')) mixer.gradient.end_z = parser.value_float();
  54. if (parser.seenval('I')) mixer.gradient.start_vtool = (uint8_t)constrain(parser.value_int(), 0, MIXING_VIRTUAL_TOOLS);
  55. if (parser.seenval('J')) mixer.gradient.end_vtool = (uint8_t)constrain(parser.value_int(), 0, MIXING_VIRTUAL_TOOLS);
  56. #if ENABLED(GRADIENT_VTOOL)
  57. if (parser.seen('T')) mixer.gradient.vtool_index = parser.byteval('T', -1);
  58. #endif
  59. if (parser.seen('S')) mixer.gradient.enabled = parser.value_bool();
  60. mixer.refresh_gradient();
  61. SERIAL_ECHOPGM("Gradient Mix ");
  62. serialprint_onoff(mixer.gradient.enabled);
  63. if (mixer.gradient.enabled) {
  64. #if ENABLED(GRADIENT_VTOOL)
  65. if (mixer.gradient.vtool_index >= 0) {
  66. SERIAL_ECHOPAIR(" (T", mixer.gradient.vtool_index);
  67. SERIAL_CHAR(')');
  68. }
  69. #endif
  70. SERIAL_ECHOPGM(" ; Start");
  71. echo_zt(mixer.gradient.start_vtool, mixer.gradient.start_z);
  72. SERIAL_ECHOPGM(" ; End");
  73. echo_zt(mixer.gradient.end_vtool, mixer.gradient.end_z);
  74. mixer.update_mix_from_gradient();
  75. SERIAL_ECHOPGM(" ; Current Z");
  76. #if ENABLED(DELTA)
  77. get_cartesian_from_steppers();
  78. SERIAL_ECHO(cartes.z);
  79. #else
  80. SERIAL_ECHO(planner.get_axis_position_mm(Z_AXIS));
  81. #endif
  82. echo_mix();
  83. }
  84. SERIAL_EOL();
  85. }
  86. #endif // GRADIENT_MIX