From 50f09cc029e21341cfe993025cf1854746ac2990 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 16 Nov 2017 00:27:24 -0600 Subject: [PATCH] Miscellaneous cleanup --- Marlin/src/feature/Max7219_Debug_LEDs.cpp | 51 +++++++++-------------- Marlin/src/gcode/geometry/M206_M428.cpp | 4 +- Marlin/src/gcode/motion/M290.cpp | 4 +- Marlin/src/module/planner.cpp | 3 +- 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/Marlin/src/feature/Max7219_Debug_LEDs.cpp b/Marlin/src/feature/Max7219_Debug_LEDs.cpp index a57c7a0f4..b67d948bb 100644 --- a/Marlin/src/feature/Max7219_Debug_LEDs.cpp +++ b/Marlin/src/feature/Max7219_Debug_LEDs.cpp @@ -63,54 +63,41 @@ static uint8_t LEDs[8] = { 0 }; +#ifdef CPU_32_BIT + #define MS_DELAY() delayMicroseconds(5) // 32-bit processors need a delay to stabilize the signal +#else + #define MS_DELAY() NOOP +#endif + void Max7219_PutByte(uint8_t data) { CRITICAL_SECTION_START for (uint8_t i = 8; i--;) { - #ifdef CPU_32_BIT // The 32-bit processors are so fast, a small delay in the code is needed - delayMicroseconds(5); // to let the signal wires stabilize. - WRITE(MAX7219_CLK_PIN, LOW); // tick - delayMicroseconds(5); - WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW); // send 1 or 0 based on data bit - delayMicroseconds(5); - WRITE(MAX7219_CLK_PIN, HIGH); // tock - delayMicroseconds(5); - #else - WRITE(MAX7219_CLK_PIN, LOW); // tick - WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW); // send 1 or 0 based on data bit - WRITE(MAX7219_CLK_PIN, HIGH); // tock - #endif - + MS_DELAY(); + WRITE(MAX7219_CLK_PIN, LOW); // tick + MS_DELAY(); + WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW); // send 1 or 0 based on data bit + MS_DELAY(); + WRITE(MAX7219_CLK_PIN, HIGH); // tock + MS_DELAY(); data <<= 1; } CRITICAL_SECTION_END } void Max7219(const uint8_t reg, const uint8_t data) { - #ifdef CPU_32_BIT - delayMicroseconds(5); - #endif + MS_DELAY(); CRITICAL_SECTION_START WRITE(MAX7219_LOAD_PIN, LOW); // begin - #ifdef CPU_32_BIT // The 32-bit processors are so fast, a small delay in the code is needed - delayMicroseconds(5); // to let the signal wires stabilize. - #endif + MS_DELAY(); Max7219_PutByte(reg); // specify register - #ifdef CPU_32_BIT - delayMicroseconds(5); - #endif + MS_DELAY(); Max7219_PutByte(data); // put data - #ifdef CPU_32_BIT - delayMicroseconds(5); - #endif + MS_DELAY(); WRITE(MAX7219_LOAD_PIN, LOW); // and tell the chip to load the data - #ifdef CPU_32_BIT - delayMicroseconds(5); - #endif + MS_DELAY(); WRITE(MAX7219_LOAD_PIN, HIGH); CRITICAL_SECTION_END - #ifdef CPU_32_BIT - delayMicroseconds(5); - #endif + MS_DELAY(); } void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) { diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 4d15fb56b..88a60d545 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -43,8 +43,8 @@ void GcodeSuite::M206() { set_home_offset((AxisEnum)i, parser.value_linear_units()); #if ENABLED(MORGAN_SCARA) - if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_linear_units()); // Theta - if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_linear_units()); // Psi + if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_float()); // Theta + if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi #endif report_current_position(); diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index c0500bf1d..cdf5c9d6a 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -36,14 +36,14 @@ void GcodeSuite::M290() { #if ENABLED(BABYSTEP_XY) for (uint8_t a = X_AXIS; a <= Z_AXIS; a++) if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) { - const float offs = constrain(parser.value_axis_units(a), -2, 2); + const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2); #if ENABLED(BABYSTEP_ZPROBE_OFFSET) if (a == Z_AXIS) { zprobe_zoffset += offs; refresh_zprobe_zoffset(true); // 'true' to not babystep } #endif - thermalManager.babystep_axis(a, offs * planner.axis_steps_per_mm[a]); + thermalManager.babystep_axis((AxisEnum)a, offs * planner.axis_steps_per_mm[a]); } #else if (parser.seenval('Z') || parser.seenval('S')) { diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 8b20c9158..30c9315bf 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -542,8 +542,7 @@ void Planner::check_axes_activity() { } inline float calculate_volumetric_multiplier(const float &diameter) { - if (!parser.volumetric_enabled || diameter == 0) return 1.0; - return 1.0 / CIRCLE_AREA(diameter * 0.5); + return (parser.volumetric_enabled && diameter) ? 1.0 / CIRCLE_AREA(diameter * 0.5) : 1.0; } void Planner::calculate_volumetric_multipliers() {