Skip to content

Commit

Permalink
Merge branch 'bugfix-2.1.x' into pr/25146
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jan 11, 2023
2 parents a45c5fe + a71a62c commit c331513
Show file tree
Hide file tree
Showing 111 changed files with 2,413 additions and 2,092 deletions.
68 changes: 62 additions & 6 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@
#endif

// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers).
#define DELTA_PRINTABLE_RADIUS 140.0 // (mm)
#define PRINTABLE_RADIUS 140.0 // (mm)

// Maximum reachable area
#define DELTA_MAX_RADIUS 140.0 // (mm)
Expand Down Expand Up @@ -969,7 +969,7 @@
#if ENABLED(MORGAN_SCARA)

//#define DEBUG_SCARA_KINEMATICS
#define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
#define FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
// Radius around the center where the arm cannot reach
#define MIDDLE_DEAD_ZONE_R 0 // (mm)
Expand Down Expand Up @@ -1004,7 +1004,7 @@
#define TPARA_OFFSET_Y 0 // (mm)
#define TPARA_OFFSET_Z 0 // (mm)

#define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
#define FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
// Radius around the center where the arm cannot reach
#define MIDDLE_DEAD_ZONE_R 0 // (mm)
Expand All @@ -1014,6 +1014,59 @@
#define PSI_HOMING_OFFSET 0
#endif

// @section polar

/**
* POLAR Kinematics
* developed by Kadir ilkimen for PolarBear CNC and babyBear
* https://github.com/kadirilkimen/Polar-Bear-Cnc-Machine
* https://github.com/kadirilkimen/babyBear-3D-printer
*
* A polar machine can have different configurations.
* This kinematics is only compatible with the following configuration:
* X : Independent linear
* Y or B : Polar
* Z : Independent linear
*
* For example, PolarBear has CoreXZ plus Polar Y or B.
*
* Motion problem for Polar axis near center / origin:
*
* 3D printing:
* Movements very close to the center of the polar axis take more time than others.
* This brief delay results in more material deposition due to the pressure in the nozzle.
*
* Current Kinematics and feedrate scaling deals with this by making the movement as fast
* as possible. It works for slow movements but doesn't work well with fast ones. A more
* complicated extrusion compensation must be implemented.
*
* Ideally, it should estimate that a long rotation near the center is ahead and will cause
* unwanted deposition. Therefore it can compensate the extrusion beforehand.
*
* Laser cutting:
* Same thing would be a problem for laser engraving too. As it spends time rotating at the
* center point, more likely it will burn more material than it should. Therefore similar
* compensation would be implemented for laser-cutting operations.
*
* Milling:
* This shouldn't be a problem for cutting/milling operations.
*/
//#define POLAR
#if ENABLED(POLAR)
#define DEFAULT_SEGMENTS_PER_SECOND 180 // If movement is choppy try lowering this value
#define PRINTABLE_RADIUS 82.0f // (mm) Maximum travel of X axis

// Movements fall inside POLAR_FAST_RADIUS are assigned the highest possible feedrate
// to compensate unwanted deposition related to the near-origin motion problem.
#define POLAR_FAST_RADIUS 3.0f // (mm)

// Radius which is unreachable by the tool.
// Needed if the tool is not perfectly aligned to the center of the polar axis.
#define POLAR_CENTER_OFFSET 0.0f // (mm)

#define FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
#endif

// @section machine

// Articulated robot (arm). Joints are directly mapped to axes with no kinematics.
Expand Down Expand Up @@ -1420,13 +1473,13 @@
// 2 or 3 sets of coordinates for deploying and retracting the spring loaded touch probe on G29,
// if servo actuated touch probe is not defined. Uncomment as appropriate for your printer/probe.

#define Z_PROBE_ALLEN_KEY_DEPLOY_1 { 30.0, DELTA_PRINTABLE_RADIUS, 100.0 }
#define Z_PROBE_ALLEN_KEY_DEPLOY_1 { 30.0, PRINTABLE_RADIUS, 100.0 }
#define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE XY_PROBE_FEEDRATE

