General cleanup, code reduction in Marlin_main.cpp

This commit is contained in:
Scott Lahteine 2016-07-09 17:53:49 -07:00
parent e282d69f63
commit a8538bd7ce

View File

@ -1323,7 +1323,7 @@ inline bool code_value_bool() { return code_value_byte() > 0; }
float code_value_temp_diff() { return code_value_float(); }
#endif
inline millis_t code_value_millis() { return code_value_ulong(); }
FORCE_INLINE millis_t code_value_millis() { return code_value_ulong(); }
inline millis_t code_value_millis_from_seconds() { return code_value_float() * 1000; }
bool code_seen(char code) {
@ -3219,7 +3219,6 @@ inline void gcode_G28() {
}
int8_t px, py;
float z;
switch (state) {
case MeshReport:
@ -3317,24 +3316,22 @@ inline void gcode_G28() {
return;
}
if (code_seen('Z')) {
z = code_value_axis_units(Z_AXIS);
mbl.z_values[py][px] = code_value_axis_units(Z_AXIS);
}
else {
SERIAL_PROTOCOLLNPGM("Z not entered.");
return;
}
mbl.z_values[py][px] = z;
break;
case MeshSetZOffset:
if (code_seen('Z')) {
z = code_value_axis_units(Z_AXIS);
mbl.z_offset = code_value_axis_units(Z_AXIS);
}
else {
SERIAL_PROTOCOLLNPGM("Z not entered.");
return;
}
mbl.z_offset = z;
break;
case MeshReset:
@ -3866,15 +3863,12 @@ inline void gcode_G92() {
#if ENABLED(ULTIPANEL)
/**
* M0: // M0 - Unconditional stop - Wait for user button press on LCD
* M1: // M1 - Conditional stop - Wait for user button press on LCD
* M0: Unconditional stop - Wait for user button press on LCD
* M1: Conditional stop - Wait for user button press on LCD
*/
inline void gcode_M0_M1() {
char* args = current_command_args;
uint8_t test_value = 12;
SERIAL_ECHOPAIR("TEST", test_value);
millis_t codenum = 0;
bool hasP = false, hasS = false;
if (code_seen('P')) {
@ -4096,7 +4090,8 @@ inline void gcode_M31() {
* S<byte> Pin status from 0 - 255
*/
inline void gcode_M42() {
if (code_seen('S')) {
if (!code_seen('S')) return;
int pin_status = code_value_int();
if (pin_status < 0 || pin_status > 255) return;
@ -4123,8 +4118,6 @@ inline void gcode_M42() {
#endif
}
#endif
} // code_seen('S')
}
#if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
@ -5534,11 +5527,9 @@ inline void gcode_M220() {
* M221: Set extrusion percentage (M221 T0 S95)
*/
inline void gcode_M221() {
if (code_seen('S')) {
int sval = code_value_int();
if (get_target_extruder_from_command(221)) return;
extruder_multiplier[target_extruder] = sval;
}
if (code_seen('S'))
extruder_multiplier[target_extruder] = code_value_int();
}
/**
@ -5590,23 +5581,15 @@ inline void gcode_M226() {
#if HAS_SERVOS
/**
* M280: Get or set servo position. P<index> S<angle>
* M280: Get or set servo position. P<index> [S<angle>]
*/
inline void gcode_M280() {
int servo_index = code_seen('P') ? code_value_int() : -1;
int servo_position = 0;
if (code_seen('S')) {
servo_position = code_value_int();
if (servo_index >= 0 && servo_index < NUM_SERVOS)
MOVE_SERVO(servo_index, servo_position);
if (!code_seen('P')) return;
int servo_index = code_value_int();
if (servo_index >= 0 && servo_index < NUM_SERVOS) {
if (code_seen('S'))
MOVE_SERVO(servo_index, code_value_int());
else {
SERIAL_ERROR_START;
SERIAL_ERROR("Servo ");
SERIAL_ERROR(servo_index);
SERIAL_ERRORLN(" out of range");
}
}
else if (servo_index >= 0) {
SERIAL_ECHO_START;
SERIAL_ECHOPGM(" Servo ");
SERIAL_ECHO(servo_index);
@ -5614,6 +5597,13 @@ inline void gcode_M226() {
SERIAL_ECHOLN(servo[servo_index].read());
}
}
else {
SERIAL_ERROR_START;
SERIAL_ERROR("Servo ");
SERIAL_ERROR(servo_index);
SERIAL_ERRORLN(" out of range");
}
}
#endif // HAS_SERVOS
@ -5864,12 +5854,10 @@ inline void gcode_M303() {
* M365: SCARA calibration: Scaling factor, X, Y, Z axis
*/
inline void gcode_M365() {
for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
if (code_seen(axis_codes[i])) {
for (int8_t i = X_AXIS; i <= Z_AXIS; i++)
if (code_seen(axis_codes[i]))
axis_scaling[i] = code_value_float();
}
}
}
#endif // SCARA