Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0.x] Group G-codes to fix command-line overflow #7719

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Marlin/src/feature/caselight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#if HAS_CASE_LIGHT

int case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
uint8_t case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
bool case_light_on = CASE_LIGHT_DEFAULT_ON;

#ifndef INVERT_CASE_LIGHT
Expand All @@ -33,7 +33,6 @@ bool case_light_on = CASE_LIGHT_DEFAULT_ON;

void update_case_light() {
SET_OUTPUT(CASE_LIGHT_PIN);
uint8_t case_light_bright = (uint8_t)case_light_brightness;
if (case_light_on) {
if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) {
analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 - case_light_brightness : case_light_brightness );
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/caselight.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef __CASELIGHT_H__
#define __CASELIGHT_H__

extern int case_light_brightness; // LCD routine wants INT
extern uint8_t case_light_brightness;
extern bool case_light_on;

void update_case_light();
Expand Down
129 changes: 129 additions & 0 deletions Marlin/src/gcode/config/M200-M205.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/**
* 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/>.
*
*/

#include "../gcode.h"
#include "../../Marlin.h"
#include "../../module/planner.h"

/**
* M200: Set filament diameter and set E axis units to cubic units
*
* T<extruder> - Optional extruder number. Current extruder if omitted.
* D<linear> - Diameter of the filament. Use "D0" to switch back to linear units on the E axis.
*/
void GcodeSuite::M200() {

if (get_target_extruder_from_command()) return;

if (parser.seen('D')) {
// setting any extruder filament size disables volumetric on the assumption that
// slicers either generate in extruder values as cubic mm or as as filament feeds
// for all extruders
if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0.0)) )
planner.set_filament_size(target_extruder, parser.value_linear_units());
}
planner.calculate_volumetric_multipliers();
}

/**
* M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
*
* With multiple extruders use T to specify which one.
*/
void GcodeSuite::M201() {

GET_TARGET_EXTRUDER();

LOOP_XYZE(i) {
if (parser.seen(axis_codes[i])) {
const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
planner.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
}
}
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
planner.reset_acceleration_rates();
}

/**
* M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
*
* With multiple extruders use T to specify which one.
*/
void GcodeSuite::M203() {

GET_TARGET_EXTRUDER();

LOOP_XYZE(i)
if (parser.seen(axis_codes[i])) {
const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
planner.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
}
}

/**
* M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000)
*
* P = Printing moves
* R = Retract only (no X, Y, Z) moves
* T = Travel (non printing) moves
*
* Also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate
*/
void GcodeSuite::M204() {
if (parser.seen('S')) { // Kept for legacy compatibility. Should NOT BE USED for new developments.
planner.travel_acceleration = planner.acceleration = parser.value_linear_units();
SERIAL_ECHOLNPAIR("Setting Print and Travel Acceleration: ", planner.acceleration);
}
if (parser.seen('P')) {
planner.acceleration = parser.value_linear_units();
SERIAL_ECHOLNPAIR("Setting Print Acceleration: ", planner.acceleration);
}
if (parser.seen('R')) {
planner.retract_acceleration = parser.value_linear_units();
SERIAL_ECHOLNPAIR("Setting Retract Acceleration: ", planner.retract_acceleration);
}
if (parser.seen('T')) {
planner.travel_acceleration = parser.value_linear_units();
SERIAL_ECHOLNPAIR("Setting Travel Acceleration: ", planner.travel_acceleration);
}
}

/**
* M205: Set Advanced Settings
*
* S = Min Feed Rate (units/s)
* T = Min Travel Feed Rate (units/s)
* B = Min Segment Time (µs)
* X = Max X Jerk (units/sec^2)
* Y = Max Y Jerk (units/sec^2)
* Z = Max Z Jerk (units/sec^2)
* E = Max E Jerk (units/sec^2)
*/
void GcodeSuite::M205() {
if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
if (parser.seen('B')) planner.min_segment_time = parser.value_millis();
if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();
if (parser.seen('E')) planner.max_jerk[E_AXIS] = parser.value_linear_units();
}
45 changes: 0 additions & 45 deletions Marlin/src/gcode/config/M200.cpp

This file was deleted.

43 changes: 0 additions & 43 deletions Marlin/src/gcode/config/M201.cpp

This file was deleted.

40 changes: 0 additions & 40 deletions Marlin/src/gcode/config/M203.cpp

This file was deleted.

52 changes: 0 additions & 52 deletions Marlin/src/gcode/config/M204.cpp

This file was deleted.

45 changes: 0 additions & 45 deletions Marlin/src/gcode/config/M205.cpp

This file was deleted.

Loading