#define Z_PROBE_ALLEN_KEY_DEPLOY_2 { 0.0, DELTA_PRINTABLE_RADIUS, 100.0 }
#define Z_PROBE_ALLEN_KEY_DEPLOY_2 { 0.0, PRINTABLE_RADIUS, 100.0 }
#define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE (XY_PROBE_FEEDRATE)/10

#define Z_PROBE_ALLEN_KEY_DEPLOY_3 { 0.0, (DELTA_PRINTABLE_RADIUS) * 0.75, 100.0 }
#define Z_PROBE_ALLEN_KEY_DEPLOY_3 { 0.0, (PRINTABLE_RADIUS) * 0.75, 100.0 }
#define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE XY_PROBE_FEEDRATE

#define Z_PROBE_ALLEN_KEY_STOW_1 { -64.0, 56.0, 23.0 } // Move the probe into position
Expand Down Expand Up @@ -3293,6 +3346,9 @@
//#define RGB_LED_G_PIN 43
//#define RGB_LED_B_PIN 35
//#define RGB_LED_W_PIN -1
#endif

#if ANY(RGB_LED, RGBW_LED, PCA9632)
//#define RGB_STARTUP_TEST // For PWM pins, fade between all colors
#if ENABLED(RGB_STARTUP_TEST)
#define RGB_STARTUP_TEST_INNER_MS 10 // (ms) Reduce or increase fading speed
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* here we define this default string as the date where the latest release
* version was tagged.
*/
//#define STRING_DISTRIBUTION_DATE "2023-01-04"
//#define STRING_DISTRIBUTION_DATE "2023-01-10"

