FILAMENT_WIDTH_SENSOR feature

This commit is contained in:
Scott Lahteine
2017-09-12 15:02:17 -05:00
parent d5fe0fb02b
commit 4f1eadf41f
10 changed files with 81 additions and 91 deletions

View File

@ -20,10 +20,33 @@
*
*/
#include "../../../inc/MarlinConfig.h"
#if ENABLED(FILAMENT_WIDTH_SENSOR)
#include "../../../feature/filwidth.h"
#include "../../../module/planner.h"
#include "../../../module/temperature.h"
#include "../../../Marlin.h"
#include "../../gcode.h"
/**
* M404: Display or set (in current units) the nominal filament width (3mm, 1.75mm ) W<3.0>
*/
void GcodeSuite::M404() {
if (parser.seen('W')) {
filament_width_nominal = parser.value_linear_units();
}
else {
SERIAL_PROTOCOLPGM("Filament dia (nominal mm):");
SERIAL_PROTOCOLLN(filament_width_nominal);
}
}
/**
* M405: Turn on filament sensor for control
*/
void gcode_M405() {
void GcodeSuite::M405() {
// This is technically a linear measurement, but since it's quantized to centimeters and is a different
// unit than everything else, it uses parser.value_byte() instead of parser.value_linear_units().
if (parser.seen('D')) {
@ -47,3 +70,21 @@ void gcode_M405() {
//SERIAL_PROTOCOLPGM("Extrusion ratio(%):");
//SERIAL_PROTOCOL(planner.flow_percentage[active_extruder]);
}
/**
* M406: Turn off filament sensor for control
*/
void GcodeSuite::M406() {
filament_sensor = false;
calculate_volumetric_multipliers(); // Restore correct 'volumetric_multiplier' value
}
/**
* M407: Get measured filament diameter on serial output
*/
void GcodeSuite::M407() {
SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
SERIAL_PROTOCOLLN(filament_width_meas);
}
#endif // FILAMENT_WIDTH_SENSOR

View File

@ -102,11 +102,6 @@ void GcodeSuite::get_destination_from_command() {
//
// Placeholders for non-migrated codes
//
extern void gcode_G0_G1(
#if IS_SCARA
bool fast_move=false
#endif
);
extern void gcode_G2_G3(bool clockwise);
extern void gcode_G4();
extern void gcode_G5();
@ -216,10 +211,6 @@ extern void gcode_M381();
extern void gcode_M400();
extern void gcode_M401();
extern void gcode_M402();
extern void gcode_M404();
extern void gcode_M405();
extern void gcode_M406();
extern void gcode_M407();
extern void gcode_M410();
extern void gcode_M428();
extern void gcode_M500();
@ -871,16 +862,16 @@ void GcodeSuite::process_next_command() {
#if ENABLED(FILAMENT_WIDTH_SENSOR)
case 404: // M404: Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
gcode_M404();
M404();
break;
case 405: // M405: Turn on filament sensor for control
gcode_M405();
M405();
break;
case 406: // M406: Turn off filament sensor for control
gcode_M406();
M406();
break;
case 407: // M407: Display measured filament diameter
gcode_M407();
M407();
break;
#endif // FILAMENT_WIDTH_SENSOR

View File

@ -1,34 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* M404: Display or set (in current units) the nominal filament width (3mm, 1.75mm ) W<3.0>
*/
void gcode_M404() {
if (parser.seen('W')) {
filament_width_nominal = parser.value_linear_units();
}
else {
SERIAL_PROTOCOLPGM("Filament dia (nominal mm):");
SERIAL_PROTOCOLLN(filament_width_nominal);
}
}

View File

@ -1,29 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* M406: Turn off filament sensor for control
*/
void gcode_M406() {
filament_sensor = false;
calculate_volumetric_multipliers(); // Restore correct 'volumetric_multiplier' value
}

View File

@ -1,29 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* M407: Get measured filament diameter on serial output
*/
void gcode_M407() {
SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
SERIAL_PROTOCOLLN(filament_width_meas);
}