diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000000..a0fa3eff170e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# editorconfig.org +root = true + +[{*.patch,syntax_test_*}] +trim_trailing_whitespace = false + +[{*.c,*.cpp,*.h}] +charset = utf-8 + +[{*.c,*.cpp,*.h,Makefile}] +trim_trailing_whitespace = true +insert_final_newline = true +end_of_line = lf +indent_style = space +indent_size = 2 + +[{*.py,*.conf,*.sublime-project}] +indent_style = tab +indent_size = 4 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 91f9435f693b..4f75597c7b8e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,4 +1,4 @@ -name: CI +name: Nightly Build on: schedule: diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 120fb123192f..bd21c09d5da1 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1191,6 +1191,7 @@ #define MESH_TEST_HOTEND_TEMP 205 // (°C) Default nozzle temperature for the G26 Mesh Validation Tool. #define MESH_TEST_BED_TEMP 60 // (°C) Default bed temperature for the G26 Mesh Validation Tool. #define G26_XY_FEEDRATE 20 // (mm/s) Feedrate for XY Moves for the G26 Mesh Validation Tool. + #define G26_RETRACT_MULTIPLIER 1.0 // G26 Q (retraction) used by default between mesh test elements. #endif #endif diff --git a/Marlin/Makefile b/Marlin/Makefile index fcd763881eef..df44b6f718e3 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -789,11 +789,11 @@ sym: $(BUILD_DIR)/$(TARGET).sym # Do not try to reset an Arduino if it's not one upload: $(BUILD_DIR)/$(TARGET).hex ifeq (${AVRDUDE_PROGRAMMER}, arduino) - stty hup < $(UPLOAD_PORT); true + stty hup < $(UPLOAD_PORT); true endif - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) ifeq (${AVRDUDE_PROGRAMMER}, arduino) - stty -hup < $(UPLOAD_PORT); true + stty -hup < $(UPLOAD_PORT); true endif # Display size of file. @@ -801,10 +801,10 @@ HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex ELFSIZE = $(SIZE) $(SIZE_FLAGS) $(BUILD_DIR)/$(TARGET).elf; \ $(SIZE) $(BUILD_DIR)/$(TARGET).elf sizebefore: - $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi + $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi sizeafter: build - $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi + $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. @@ -816,71 +816,71 @@ COFFCONVERT=$(OBJCOPY) --debugging \ coff: $(BUILD_DIR)/$(TARGET).elf - $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof + $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof extcoff: $(TARGET).elf - $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof .SUFFIXES: .elf .hex .eep .lss .sym .bin .PRECIOUS: .o .elf.hex: - $(Pecho) " COPY $@" - $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + $(Pecho) " COPY $@" + $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ .elf.bin: - $(Pecho) " COPY $@" - $P $(OBJCOPY) -O binary -R .eeprom $< $@ + $(Pecho) " COPY $@" + $P $(OBJCOPY) -O binary -R .eeprom $< $@ .elf.eep: - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ # Create extended listing file from ELF output file. .elf.lss: - $(OBJDUMP) -h -S $< > $@ + $(OBJDUMP) -h -S $< > $@ # Create a symbol table from ELF output file. .elf.sym: - $(NM) -n $< > $@ + $(NM) -n $< > $@ # Link: create ELF output file from library. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h - $(Pecho) " CXX $@" - $P $(CC) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX) + $(Pecho) " CXX $@" + $P $(CC) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX) # Object files that were found in "src" will be stored in $(BUILD_DIR) # in directories that mirror the structure of "src" $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE) - $(Pecho) " CC $<" - $P $(CC) -MMD -c $(ALL_CFLAGS) $(CWARN) $< -o $@ + $(Pecho) " CC $<" + $P $(CC) -MMD -c $(ALL_CFLAGS) $(CWARN) $< -o $@ $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE) - $(Pecho) " CXX $<" - $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(CXXWARN) $< -o $@ + $(Pecho) " CXX $<" + $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(CXXWARN) $< -o $@ # Object files for Arduino libs will be created in $(BUILD_DIR)/arduino $(BUILD_DIR)/arduino/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE) - $(Pecho) " CC $<" - $P $(CC) -MMD -c $(ALL_CFLAGS) $(LIBWARN) $< -o $@ + $(Pecho) " CC $<" + $P $(CC) -MMD -c $(ALL_CFLAGS) $(LIBWARN) $< -o $@ $(BUILD_DIR)/arduino/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE) - $(Pecho) " CXX $<" - $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(LIBWARN) $< -o $@ + $(Pecho) " CXX $<" + $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(LIBWARN) $< -o $@ $(BUILD_DIR)/arduino/%.o: %.S $(MAKEFILE) - $(Pecho) " CXX $<" - $P $(CXX) -MMD -c $(ALL_ASFLAGS) $< -o $@ + $(Pecho) " CXX $<" + $P $(CXX) -MMD -c $(ALL_ASFLAGS) $< -o $@ # Target: clean project. clean: - $(Pecho) " RMDIR $(BUILD_DIR)/" - $P rm -rf $(BUILD_DIR) + $(Pecho) " RMDIR $(BUILD_DIR)/" + $P rm -rf $(BUILD_DIR) .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter diff --git a/Marlin/src/HAL/HAL_LPC1768/main.cpp b/Marlin/src/HAL/HAL_LPC1768/main.cpp index 581dd86716a6..d7ba62fe5e98 100644 --- a/Marlin/src/HAL/HAL_LPC1768/main.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/main.cpp @@ -136,15 +136,6 @@ void HAL_init() { #endif } - #if NUM_SERIAL > 0 - MYSERIAL0.begin(BAUDRATE); - #if NUM_SERIAL > 1 - MYSERIAL1.begin(BAUDRATE); - #endif - SERIAL_PRINTF("\n\necho:%s (%dMhz) Initialized\n", isLPC1769() ? "LPC1769" : "LPC1768", SystemCoreClock / 1000000); - SERIAL_FLUSHTX(); - #endif - HAL_timer_init(); } diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 180bedd87c2d..bb418b1e9d2a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -880,15 +880,10 @@ void setup() { #if NUM_SERIAL > 0 MYSERIAL0.begin(BAUDRATE); - #if NUM_SERIAL > 1 - MYSERIAL1.begin(BAUDRATE); - #endif - #endif - - #if NUM_SERIAL > 0 uint32_t serial_connect_timeout = millis() + 1000UL; while (!MYSERIAL0 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #if NUM_SERIAL > 1 + MYSERIAL1.begin(BAUDRATE); serial_connect_timeout = millis() + 1000UL; while (!MYSERIAL1 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #endif diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 4e6829342df5..904c25d86849 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -310,19 +310,20 @@ #define BOARD_BEAST 4200 // STM32F4xxVxT6 Libmaple-based STM32F4 controller #define BOARD_GENERIC_STM32F4 4201 // STM32 STM32GENERIC-based STM32F4 controller #define BOARD_ARMED 4202 // Arm'ed STM32F4-based controller -#define BOARD_RUMBA32 4203 // RUMBA32 STM32F4-based controller -#define BOARD_BLACK_STM32F407VE 4204 // BLACK_STM32F407VE -#define BOARD_BLACK_STM32F407ZE 4205 // BLACK_STM32F407ZE -#define BOARD_STEVAL_3DP001V1 4206 // STEVAL-3DP001V1 3D PRINTER BOARD -#define BOARD_BTT_SKR_PRO_V1_1 4207 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) -#define BOARD_BTT_BTT002_V1_0 4208 // BigTreeTech BTT002 v1.0 (STM32F407VE) -#define BOARD_BTT_GTR_V1_0 4209 // BigTreeTech GTR v1.0 (STM32F407IGT) -#define BOARD_LERDGE_K 4210 // Lerdge K (STM32F407ZG) -#define BOARD_LERDGE_X 4211 // Lerdge X (STM32F407VE) -#define BOARD_VAKE403D 4212 // VAkE 403D (STM32F446VET6) -#define BOARD_FYSETC_S6 4213 // FYSETC S6 board -#define BOARD_FLYF407ZG 4214 // FLYF407ZG board (STM32F407ZG) -#define BOARD_MKS_ROBIN2 4215 // MKS_ROBIN2 (STM32F407ZE) +#define BOARD_RUMBA32_AUS3D 4203 // RUMBA32 STM32F446VET6 based controller from Aus3D +#define BOARD_RUMBA32_MKS 4204 // RUMBA32 STM32F446VET6 based controller from Makerbase +#define BOARD_BLACK_STM32F407VE 4205 // BLACK_STM32F407VE +#define BOARD_BLACK_STM32F407ZE 4206 // BLACK_STM32F407ZE +#define BOARD_STEVAL_3DP001V1 4207 // STEVAL-3DP001V1 3D PRINTER BOARD +#define BOARD_BTT_SKR_PRO_V1_1 4208 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) +#define BOARD_BTT_BTT002_V1_0 4209 // BigTreeTech BTT002 v1.0 (STM32F407VE) +#define BOARD_BTT_GTR_V1_0 4210 // BigTreeTech GTR v1.0 (STM32F407IGT) +#define BOARD_LERDGE_K 4211 // Lerdge K (STM32F407ZG) +#define BOARD_LERDGE_X 4212 // Lerdge X (STM32F407VE) +#define BOARD_VAKE403D 4213 // VAkE 403D (STM32F446VET6) +#define BOARD_FYSETC_S6 4214 // FYSETC S6 board +#define BOARD_FLYF407ZG 4215 // FLYF407ZG board (STM32F407ZG) +#define BOARD_MKS_ROBIN2 4216 // MKS_ROBIN2 (STM32F407ZE) // // ARM Cortex M7 diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/abl.cpp index 5bc08bc69577..74821ba2ec5f 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/abl.cpp @@ -43,6 +43,7 @@ bed_mesh_t z_values; * Extrapolate a single point from its neighbors */ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { + if (!isnan(z_values[x][y])) return; if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM("Extrapolate ["); if (x < 10) DEBUG_CHAR(' '); @@ -54,10 +55,6 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t DEBUG_CHAR(ydir ? (ydir > 0 ? '+' : '-') : ' '); DEBUG_ECHOLNPGM("]"); } - if (!isnan(z_values[x][y])) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(" (done)"); - return; // Don't overwrite good values. - } // Get X neighbors, Y neighbors, and XY neighbors const uint8_t x1 = x + xdir, y1 = y + ydir, x2 = x1 + xdir, y2 = y1 + ydir; diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 4ef98578c56b..b8ec262693f6 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -43,13 +43,16 @@ #include "../../lcd/ultralcd.h" #define EXTRUSION_MULTIPLIER 1.0 -#define RETRACTION_MULTIPLIER 1.0 #define PRIME_LENGTH 10.0 #define OOZE_AMOUNT 0.3 #define INTERSECTION_CIRCLE_RADIUS 5 #define CROSSHAIRS_SIZE 3 +#ifndef G26_RETRACT_MULTIPLIER + #define G26_RETRACT_MULTIPLIER 1.0 // x 1mm +#endif + #ifndef G26_XY_FEEDRATE #define G26_XY_FEEDRATE (PLANNER_XY_FEEDRATE() / 3.0) #endif @@ -509,7 +512,7 @@ void GcodeSuite::G26() { if (parser.seenval('T')) tool_change(parser.value_int()); g26_extrusion_multiplier = EXTRUSION_MULTIPLIER; - g26_retraction_multiplier = RETRACTION_MULTIPLIER; + g26_retraction_multiplier = G26_RETRACT_MULTIPLIER; g26_layer_height = MESH_TEST_LAYER_HEIGHT; g26_prime_length = PRIME_LENGTH; g26_bed_temp = MESH_TEST_BED_TEMP; diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index a92e36811472..5173505164fb 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -958,10 +958,8 @@ G29_TYPE GcodeSuite::G29() { // Restore state after probing if (!faux) restore_feedrate_and_scaling(); - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G29"); - - if (planner.leveling_active) - sync_plan_position(); + // Sync the planner from the current_position + if (planner.leveling_active) sync_plan_position(); #if HAS_BED_PROBE && defined(Z_AFTER_PROBING) probe.move_z_after_probing(); @@ -975,6 +973,8 @@ G29_TYPE GcodeSuite::G29() { report_current_position(); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G29"); + G29_RETURN(isnan(measured_z)); } diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 23d9cd399274..b6db9de532c8 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-02-05" + #define STRING_DISTRIBUTION_DATE "2020-02-09" #endif /** diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index f3f73f3da11a..1491d881d526 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -529,11 +529,11 @@ void Endstops::update() { // With Dual X, endstops are only checked in the homing direction for the active extruder #if ENABLED(DUAL_X_CARRIAGE) #define E0_ACTIVE stepper.movement_extruder() == 0 - #define X_MIN_TEST ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE)) - #define X_MAX_TEST ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE)) + #define X_MIN_TEST() ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE)) + #define X_MAX_TEST() ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE)) #else - #define X_MIN_TEST true - #define X_MAX_TEST true + #define X_MIN_TEST() true + #define X_MAX_TEST() true #endif // Use HEAD for core axes, AXIS for others @@ -690,7 +690,7 @@ void Endstops::update() { #define _ENDSTOP_HIT(AXIS, MINMAX) SBI(hit_state, _ENDSTOP(AXIS, MINMAX)) // Call the endstop triggered routine for single endstops - #define PROCESS_ENDSTOP(AXIS,MINMAX) do { \ + #define PROCESS_ENDSTOP(AXIS, MINMAX) do { \ if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX))) { \ _ENDSTOP_HIT(AXIS, MINMAX); \ planner.endstop_triggered(_AXIS(AXIS)); \ @@ -698,36 +698,58 @@ void Endstops::update() { }while(0) // Call the endstop triggered routine for dual endstops - #define PROCESS_DUAL_ENDSTOP(AXIS1, AXIS2, MINMAX) do { \ - const byte dual_hit = TEST_ENDSTOP(_ENDSTOP(AXIS1, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(AXIS2, MINMAX)) << 1); \ + #define PROCESS_DUAL_ENDSTOP(A, MINMAX) do { \ + const byte dual_hit = TEST_ENDSTOP(_ENDSTOP(A, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(A##2, MINMAX)) << 1); \ if (dual_hit) { \ - _ENDSTOP_HIT(AXIS1, MINMAX); \ + _ENDSTOP_HIT(A, MINMAX); \ /* if not performing home or if both endstops were trigged during homing... */ \ if (!stepper.separate_multi_axis || dual_hit == 0b11) \ - planner.endstop_triggered(_AXIS(AXIS1)); \ + planner.endstop_triggered(_AXIS(A)); \ } \ }while(0) - #define PROCESS_TRIPLE_ENDSTOP(AXIS1, AXIS2, AXIS3, MINMAX) do { \ - const byte triple_hit = TEST_ENDSTOP(_ENDSTOP(AXIS1, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(AXIS2, MINMAX)) << 1) | (TEST_ENDSTOP(_ENDSTOP(AXIS3, MINMAX)) << 2); \ + #define PROCESS_TRIPLE_ENDSTOP(A, MINMAX) do { \ + const byte triple_hit = TEST_ENDSTOP(_ENDSTOP(A, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(A##2, MINMAX)) << 1) | (TEST_ENDSTOP(_ENDSTOP(A##3, MINMAX)) << 2); \ if (triple_hit) { \ - _ENDSTOP_HIT(AXIS1, MINMAX); \ + _ENDSTOP_HIT(A, MINMAX); \ /* if not performing home or if both endstops were trigged during homing... */ \ if (!stepper.separate_multi_axis || triple_hit == 0b111) \ - planner.endstop_triggered(_AXIS(AXIS1)); \ + planner.endstop_triggered(_AXIS(A)); \ } \ }while(0) - #define PROCESS_QUAD_ENDSTOP(AXIS1, AXIS2, AXIS3, AXIS4, MINMAX) do { \ - const byte quad_hit = TEST_ENDSTOP(_ENDSTOP(AXIS1, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(AXIS2, MINMAX)) << 1) | (TEST_ENDSTOP(_ENDSTOP(AXIS3, MINMAX)) << 2) | (TEST_ENDSTOP(_ENDSTOP(AXIS4, MINMAX)) << 3); \ + #define PROCESS_QUAD_ENDSTOP(A, MINMAX) do { \ + const byte quad_hit = TEST_ENDSTOP(_ENDSTOP(A, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(A##2, MINMAX)) << 1) | (TEST_ENDSTOP(_ENDSTOP(A##3, MINMAX)) << 2) | (TEST_ENDSTOP(_ENDSTOP(A##4, MINMAX)) << 3); \ if (quad_hit) { \ - _ENDSTOP_HIT(AXIS1, MINMAX); \ + _ENDSTOP_HIT(A, MINMAX); \ /* if not performing home or if both endstops were trigged during homing... */ \ if (!stepper.separate_multi_axis || quad_hit == 0b1111) \ - planner.endstop_triggered(_AXIS(AXIS1)); \ + planner.endstop_triggered(_AXIS(A)); \ } \ }while(0) + #if ENABLED(X_DUAL_ENDSTOPS) + #define PROCESS_ENDSTOP_X(MINMAX) PROCESS_DUAL_ENDSTOP(X, MINMAX) + #else + #define PROCESS_ENDSTOP_X(MINMAX) if (X_##MINMAX##_TEST()) PROCESS_ENDSTOP(X, MINMAX) + #endif + + #if ENABLED(Y_DUAL_ENDSTOPS) + #define PROCESS_ENDSTOP_Y(MINMAX) PROCESS_DUAL_ENDSTOP(Y, MINMAX) + #else + #define PROCESS_ENDSTOP_Y(MINMAX) PROCESS_ENDSTOP(Y, MINMAX) + #endif + + #if DISABLED(Z_MULTI_ENDSTOPS) + #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_ENDSTOP(Z, MINMAX) + #elif NUM_Z_STEPPER_DRIVERS == 4 + #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_QUAD_ENDSTOP(Z, MINMAX) + #elif NUM_Z_STEPPER_DRIVERS == 3 + #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_TRIPLE_ENDSTOP(Z, MINMAX) + #else + #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX) + #endif + #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ) #if ENABLED(G38_PROBE_AWAY) #define _G38_OPEN_STATE (G38_move >= 4) @@ -747,20 +769,12 @@ void Endstops::update() { if (stepper.axis_is_moving(X_AXIS)) { if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction #if HAS_X_MIN || (X_SPI_SENSORLESS && X_HOME_DIR < 0) - #if ENABLED(X_DUAL_ENDSTOPS) - PROCESS_DUAL_ENDSTOP(X, X2, MIN); - #else - if (X_MIN_TEST) PROCESS_ENDSTOP(X, MIN); - #endif + PROCESS_ENDSTOP_X(MIN); #endif } else { // +direction #if HAS_X_MAX || (X_SPI_SENSORLESS && X_HOME_DIR > 0) - #if ENABLED(X_DUAL_ENDSTOPS) - PROCESS_DUAL_ENDSTOP(X, X2, MAX); - #else - if (X_MAX_TEST) PROCESS_ENDSTOP(X, MAX); - #endif + PROCESS_ENDSTOP_X(MAX); #endif } } @@ -768,44 +782,27 @@ void Endstops::update() { if (stepper.axis_is_moving(Y_AXIS)) { if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction #if HAS_Y_MIN || (Y_SPI_SENSORLESS && Y_HOME_DIR < 0) - #if ENABLED(Y_DUAL_ENDSTOPS) - PROCESS_DUAL_ENDSTOP(Y, Y2, MIN); - #else - PROCESS_ENDSTOP(Y, MIN); - #endif + PROCESS_ENDSTOP_Y(MIN); #endif } else { // +direction #if HAS_Y_MAX || (Y_SPI_SENSORLESS && Y_HOME_DIR > 0) - #if ENABLED(Y_DUAL_ENDSTOPS) - PROCESS_DUAL_ENDSTOP(Y, Y2, MAX); - #else - PROCESS_ENDSTOP(Y, MAX); - #endif + PROCESS_ENDSTOP_Y(MAX); #endif } } if (stepper.axis_is_moving(Z_AXIS)) { if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up. + #if HAS_Z_MIN || (Z_SPI_SENSORLESS && Z_HOME_DIR < 0) - #if ENABLED(Z_MULTI_ENDSTOPS) - #if NUM_Z_STEPPER_DRIVERS == 4 - PROCESS_QUAD_ENDSTOP(Z, Z2, Z3, Z4, MIN); - #elif NUM_Z_STEPPER_DRIVERS == 3 - PROCESS_TRIPLE_ENDSTOP(Z, Z2, Z3, MIN); - #else - PROCESS_DUAL_ENDSTOP(Z, Z2, MIN); - #endif - #else + if (true #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) - if (z_probe_enabled) PROCESS_ENDSTOP(Z, MIN); + && z_probe_enabled #elif HAS_CUSTOM_PROBE_PIN - if (!z_probe_enabled) PROCESS_ENDSTOP(Z, MIN); - #else - PROCESS_ENDSTOP(Z, MIN); + && !z_probe_enabled #endif - #endif + ) PROCESS_ENDSTOP_Z(MIN); #endif // When closing the gap check the enabled probe @@ -816,16 +813,8 @@ void Endstops::update() { else { // Z +direction. Gantry up, bed down. #if HAS_Z_MAX || (Z_SPI_SENSORLESS && Z_HOME_DIR > 0) #if ENABLED(Z_MULTI_ENDSTOPS) - #if NUM_Z_STEPPER_DRIVERS == 4 - PROCESS_QUAD_ENDSTOP(Z, Z2, Z3, Z4, MAX); - #elif NUM_Z_STEPPER_DRIVERS == 3 - PROCESS_TRIPLE_ENDSTOP(Z, Z2, Z3, MAX); - #else - PROCESS_DUAL_ENDSTOP(Z, Z2, MAX); - #endif - #elif !HAS_CUSTOM_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN - // If this pin is not hijacked for the bed probe - // then it belongs to the Z endstop + PROCESS_ENDSTOP_Z(MAX); + #elif !HAS_CUSTOM_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN // No probe or probe is Z_MIN || Probe is not Z_MAX PROCESS_ENDSTOP(Z, MAX); #endif #endif diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index c89c5eb08791..4bb434a922b4 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -459,8 +459,18 @@ bool Probe::set_deployed(const bool deploy) { const char Probe::msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n"; #endif -bool Probe::move_to_z(const float z, const feedRate_t fr_mm_s) { - if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::move_to_z", current_position); +/** + * @brief Move down until the probe triggers or the low limit is reached + * + * @details Used by run_z_probe to get each bed Z height measurement. + * Sets current_position.z to the height where the probe triggered + * (according to the Z stepper count). The float Z is propagated + * back to the planner.position to preempt any rounding error. + * + * @return TRUE if the probe failed to trigger. + */ +bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { + if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::probe_down_to_z", current_position); #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) // Wait for bed to heat back up between probing points @@ -536,7 +546,7 @@ bool Probe::move_to_z(const float z, const feedRate_t fr_mm_s) { // Tell the planner where we actually are sync_plan_position(); - if (DEBUGGING(LEVELING)) DEBUG_POS("<<< Probe::move_to_z", current_position); + if (DEBUGGING(LEVELING)) DEBUG_POS("<<< Probe::probe_down_to_z", current_position); return !probe_triggered; } @@ -561,7 +571,7 @@ float Probe::run_z_probe() { #if TOTAL_PROBING == 2 // Do a first probe at the fast speed - if (move_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) { + if (probe_down_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) { if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM("FAST Probe fail!"); DEBUG_POS("<<< run_z_probe", current_position); @@ -583,7 +593,7 @@ float Probe::run_z_probe() { const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (offset.z < 0 ? -offset.z : 0); if (current_position.z > z) { // Probe down fast. If the probe never triggered, raise for probe clearance - if (!move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) + if (!probe_down_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST)); } #endif @@ -604,7 +614,7 @@ float Probe::run_z_probe() { #endif { // Probe downward slowly to find the bed - if (move_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) { + if (probe_down_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) { if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM("SLOW Probe fail!"); DEBUG_POS("<<< run_z_probe", current_position); diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index d424f4d283a4..b70c01364ab3 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -162,7 +162,7 @@ class Probe { #endif private: - static bool move_to_z(const float z, const feedRate_t fr_mm_s); + static bool probe_down_to_z(const float z, const feedRate_t fr_mm_s); static void do_z_raise(const float z_raise); static float run_z_probe(); }; diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h index 816dbb9dc4dc..15b63494094b 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h @@ -230,4 +230,4 @@ #endif // Include common SKR pins -#include "pins_BTT_SKR.h" +#include "pins_BTT_SKR_common.h" diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h index a3cdf1586cf1..d7af23242723 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -369,4 +369,4 @@ */ // Include common SKR pins -#include "pins_BTT_SKR.h" +#include "pins_BTT_SKR_common.h" diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index 01a8bd7e38eb..2bb57c09fd4e 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -153,7 +153,7 @@ // // Include common SKR pins // -#include "pins_BTT_SKR.h" +#include "pins_BTT_SKR_common.h" // // Software SPI pins for TMC2130 stepper drivers diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h similarity index 100% rename from Marlin/src/pins/lpc1768/pins_BTT_SKR.h rename to Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index def3e2681b1c..35e73e9d3f35 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -528,8 +528,10 @@ #include "stm32/pins_GENERIC_STM32F4.h" // STM32F4 env:STM32F4 #elif MB(ARMED) #include "stm32/pins_ARMED.h" // STM32F4 env:ARMED -#elif MB(RUMBA32) - #include "stm32/pins_RUMBA32.h" // STM32F4 env:rumba32_f446ve env:mks_rumba32 +#elif MB(RUMBA32_AUS3D) + #include "stm32/pins_RUMBA32_AUS3D.h" // STM32F4 env:rumba32_f446ve +#elif MB(RUMBA32_MKS) + #include "stm32/pins_RUMBA32_MKS.h" // STM32F4 env:rumba32_mks #elif MB(BLACK_STM32F407VE) #include "stm32/pins_BLACK_STM32F407VE.h" // STM32F4 env:STM32F407VE_black #elif MB(STEVAL_3DP001V1) @@ -607,6 +609,7 @@ #define BOARD_BIGTREE_SKR_MINI_V1_1 -1015 #define BOARD_BIGTREE_SKR_MINI_E3 -1016 #define BOARD_BIGTREE_SKR_E3_DIP -1017 + #define BOARD_RUMBA32 -1018 #if MB(MKS_13) #error "BOARD_MKS_13 has been renamed BOARD_MKS_GEN_13. Please update your configuration." @@ -646,6 +649,8 @@ #error "BOARD_ESP32 has been renamed BOARD_ESPRESSIF_ESP32. Please update your configuration." #elif MB(STEVAL) #error "BOARD_STEVAL has been renamed BOARD_STEVAL_3DP001V1. Please update your configuration." + #elif MB(RUMBA32) + #error "BOARD_RUMBA32 is now BOARD_RUMBA32_MKS or BOARD_RUMBA32_AUS3D. Please update your configuration." #else #error "Unknown MOTHERBOARD value set in Configuration.h" #endif @@ -668,6 +673,7 @@ #undef BOARD_BIGTREE_SKR_PRO_V1_1 #undef BOARD_BIGTREE_SKR_MINI_V1_1 #undef BOARD_BIGTREE_SKR_E3_DIP + #undef BOARD_RUMBA32 #endif diff --git a/Marlin/src/pins/stm32/pins_RUMBA32_AUS3D.h b/Marlin/src/pins/stm32/pins_RUMBA32_AUS3D.h new file mode 100644 index 000000000000..cff34a2d860b --- /dev/null +++ b/Marlin/src/pins/stm32/pins_RUMBA32_AUS3D.h @@ -0,0 +1,42 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +/** + * Pin assignments for the MKS RUMBA32 + * + * https://aus3d.com.au/rumba32 + * https://github.com/Aus3D/RUMBA32 + * + * The MKS and Aus3D versions have the same pinout but the MKS version + * has some added resistors and LEDs. The resistors needed for the + * TMC2208/9 UART interface are among the additions. Also added were + * connectors and resistors dedicated to the TMC2130 sensorless homing + * interface. + */ + +#define BOARD_INFO_NAME "Aus3D RUMBA32" + +#define RUMBA32_V1_0 +//#define I2C_EEPROM + +#include "pins_RUMBA32_common.h" diff --git a/Marlin/src/pins/stm32/pins_RUMBA32_MKS.h b/Marlin/src/pins/stm32/pins_RUMBA32_MKS.h new file mode 100644 index 000000000000..8e2bb3b8afbd --- /dev/null +++ b/Marlin/src/pins/stm32/pins_RUMBA32_MKS.h @@ -0,0 +1,109 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +/** + * Pin assignments for the MKS RUMBA32 + * + * https://github.com/makerbase-mks/MKS-RUMBA32 + * + * The MKS and Aus3D versions have the same pinout but the MKS version + * has some added resistors and LEDs. The resistors needed for the + * TMC2208/9 UART interface are among the additions. Also added were + * connectors and resistors dedicated to the TMC2130 sensorless homing + * interface. + */ + +#define BOARD_INFO_NAME "MKS RUMBA32" + +#define RUMBA32_V1_0 +#define ENABLE_SPI1 +//#define I2C_EEPROM + +#include "pins_RUMBA32_common.h" + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PA7 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PA6 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PA5 + #endif +#endif + +#if HAS_TMC220x + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + // + // Software serial + // + #define X_SERIAL_TX_PIN PA3 + #define X_SERIAL_RX_PIN PC14 + + #define Y_SERIAL_TX_PIN PA4 + #define Y_SERIAL_RX_PIN PE4 + + #define Z_SERIAL_TX_PIN PD13 + #define Z_SERIAL_RX_PIN PE0 + + #define E0_SERIAL_TX_PIN PD14 + #define E0_SERIAL_RX_PIN PC13 + + #define E1_SERIAL_TX_PIN PD15 + #define E1_SERIAL_RX_PIN PD5 + + #define E2_SERIAL_TX_PIN PD12 + #define E2_SERIAL_RX_PIN PD1 +#endif + +// +// LCD / Controller +// + +// Alter timing for graphical display +#if HAS_GRAPHICAL_LCD + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #define BOARD_ST7920_DELAY_3 DELAY_NS(600) +#endif diff --git a/Marlin/src/pins/stm32/pins_RUMBA32.h b/Marlin/src/pins/stm32/pins_RUMBA32_common.h similarity index 82% rename from Marlin/src/pins/stm32/pins_RUMBA32.h rename to Marlin/src/pins/stm32/pins_RUMBA32_common.h index dcdbd1b40a4b..0fb469112d41 100644 --- a/Marlin/src/pins/stm32/pins_RUMBA32.h +++ b/Marlin/src/pins/stm32/pins_RUMBA32_common.h @@ -21,17 +21,23 @@ */ #pragma once +/** + * Common pin assignments for all RUMBA32 boards + */ + #ifndef STM32F4 #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 3 || E_STEPPERS > 3 - #error "RUMBA32 supports up to 3 hotends / E-steppers." + #error "RUMBA32 boards support up to 3 hotends / E-steppers." #endif #define RUMBA32_V1_0 -#define BOARD_INFO_NAME "RUMBA32" #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME //#define I2C_EEPROM +#ifdef E2END + #undef E2END +#endif #define E2END 0xFFF // 4KB // @@ -119,12 +125,25 @@ // // LCD / Controller // -#define LCD_PINS_RS PE10 -#define LCD_PINS_ENABLE PE9 -#define LCD_PINS_D4 PE12 -#define LCD_PINS_D5 PE13 -#define LCD_PINS_D6 PE14 -#define LCD_PINS_D7 PE15 -#define BTN_EN1 PB1 -#define BTN_EN2 PB2 -#define BTN_ENC PE7 +#if HAS_SPI_LCD + + #define BTN_EN1 PB2 + #define BTN_EN2 PB1 + #define BTN_ENC PE7 + + #define LCD_PINS_RS PE10 + #define LCD_PINS_ENABLE PE9 + #define LCD_PINS_D4 PE12 + + #if ENABLED(MKS_MINI_12864) + #define DOGLCD_CS PE13 + #define DOGLCD_A0 PE14 + #endif + + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 PE13 + #define LCD_PINS_D6 PE14 + #define LCD_PINS_D7 PE15 + #endif + +#endif diff --git a/platformio.ini b/platformio.ini index f716db296771..6b4f171f7d3e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -822,9 +822,9 @@ monitor_speed = 500000 upload_protocol = dfu # -# MKS RUMBA32(add TMC2208/2209 UART interface and AUX-1) +# MKS RUMBA32 (adds TMC2208/2209 UART interface and AUX-1) # -[env:mks_rumba32] +[env:rumba32_mks] platform = ststm32 board = rumba32_f446ve build_flags = ${common.build_flags}