/**
* Defines a generic printer name to be output to the LCD after booting Marlin.
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/HAL/SAMD21/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = {
{ {.pTcc=TCC0}, TimerType::tcc, TCC0_IRQn, TC_PRIORITY(0) }, // 0 - stepper (assigned priority 2)
{ {.pTcc=TCC1}, TimerType::tcc, TCC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers)
{ {.pTcc=TCC2}, TimerType::tcc, TCC2_IRQn, 5 }, // 2 - tone (reserved by framework and fixed assigned priority 5)
{ {.pTc=TC3}, TimerType::tc, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo (assigned priority 1)
{ {.pTc=TC4}, TimerType::tc, TC4_IRQn, TC_PRIORITY(4) }, // 4 - software serial (no interrupts used)
{ {.pTc=TC5}, TimerType::tc, TC5_IRQn, TC_PRIORITY(5) },
{ {.pTc=TC6}, TimerType::tc, TC6_IRQn, TC_PRIORITY(6) },
{ {.pTc=TC7}, TimerType::tc, TC7_IRQn, TC_PRIORITY(7) },
{ {.pTc=TC3}, TimerType::tc, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo (assigned priority 1)
{ {.pTc=TC4}, TimerType::tc, TC4_IRQn, TC_PRIORITY(4) }, // 4 - software serial (no interrupts used)
{ {.pTc=TC5}, TimerType::tc, TC5_IRQn, TC_PRIORITY(5) },
{ {.pTc=TC6}, TimerType::tc, TC6_IRQn, TC_PRIORITY(6) },
{ {.pTc=TC7}, TimerType::tc, TC7_IRQn, TC_PRIORITY(7) },
{ {.pRtc=RTC}, TimerType::rtc, RTC_IRQn, TC_PRIORITY(8) } // 8 - temperature (assigned priority 6)
};

Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@
#include "module/polargraph.h"
#elif IS_SCARA
#include "module/scara.h"
#elif ENABLED(POLAR)
#include "module/polar.h"
#endif

#if HAS_LEVELING
Expand Down Expand Up @@ -232,7 +234,7 @@
#include "feature/password/password.h"
#endif

#if ENABLED(DGUS_LCD_UI_MKS)
#if DGUS_LCD_UI_MKS
#include "lcd/extui/dgus/DGUSScreenHandler.h"
#endif

Expand Down
1 change: 1 addition & 0 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
#define STR_S_SEG_PER_SEC "S<seg-per-sec>"
#define STR_DELTA_SETTINGS "Delta (L<diagonal-rod> R<radius> H<height> S<seg-per-sec> XYZ<tower-angle-trim> ABC<rod-trim>)"
#define STR_SCARA_SETTINGS "SCARA"
#define STR_POLAR_SETTINGS "Polar"
#define STR_POLARGRAPH_SETTINGS "Polargraph"
#define STR_SCARA_P_T_Z "P<theta-psi-offset> T<theta-offset> Z<home-offset>"
#define STR_ENDSTOP_ADJUSTMENT "Endstop adjustment"
Expand Down
32 changes: 15 additions & 17 deletions Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,14 @@
#else // UBL_SEGMENTED

#if IS_SCARA
#define DELTA_SEGMENT_MIN_LENGTH 0.25 // SCARA minimum segment size is 0.25mm
#elif ENABLED(DELTA)
#define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DEFAULT_SEGMENTS_PER_SECOND)
#elif ENABLED(POLARGRAPH)
#define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DEFAULT_SEGMENTS_PER_SECOND)
#define SEGMENT_MIN_LENGTH 0.25 // SCARA minimum segment size is 0.25mm
#elif IS_KINEMATIC
#define SEGMENT_MIN_LENGTH 0.10 // (mm) Still subject to DEFAULT_SEGMENTS_PER_SECOND
#else // CARTESIAN
#ifdef LEVELED_SEGMENT_LENGTH
#define DELTA_SEGMENT_MIN_LENGTH LEVELED_SEGMENT_LENGTH
#define SEGMENT_MIN_LENGTH LEVELED_SEGMENT_LENGTH
#else
#define DELTA_SEGMENT_MIN_LENGTH 1.00 // mm (similar to G2/G3 arc segmentation)
#define SEGMENT_MIN_LENGTH 1.00 // (mm) Similar to G2/G3 arc segmentation
#endif
#endif

Expand All @@ -361,23 +359,23 @@
const xyze_pos_t total = destination - current_position;

const float cart_xy_mm_2 = HYPOT2(total.x, total.y),
cart_xy_mm = SQRT(cart_xy_mm_2); // Total XY distance
cart_xy_mm = SQRT(cart_xy_mm_2); // Total XY distance

#if IS_KINEMATIC
const float seconds = cart_xy_mm / scaled_fr_mm_s; // Duration of XY move at requested rate
uint16_t segments = LROUND(segments_per_second * seconds), // Preferred number of segments for distance @ feedrate
seglimit = LROUND(cart_xy_mm * RECIPROCAL(DELTA_SEGMENT_MIN_LENGTH)); // Number of segments at minimum segment length
NOMORE(segments, seglimit); // Limit to minimum segment length (fewer segments)
const float seconds = cart_xy_mm / scaled_fr_mm_s; // Duration of XY move at requested rate
uint16_t segments = LROUND(segments_per_second * seconds), // Preferred number of segments for distance @ feedrate
seglimit = LROUND(cart_xy_mm * RECIPROCAL(SEGMENT_MIN_LENGTH)); // Number of segments at minimum segment length
NOMORE(segments, seglimit); // Limit to minimum segment length (fewer segments)
#else
uint16_t segments = LROUND(cart_xy_mm * RECIPROCAL(DELTA_SEGMENT_MIN_LENGTH)); // Cartesian fixed segment length
uint16_t segments = LROUND(cart_xy_mm * RECIPROCAL(SEGMENT_MIN_LENGTH)); // Cartesian fixed segment length
#endif

NOLESS(segments, 1U); // Must have at least one segment
const float inv_segments = 1.0f / segments; // Reciprocal to save calculation
NOLESS(segments, 1U); // Must have at least one segment
const float inv_segments = 1.0f / segments; // Reciprocal to save calculation

// Add hints to help optimize the move
PlannerHints hints(SQRT(cart_xy_mm_2 + sq(total.z)) * inv_segments); // Length of each segment
#if ENABLED(SCARA_FEEDRATE_SCALING)
PlannerHints hints(SQRT(cart_xy_mm_2 + sq(total.z)) * inv_segments); // Length of each segment
#if ENABLED(FEEDRATE_SCALING)
hints.inv_duration = scaled_fr_mm_s / hints.millimeters;
#endif

Expand Down
57 changes: 56 additions & 1 deletion Marlin/src/feature/leds/leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,62 @@ void LEDLights::setup() {
delay(500);
}
#endif // RGB_STARTUP_TEST
#endif

#elif BOTH(PCA9632, RGB_STARTUP_TEST) // PCA9632 RGB_STARTUP_TEST

constexpr int8_t led_pin_count = TERN(HAS_WHITE_LED, 4, 3);

// Startup animation
LEDColor curColor = LEDColorOff();
PCA9632_set_led_color(curColor); // blackout
delay(200);

/*
* LED Pin Counter steps -> events
* | 0-100 | 100-200 | 200-300 | 300-400 |
* fade in steady | fade out
* start next pin fade in
*/

