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.

M404-M407.cpp 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../../inc/MarlinConfig.h"
  23. #if ENABLED(FILAMENT_WIDTH_SENSOR)
  24. #include "../../../feature/filwidth.h"
  25. #include "../../../module/planner.h"
  26. #include "../../../module/temperature.h"
  27. #include "../../../Marlin.h"
  28. #include "../../gcode.h"
  29. /**
  30. * M404: Display or set (in current units) the nominal filament width (3mm, 1.75mm ) W<3.0>
  31. */
  32. void GcodeSuite::M404() {
  33. if (parser.seen('W')) {
  34. filament_width_nominal = parser.value_linear_units();
  35. planner.volumetric_area_nominal = CIRCLE_AREA(filament_width_nominal * 0.5);
  36. }
  37. else {
  38. SERIAL_PROTOCOLPGM("Filament dia (nominal mm):");
  39. SERIAL_PROTOCOLLN(filament_width_nominal);
  40. }
  41. }
  42. /**
  43. * M405: Turn on filament sensor for control
  44. */
  45. void GcodeSuite::M405() {
  46. // This is technically a linear measurement, but since it's quantized to centimeters and is a different
  47. // unit than everything else, it uses parser.value_byte() instead of parser.value_linear_units().
  48. if (parser.seen('D')) {
  49. meas_delay_cm = parser.value_byte();
  50. NOMORE(meas_delay_cm, MAX_MEASUREMENT_DELAY);
  51. }
  52. if (filwidth_delay_index[1] == -1) { // Initialize the ring buffer if not done since startup
  53. const uint8_t temp_ratio = thermalManager.widthFil_to_size_ratio();
  54. for (uint8_t i = 0; i < COUNT(measurement_delay); ++i)
  55. measurement_delay[i] = temp_ratio;
  56. filwidth_delay_index[0] = filwidth_delay_index[1] = 0;
  57. }
  58. filament_sensor = true;
  59. }
  60. /**
  61. * M406: Turn off filament sensor for control
  62. */
  63. void GcodeSuite::M406() {
  64. filament_sensor = false;
  65. planner.calculate_volumetric_multipliers(); // Restore correct 'volumetric_multiplier' value
  66. }
  67. /**
  68. * M407: Get measured filament diameter on serial output
  69. */
  70. void GcodeSuite::M407() {
  71. SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
  72. SERIAL_PROTOCOLLN(filament_width_meas);
  73. }
  74. #endif // FILAMENT_WIDTH_SENSOR