uint16_t led_pin_counters[led_pin_count] = { 1, 0, 0 };

bool canEnd = false;
while (led_pin_counters[0] != 99 || !canEnd) {
if (led_pin_counters[0] == 99) // End loop next time pin0 counter is 99
canEnd = true;
LOOP_L_N(i, led_pin_count) {
if (led_pin_counters[i] > 0) {
if (++led_pin_counters[i] == 400) // turn off current pin counter in led_pin_counters
led_pin_counters[i] = 0;
else if (led_pin_counters[i] == 201) { // start next pin pwm
led_pin_counters[i + 1 == led_pin_count ? 0 : i + 1] = 1;
i++; // skip next pin in this loop so it doesn't increment twice
}
}
}
uint16_t r, g, b;
r = led_pin_counters[0]; curColor.r = r <= 100 ? r : r <= 300 ? 100 : 400 - r;
g = led_pin_counters[1]; curColor.g = g <= 100 ? g : g <= 300 ? 100 : 400 - g;
b = led_pin_counters[2]; curColor.b = b <= 100 ? b : b <= 300 ? 100 : 400 - b;
#if HAS_WHITE_LED
const uint16_t w = led_pin_counters[3]; curColor.w = w <= 100 ? w : w <= 300 ? 100 : 400 - w;
#endif
PCA9632_set_led_color(curColor);
delay(RGB_STARTUP_TEST_INNER_MS);
}

// Fade to white
LOOP_LE_N(led_pwm, 100) {
NOLESS(curColor.r, led_pwm);
NOLESS(curColor.g, led_pwm);
NOLESS(curColor.b, led_pwm);
TERN_(HAS_WHITE_LED, NOLESS(curColor.w, led_pwm));
PCA9632_set_led_color(curColor);
delay(RGB_STARTUP_TEST_INNER_MS);
}

#endif // PCA9632 && RGB_STARTUP_TEST

TERN_(NEOPIXEL_LED, neo.init());
TERN_(PCA9533, PCA9533_init());
TERN_(LED_USER_PRESET_STARTUP, set_default());
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/leds/neopixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void Marlin_NeoPixel::init() {
set_color(adaneo1.Color
TERN(LED_USER_PRESET_STARTUP,
(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE),
(255, 255, 255, 255))
(0, 0, 0, 0))
);
}

Expand Down
13 changes: 4 additions & 9 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
while (wait_for_user) {
impatient_beep(max_beep_count);
#if BOTH(FILAMENT_CHANGE_RESUME_ON_INSERT, FILAMENT_RUNOUT_SENSOR)
#if ENABLED(MULTI_FILAMENT_SENSOR)
#if MULTI_FILAMENT_SENSOR
#define _CASE_INSERTED(N) case N-1: if (READ(FIL_RUNOUT##N##_PIN) != FIL_RUNOUT##N##_STATE) wait_for_user = false; break;
switch (active_extruder) {
REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_INSERTED)
Expand Down Expand Up @@ -410,7 +410,6 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
#endif

TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Pause"), FPSTR(DISMISS_STR)));
TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause());

// Indicate that the printer is paused
++did_pause_print;
Expand Down Expand Up @@ -461,6 +460,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool

// If axes don't need to home then the nozzle can park
if (do_park) nozzle.park(0, park_point); // Park the nozzle by doing a Minimum Z Raise followed by an XY Move
TERN_(DWIN_LCD_PROUI, if (!do_park) ui.set_status(GET_TEXT_F(MSG_PARK_FAILED)));

#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
Expand Down Expand Up @@ -710,13 +710,8 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_

TERN_(HAS_FILAMENT_SENSOR, runout.reset());

#if ENABLED(DWIN_LCD_PROUI)
DWIN_Print_Resume();
HMI_ReturnScreen();
#else
ui.reset_status();
ui.return_to_status();
#endif
ui.reset_status();
ui.return_to_status();
}

#endif // ADVANCED_PAUSE_FEATURE
4 changes: 2 additions & 2 deletions Marlin/src/gcode/calibrate/G33.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,12 @@ void GcodeSuite::G33() {
towers_set = !parser.seen_test('T');

// The calibration radius is set to a calculated value
float dcr = probe_at_offset ? DELTA_PRINTABLE_RADIUS : DELTA_PRINTABLE_RADIUS - PROBING_MARGIN;
float dcr = probe_at_offset ? PRINTABLE_RADIUS : PRINTABLE_RADIUS - PROBING_MARGIN;
#if HAS_PROBE_XY_OFFSET
const float total_offset = HYPOT(probe.offset_xy.x, probe.offset_xy.y);
dcr -= probe_at_offset ? _MAX(total_offset, PROBING_MARGIN) : total_offset;
#endif
NOMORE(dcr, DELTA_PRINTABLE_RADIUS);
NOMORE(dcr, PRINTABLE_RADIUS);
if (parser.seenval('R')) dcr -= _MAX(parser.value_float(), 0.0f);
TERN_(HAS_DELTA_SENSORLESS_PROBING, dcr *= sensorless_radius_factor);

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/calibrate/M48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ void GcodeSuite::M48() {
float angle = random(0, 360);
const float radius = random(
#if ENABLED(DELTA)
int(0.1250000000 * (DELTA_PRINTABLE_RADIUS)),
int(0.3333333333 * (DELTA_PRINTABLE_RADIUS))
int(0.1250000000 * (PRINTABLE_RADIUS)),
int(0.3333333333 * (PRINTABLE_RADIUS))
#else
int(5), int(0.125 * _MIN(X_BED_SIZE, Y_BED_SIZE))
#endif
Expand Down
19 changes: 19 additions & 0 deletions Marlin/src/gcode/calibrate/M665.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,25 @@
);
}

#elif ENABLED(POLAR)

#include "../../module/polar.h"

/**
* M665: Set POLAR settings
* Parameters:
* S[segments] - Segments-per-second
*/
void GcodeSuite::M665() {
if (!parser.seen_any()) return M665_report();
if (parser.seenval('S')) segments_per_second = parser.value_float();
}

void GcodeSuite::M665_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, F(STR_POLAR_SETTINGS));
SERIAL_ECHOLNPGM_P(PSTR(" M665 S"), segments_per_second);
}

#endif

#endif // IS_KINEMATIC
2 changes: 1 addition & 1 deletion Marlin/src/gcode/config/M302.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "../../module/temperature.h"

#if ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin_defines.h"
#include "../../lcd/e3v2/proui/dwin.h"
#endif

/**
Expand Down
Loading

0 comments on commit c331513

Please sign in to comment.