Commit f8279b07 authored by MagoKimbra's avatar MagoKimbra

Same fix

parent 5ad5ba2f
...@@ -4,70 +4,71 @@ ...@@ -4,70 +4,71 @@
// Macros for board type // Macros for board type
#define BOARD_UNKNOWN -1 #define BOARD_UNKNOWN -1
#define BOARD_GEN7_CUSTOM 10 // Gen7 custom (Alfons3 Version) "https://github.com/Alfons3/Generation_7_Electronics" #define BOARD_GEN7_CUSTOM 10 // Gen7 custom (Alfons3 Version) "https://github.com/Alfons3/Generation_7_Electronics"
#define BOARD_GEN7_12 11 // Gen7 v1.1, v1.2 #define BOARD_GEN7_12 11 // Gen7 v1.1, v1.2
#define BOARD_GEN7_13 12 // Gen7 v1.3 #define BOARD_GEN7_13 12 // Gen7 v1.3
#define BOARD_GEN7_14 13 // Gen7 v1.4 #define BOARD_GEN7_14 13 // Gen7 v1.4
#define BOARD_CHEAPTRONIC 2 // Cheaptronic v1.0 #define BOARD_CHEAPTRONIC 2 // Cheaptronic v1.0
#define BOARD_SETHI 20 // Sethi 3D_1 #define BOARD_SETHI 20 // Sethi 3D_1
#define BOARD_ELEFU_3 21 // Elefu Ra Board (v3) #define BOARD_ELEFU_3 21 // Elefu Ra Board (v3)
#define BOARD_GEN3_MONOLITHIC 22 // Gen3 Monolithic Electronics #define BOARD_GEN3_MONOLITHIC 22 // Gen3 Monolithic Electronics
#define BOARD_RAMPS_OLD 3 // MEGA/RAMPS up to 1.2 #define BOARD_RAMPS_OLD 3 // MEGA/RAMPS up to 1.2
#define BOARD_RAMPS_13_HFB 33 // RAMPS 1.3 / 1.4 (Power outputs: Hotend, Fan, Bed) #define BOARD_RAMPS_13_HFB 33 // RAMPS 1.3 / 1.4 (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_13_HHB 34 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Bed) #define BOARD_RAMPS_13_HHB 34 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_13_HFF 35 // RAMPS 1.3 / 1.4 (Power outputs: Hotend, Fan, Fan) #define BOARD_RAMPS_13_HFF 35 // RAMPS 1.3 / 1.4 (Power outputs: Hotend, Fan, Fan)
#define BOARD_RAMPS_13_HHF 36 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Fan) #define BOARD_RAMPS_13_HHF 36 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_13_HHH 37 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Hotend2) #define BOARD_RAMPS_13_HHH 37 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Hotend2)
#define BOARD_RAMBO 301 // Rambo #define BOARD_RAMBO 301 // Rambo
#define BOARD_MINIRAMBO 302 // Mini-Rambo #define BOARD_MINIRAMBO 302 // Mini-Rambo
#define BOARD_DUEMILANOVE_328P 4 // Duemilanove w/ ATMega328P pin assignments #define BOARD_DUEMILANOVE_328P 4 // Duemilanove w/ ATMega328P pin assignments
#define BOARD_MKS_BASE 40 // MKS BASE 1.0 #define BOARD_MKS_BASE 40 // MKS BASE 1.0
#define BOARD_RADDS 402 // RADDS ARM 32 #define BOARD_RADDS 402 // RADDS ARM 32
#define BOARD_RAMPS_FD_V1 403 // RAMPS-FD V1 #define BOARD_RAMPS_FD_V1 403 // RAMPS-FD V1 ARM 32
#define BOARD_RAMPS_FD_V2 404 // RAMPS-FD V2 #define BOARD_RAMPS_FD_V2 404 // RAMPS-FD V2 ARM 32
#define BOARD_SMART_RAMPS 408 // SMART RAMPS #define BOARD_SMART_RAMPS 408 // SMART RAMPS ARM 32
#define BOARD_RAMPS4DUE 433 // RAMPS4DUE with AndrewBCN's RAMPS mods (http://forums.reprap.org/read.php?219,479626,page=1) ARM 32 #define BOARD_RAMPS4DUE 433 // RAMPS4DUE with AndrewBCN's RAMPS mods (http://forums.reprap.org/read.php?219,479626,page=1) ARM 32
#define BOARD_GEN6 5 // Gen6 #define BOARD_GEN6 5 // Gen6
#define BOARD_GEN6_DELUXE 51 // Gen6 deluxe #define BOARD_GEN6_DELUXE 51 // Gen6 deluxe
#define BOARD_ALLIGATOR 502 // ALLIGATOR R2 ARM 32 #define BOARD_ALLIGATOR 502 // ALLIGATOR R2 ARM 32
#define BOARD_SANGUINOLOLU_11 6 // Sanguinololu < 1.2 #define BOARD_SANGUINOLOLU_11 6 // Sanguinololu < 1.2
#define BOARD_SANGUINOLOLU_12 62 // Sanguinololu 1.2 and above #define BOARD_SANGUINOLOLU_12 62 // Sanguinololu 1.2 and above
#define BOARD_MELZI 63 // Melzi #define BOARD_MELZI 63 // Melzi
#define BOARD_STB_11 64 // STB V1.1 #define BOARD_STB_11 64 // STB V1.1
#define BOARD_AZTEEG_X1 65 // Azteeg X1 #define BOARD_AZTEEG_X1 65 // Azteeg X1
#define BOARD_MELZI_MAKR3D 66 // Melzi with ATmega1284 (MaKr3d version) #define BOARD_MELZI_MAKR3D 66 // Melzi with ATmega1284 (MaKr3d version)
#define BOARD_AZTEEG_X3 67 // Azteeg X3 #define BOARD_AZTEEG_X3 67 // Azteeg X3
#define BOARD_AZTEEG_X3_PRO 68 // Azteeg X3 Pro #define BOARD_AZTEEG_X3_PRO 68 // Azteeg X3 Pro
#define BOARD_ULTIMAKER 7 // Ultimaker #define BOARD_ULTIMAKER 7 // Ultimaker
#define BOARD_MEGATRONICS 70 // Megatronics #define BOARD_MEGATRONICS 70 // Megatronics
#define BOARD_MEGATRONICS_2 701 // Megatronics v2.0 #define BOARD_MEGATRONICS_2 701 // Megatronics v2.0
#define BOARD_MINITRONICS 702 // Minitronics v1.0 #define BOARD_MINITRONICS 702 // Minitronics v1.0
#define BOARD_MEGATRONICS_3 703 // Megatronics v3.0 #define BOARD_MEGATRONICS_3 703 // Megatronics v3.0
#define BOARD_ULTIMAKER_OLD 71 // Ultimaker (Older electronics. Pre 1.5.4. This is rare) #define BOARD_ULTRATRONICS 705 // Ultratronics v1.0 ARM 32
#define BOARD_ULTIMAIN_2 72 // Ultimainboard 2.x (Uses TEMP_SENSOR 20) #define BOARD_ULTIMAKER_OLD 71 // Ultimaker (Older electronics. Pre 1.5.4. This is rare)
#define BOARD_3DRAG 77 // 3Drag Controller #define BOARD_ULTIMAIN_2 72 // Ultimainboard 2.x (Uses TEMP_SENSOR 20)
#define BOARD_K8200 78 // Vellemann K8200 Controller (derived from 3Drag Controller) #define BOARD_3DRAG 77 // 3Drag Controller
#define BOARD_K8200 78 // Vellemann K8200 Controller (derived from 3Drag Controller)
#define BOARD_TEENSYLU 8 // Teensylu #define BOARD_TEENSYLU 8 // Teensylu
#define BOARD_RUMBA 80 // Rumba #define BOARD_RUMBA 80 // Rumba
#define BOARD_PRINTRBOARD 81 // Printrboard (AT90USB1286) #define BOARD_PRINTRBOARD 81 // Printrboard (AT90USB1286)
#define BOARD_BRAINWAVE 82 // Brainwave (AT90USB646) #define BOARD_BRAINWAVE 82 // Brainwave (AT90USB646)
#define BOARD_SAV_MKI 83 // SAV Mk-I (AT90USB1286) #define BOARD_SAV_MKI 83 // SAV Mk-I (AT90USB1286)
#define BOARD_TEENSY2 84 // Teensy++2.0 (AT90USB1286) #define BOARD_TEENSY2 84 // Teensy++2.0 (AT90USB1286)
#define BOARD_5DPRINT 88 // 5DPrint D8 Driver Board #define BOARD_5DPRINT 88 // 5DPrint D8 Driver Board
#define BOARD_GEN3_PLUS 9 // Gen3+ #define BOARD_GEN3_PLUS 9 // Gen3+
#define BOARD_OMCA_A 90 // Alpha OMCA board #define BOARD_OMCA_A 90 // Alpha OMCA board
#define BOARD_OMCA 91 // Final OMCA board #define BOARD_OMCA 91 // Final OMCA board
#define BOARD_LEAPFROG 999 // Leapfrog #define BOARD_LEAPFROG 999 // Leapfrog
#define BOARD_99 99 // This is in pins.h but...? #define BOARD_99 99 // This is in pins.h but...?
#define MB(board) (MOTHERBOARD==BOARD_##board) #define MB(board) (MOTHERBOARD==BOARD_##board)
......
...@@ -149,6 +149,8 @@ ...@@ -149,6 +149,8 @@
#define INVERT_E1_DIR false #define INVERT_E1_DIR false
#define INVERT_E2_DIR false #define INVERT_E2_DIR false
#define INVERT_E3_DIR false #define INVERT_E3_DIR false
#define INVERT_E4_DIR false
#define INVERT_E5_DIR false
/*****************************************************************************************/ /*****************************************************************************************/
......
...@@ -171,6 +171,8 @@ ...@@ -171,6 +171,8 @@
#define INVERT_E1_DIR false #define INVERT_E1_DIR false
#define INVERT_E2_DIR false #define INVERT_E2_DIR false
#define INVERT_E3_DIR false #define INVERT_E3_DIR false
#define INVERT_E4_DIR false
#define INVERT_E5_DIR false
/*****************************************************************************************/ /*****************************************************************************************/
......
...@@ -240,6 +240,8 @@ ...@@ -240,6 +240,8 @@
#define INVERT_E1_DIR false #define INVERT_E1_DIR false
#define INVERT_E2_DIR false #define INVERT_E2_DIR false
#define INVERT_E3_DIR false #define INVERT_E3_DIR false
#define INVERT_E4_DIR false
#define INVERT_E5_DIR false
/*****************************************************************************************/ /*****************************************************************************************/
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* - Dangerous extrution prevention * - Dangerous extrution prevention
* - Single nozzle * - Single nozzle
* - BariCUDA paste extruder * - BariCUDA paste extruder
* - Color Mixing Extruder
* - Multiextruder MKR4 * - Multiextruder MKR4
* - Multiextruder NPr2 * - Multiextruder NPr2
* - Multiextruder DONDOLO * - Multiextruder DONDOLO
...@@ -49,7 +50,6 @@ ...@@ -49,7 +50,6 @@
* - Filament diameter sensor * - Filament diameter sensor
* - Filament Runout sensor * - Filament Runout sensor
* - Power consumption sensor * - Power consumption sensor
* - RFID card sensor
* ADDON FEATURES: * ADDON FEATURES:
* - EEPROM * - EEPROM
* - SDCARD * - SDCARD
...@@ -388,6 +388,7 @@ ...@@ -388,6 +388,7 @@
//#define SINGLENOZZLE //#define SINGLENOZZLE
/***********************************************************************/ /***********************************************************************/
/*********************************************************************** /***********************************************************************
*********************** BariCUDA paste extruder *********************** *********************** BariCUDA paste extruder ***********************
*********************************************************************** ***********************************************************************
...@@ -399,6 +400,20 @@ ...@@ -399,6 +400,20 @@
/***********************************************************************/ /***********************************************************************/
/***********************************************************************
********************** COLOR MIXING EXTRUDER **************************
***********************************************************************
* *
* Extends G0/G1 with mixing factors ABCDHI for up to 6 steppers. *
* Adds a new code, M223, to set the current mix factors. *
* Extends the stepping routines to move multiple steppers in *
* proportion to the mix. *
* *
***********************************************************************/
//#define COLOR_MIXING_EXTRUDER
/***********************************************************************/
/*********************************************************************** /***********************************************************************
************************* Multiextruder MKR4 ************************** ************************* Multiextruder MKR4 **************************
*********************************************************************** ***********************************************************************
......
...@@ -43,6 +43,18 @@ ...@@ -43,6 +43,18 @@
#define E3_ENABLE_PIN ORIG_E3_ENABLE_PIN #define E3_ENABLE_PIN ORIG_E3_ENABLE_PIN
#endif #endif
#if DRIVER_EXTRUDERS > 4
#define E4_STEP_PIN ORIG_E4_STEP_PIN
#define E4_DIR_PIN ORIG_E4_DIR_PIN
#define E4_ENABLE_PIN ORIG_E4_ENABLE_PIN
#endif
#if DRIVER_EXTRUDERS > 5
#define E5_STEP_PIN ORIG_E5_STEP_PIN
#define E5_DIR_PIN ORIG_E5_DIR_PIN
#define E5_ENABLE_PIN ORIG_E5_ENABLE_PIN
#endif
// ENDSTOP pin // ENDSTOP pin
#define X_MIN_PIN ORIG_X_MIN_PIN #define X_MIN_PIN ORIG_X_MIN_PIN
#define X_MAX_PIN ORIG_X_MAX_PIN #define X_MAX_PIN ORIG_X_MAX_PIN
......
...@@ -170,6 +170,8 @@ ...@@ -170,6 +170,8 @@
#define INVERT_E1_DIR false #define INVERT_E1_DIR false
#define INVERT_E2_DIR false #define INVERT_E2_DIR false
#define INVERT_E3_DIR false #define INVERT_E3_DIR false
#define INVERT_E4_DIR false
#define INVERT_E5_DIR false
/*****************************************************************************************/ /*****************************************************************************************/
......
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
* M220 - Set speed factor override percentage: S<factor in percent> * M220 - Set speed factor override percentage: S<factor in percent>
* M221 - Set extrude factor override percentage: S<factor in percent> * M221 - Set extrude factor override percentage: S<factor in percent>
* M222 - Set density extrusion percentage for purge: S<factor in percent> * M222 - Set density extrusion percentage for purge: S<factor in percent>
* M223 - Set the mix factors for a mixing extruder: <ABCDHI>
* M226 - Wait until the specified pin reaches the state required: P<pin number> S<pin state> * M226 - Wait until the specified pin reaches the state required: P<pin number> S<pin state>
* M240 - Trigger a camera to take a photograph * M240 - Trigger a camera to take a photograph
* M250 - Set LCD contrast C<contrast value> (value 0..63) * M250 - Set LCD contrast C<contrast value> (value 0..63)
......
This diff is collapsed.
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include "module/temperature/temperature.h" #include "module/temperature/temperature.h"
#include "module/temperature/thermistortables.h" #include "module/temperature/thermistortables.h"
#include "module/lcd/ultralcd.h" #include "module/lcd/ultralcd.h"
#include "module/nextion/nextion_lcd.h" #include "module/nextion/Nextion_lcd.h"
#include "module/sd/cardreader.h" #include "module/sd/cardreader.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if ENABLED(AUTO_BED_LEVELING_FEATURE)
......
...@@ -233,6 +233,10 @@ double printer_usage_filament; ...@@ -233,6 +233,10 @@ double printer_usage_filament;
static bool filrunoutEnqueued = false; static bool filrunoutEnqueued = false;
#endif #endif
#if ENABLED(COLOR_MIXING_EXTRUDER)
float mixing_factor[DRIVER_EXTRUDERS] = { 1.0 / DRIVER_EXTRUDERS };
#endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
static bool fromsd[BUFSIZE]; static bool fromsd[BUFSIZE];
#if ENABLED(SD_SETTINGS) #if ENABLED(SD_SETTINGS)
...@@ -2506,6 +2510,29 @@ static void clean_up_after_endstop_move() { ...@@ -2506,6 +2510,29 @@ static void clean_up_after_endstop_move() {
#endif //DELTA #endif //DELTA
#if ENABLED(COLOR_MIXING_EXTRUDER)
// Get mixing parameters from the GCode
// Factors that are left out are set to 0
// The total "must" be 1.0 (but it will be normalized)
void gcode_get_mix() {
const char* mixing_codes = "ABCDHI";
float mix_total = 0.0;
for (int8_t e = 0; e < DRIVER_EXTRUDERS; e++) {
float v = code_seen(mixing_codes[e]) ? code_value() : 0;
mixing_factor[e] = v;
mix_total += v;
}
// Scale values if they don't add up to ~1.0
if (mix_total < 0.9999 || mix_total > 1.0001) {
ECHO_EM("Warning: Mix factors must add up to 1.0. Scaling.");
float mix_scale = 1.0 / mix_total;
for (int8_t e = 0; e < DRIVER_EXTRUDERS; e++)
mixing_factor[e] *= mix_scale;
}
}
#endif
#if ENABLED(IDLE_OOZING_PREVENT) #if ENABLED(IDLE_OOZING_PREVENT)
void IDLE_OOZING_retract(bool retracting) { void IDLE_OOZING_retract(bool retracting) {
if (retracting && !IDLE_OOZING_retracted[active_extruder]) { if (retracting && !IDLE_OOZING_retracted[active_extruder]) {
...@@ -2792,6 +2819,11 @@ void gcode_get_destination() { ...@@ -2792,6 +2819,11 @@ void gcode_get_destination() {
destination[E_AXIS] = (code_value() * density_multiplier[previous_extruder] / 100) + current_position[E_AXIS]; destination[E_AXIS] = (code_value() * density_multiplier[previous_extruder] / 100) + current_position[E_AXIS];
} }
// Get ABCDHI mixing factors
#if ENABLED(COLOR_MIXING_EXTRUDER)
gcode_get_mix();
#endif
printer_usage_filament += (destination[E_AXIS] - current_position[E_AXIS]); printer_usage_filament += (destination[E_AXIS] - current_position[E_AXIS]);
#if ENABLED(NEXTION) && ENABLED(NEXTION_GFX) #if ENABLED(NEXTION) && ENABLED(NEXTION_GFX)
...@@ -3127,7 +3159,7 @@ inline void gcode_G28() { ...@@ -3127,7 +3159,7 @@ inline void gcode_G28() {
refresh_cmd_timeout(); refresh_cmd_timeout();
enable_endstops(true); enable_endstops(true);
for(int8_t i=0; i < NUM_AXIS; i++) { for(int8_t i = 0; i < NUM_AXIS; i++) {
destination[i] = current_position[i]; destination[i] = current_position[i];
} }
feedrate = 0.0; feedrate = 0.0;
...@@ -5586,6 +5618,23 @@ inline void gcode_M222() { ...@@ -5586,6 +5618,23 @@ inline void gcode_M222() {
if (code_seen('S')) density_multiplier[target_extruder] = code_value(); if (code_seen('S')) density_multiplier[target_extruder] = code_value();
} }
#if ENABLED(COLOR_MIXING_EXTRUDER)
/**
* M223: Set the mix factors for a mixing extruder.
* Factors that are left out will be set to 0.
* All factors together must add up to 1.0.
*
* A[factor] Mix factor for extruder stepper 1
* B[factor] Mix factor for extruder stepper 2
* C[factor] Mix factor for extruder stepper 3
* D[factor] Mix factor for extruder stepper 4
* H[factor] Mix factor for extruder stepper 5
* I[factor] Mix factor for extruder stepper 6
*
*/
inline void gcode_M223() { gcode_get_mix(); }
#endif
/** /**
* M226: Wait until the specified pin reaches the state required (M226 P<pin> S<state>) * M226: Wait until the specified pin reaches the state required (M226 P<pin> S<state>)
*/ */
...@@ -7146,6 +7195,12 @@ void process_next_command() { ...@@ -7146,6 +7195,12 @@ void process_next_command() {
gcode_M221(); break; gcode_M221(); break;
case 222: // M222 T<extruder> S<factor in percent> - set density extrude factor percentage for purge case 222: // M222 T<extruder> S<factor in percent> - set density extrude factor percentage for purge
gcode_M222(); break; gcode_M222(); break;
#if ENABLED(COLOR_MIXING_EXTRUDER)
case 223: // M223 Set the mix factors for a mixing extruder
gcode_M223; break;
#endif
case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
gcode_M226(); break; gcode_M226(); break;
......
...@@ -230,6 +230,10 @@ extern uint8_t active_driver; ...@@ -230,6 +230,10 @@ extern uint8_t active_driver;
void FirmwareTest(); void FirmwareTest();
#endif #endif
#if ENABLED(COLOR_MIXING_EXTRUDER)
extern float mixing_factor[DRIVER_EXTRUDERS];
#endif
extern void calculate_volumetric_multipliers(); extern void calculate_volumetric_multipliers();
#if ENABLED(M100_FREE_MEMORY_WATCHER) #if ENABLED(M100_FREE_MEMORY_WATCHER)
......
...@@ -651,6 +651,8 @@ ...@@ -651,6 +651,8 @@
#define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE)) #define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE))
#define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE)) #define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE))
#define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE)) #define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE))
#define HAS_E4_ENABLE (PIN_EXISTS(E4_ENABLE))
#define HAS_E5_ENABLE (PIN_EXISTS(E5_ENABLE))
#define HAS_X_DIR (PIN_EXISTS(X_DIR)) #define HAS_X_DIR (PIN_EXISTS(X_DIR))
#define HAS_X2_DIR (PIN_EXISTS(X2_DIR)) #define HAS_X2_DIR (PIN_EXISTS(X2_DIR))
#define HAS_Y_DIR (PIN_EXISTS(Y_DIR)) #define HAS_Y_DIR (PIN_EXISTS(Y_DIR))
...@@ -661,6 +663,8 @@ ...@@ -661,6 +663,8 @@
#define HAS_E1_DIR (PIN_EXISTS(E1_DIR)) #define HAS_E1_DIR (PIN_EXISTS(E1_DIR))
#define HAS_E2_DIR (PIN_EXISTS(E2_DIR)) #define HAS_E2_DIR (PIN_EXISTS(E2_DIR))
#define HAS_E3_DIR (PIN_EXISTS(E3_DIR)) #define HAS_E3_DIR (PIN_EXISTS(E3_DIR))
#define HAS_E4_DIR (PIN_EXISTS(E4_DIR))
#define HAS_E5_DIR (PIN_EXISTS(E5_DIR))
#define HAS_X_STEP (PIN_EXISTS(X_STEP)) #define HAS_X_STEP (PIN_EXISTS(X_STEP))
#define HAS_X2_STEP (PIN_EXISTS(X2_STEP)) #define HAS_X2_STEP (PIN_EXISTS(X2_STEP))
#define HAS_Y_STEP (PIN_EXISTS(Y_STEP)) #define HAS_Y_STEP (PIN_EXISTS(Y_STEP))
...@@ -671,9 +675,13 @@ ...@@ -671,9 +675,13 @@
#define HAS_E1_STEP (PIN_EXISTS(E1_STEP)) #define HAS_E1_STEP (PIN_EXISTS(E1_STEP))
#define HAS_E2_STEP (PIN_EXISTS(E2_STEP)) #define HAS_E2_STEP (PIN_EXISTS(E2_STEP))
#define HAS_E3_STEP (PIN_EXISTS(E3_STEP)) #define HAS_E3_STEP (PIN_EXISTS(E3_STEP))
#define HAS_E4_STEP (PIN_EXISTS(E4_STEP))
#define HAS_E5_STEP (PIN_EXISTS(E5_STEP))
#define HAS_E0E1 (PIN_EXISTS(E0E1_CHOICE)) #define HAS_E0E1 (PIN_EXISTS(E0E1_CHOICE))
#define HAS_E0E2 (PIN_EXISTS(E0E2_CHOICE)) #define HAS_E0E2 (PIN_EXISTS(E0E2_CHOICE))
#define HAS_E0E3 (PIN_EXISTS(E0E3_CHOICE)) #define HAS_E0E3 (PIN_EXISTS(E0E3_CHOICE))
#define HAS_E0E4 (PIN_EXISTS(E0E4_CHOICE))
#define HAS_E0E5 (PIN_EXISTS(E0E5_CHOICE))
#define HAS_E1E3 (PIN_EXISTS(E1E3_CHOICE)) #define HAS_E1E3 (PIN_EXISTS(E1E3_CHOICE))
#define HAS_BTN_BACK (PIN_EXISTS(BTN_BACK)) #define HAS_BTN_BACK (PIN_EXISTS(BTN_BACK))
#define HAS_POWER_SWITCH (POWER_SUPPLY > 0 && PIN_EXISTS(PS_ON)) #define HAS_POWER_SWITCH (POWER_SUPPLY > 0 && PIN_EXISTS(PS_ON))
......
...@@ -100,6 +100,9 @@ ...@@ -100,6 +100,9 @@
#define SERIAL_ACTIVE_DRIVER "Active Driver: " #define SERIAL_ACTIVE_DRIVER "Active Driver: "
#define SERIAL_ACTIVE_EXTRUDER "Active Extruder: " #define SERIAL_ACTIVE_EXTRUDER "Active Extruder: "
#define SERIAL_ACTIVE_COLOR "Active Color: " #define SERIAL_ACTIVE_COLOR "Active Color: "
#define MSG_COUNT_X " Count X:"
#define MSG_COUNT_A " Count A:"
#define MSG_COUNT_ALPHA " Count Alpha: "
#define SERIAL_X_MIN "x_min: " #define SERIAL_X_MIN "x_min: "
#define SERIAL_X_MAX "x_max: " #define SERIAL_X_MAX "x_max: "
#define SERIAL_Y_MIN "y_min: " #define SERIAL_Y_MIN "y_min: "
...@@ -117,6 +120,8 @@ ...@@ -117,6 +120,8 @@
#define SERIAL_HOTEND_OFFSET "Hotend offsets:" #define SERIAL_HOTEND_OFFSET "Hotend offsets:"
#define SERIAL_EMPTY_PLANE "Autolevel can only be execute on an actual plane, make sure width and height are not 0!" #define SERIAL_EMPTY_PLANE "Autolevel can only be execute on an actual plane, make sure width and height are not 0!"
#define SERIAL_FILRUNOUT_PIN "filament_runout_pin: " #define SERIAL_FILRUNOUT_PIN "filament_runout_pin: "
// SD Card
#define SERIAL_SD_ERRORCODE "SD errorCode:" #define SERIAL_SD_ERRORCODE "SD errorCode:"
#define SERIAL_SD_CANT_OPEN_SUBDIR "Cannot open subdir" #define SERIAL_SD_CANT_OPEN_SUBDIR "Cannot open subdir"
#define SERIAL_SD_INIT_FAIL "SD init fail" #define SERIAL_SD_INIT_FAIL "SD init fail"
......
...@@ -598,11 +598,18 @@ float junction_deviation = 0.1; ...@@ -598,11 +598,18 @@ float junction_deviation = 0.1;
if (block->step_event_count <= DROP_SEGMENTS) return; if (block->step_event_count <= DROP_SEGMENTS) return;
block->fan_speed = fanSpeed; block->fan_speed = fanSpeed;
#if ENABLED(BARICUDA) #if ENABLED(BARICUDA)
block->valve_pressure = ValvePressure; block->valve_pressure = ValvePressure;
block->e_to_p_pressure = EtoPPressure; block->e_to_p_pressure = EtoPPressure;
#endif #endif
// For a mixing extruder, get steps for each
#if ENABLED(COLOR_MIXING_EXTRUDER)
for (int8_t e = 0; e < DRIVER_EXTRUDERS; e++)
block->mix_steps[e] = block->steps[E_AXIS] * mixing_factor[e];
#endif
// Add update block variables for LASER BEAM control // Add update block variables for LASER BEAM control
#if ENABLED(LASERBEAM) #if ENABLED(LASERBEAM)
block->laser_ttlmodulation = laser_ttl_modulation; block->laser_ttlmodulation = laser_ttl_modulation;
......
...@@ -29,12 +29,18 @@ ...@@ -29,12 +29,18 @@
typedef struct { typedef struct {
// Fields used by the bresenham algorithm for tracing the line // Fields used by the bresenham algorithm for tracing the line
long steps[NUM_AXIS]; // Step count along each axis long steps[NUM_AXIS]; // Step count along each axis
#if ENABLED(COLOR_MIXING_EXTRUDER)
float mix_steps[DRIVER_EXTRUDERS]; // Step count for each stepper in a mixing extruder
#endif
unsigned long step_event_count; // The number of step events required to complete this block unsigned long step_event_count; // The number of step events required to complete this block
long accelerate_until; // The index of the step event on which to stop acceleration long accelerate_until; // The index of the step event on which to stop acceleration
long decelerate_after; // The index of the step event on which to start decelerating long decelerate_after; // The index of the step event on which to start decelerating
long acceleration_rate; // The acceleration rate used for acceleration calculation long acceleration_rate; // The acceleration rate used for acceleration calculation
unsigned char direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h) unsigned char direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
unsigned char active_driver; // Selects the active driver unsigned char active_driver; // Selects the active driver
#if ENABLED(ADVANCE) #if ENABLED(ADVANCE)
long advance_rate; long advance_rate;
volatile long initial_advance; volatile long initial_advance;
...@@ -58,13 +64,16 @@ typedef struct { ...@@ -58,13 +64,16 @@ typedef struct {
unsigned long final_rate; // The minimal rate at exit unsigned long final_rate; // The minimal rate at exit
unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long acceleration_st; // acceleration steps/sec^2
unsigned long fan_speed; unsigned long fan_speed;
#if ENABLED(BARICUDA) #if ENABLED(BARICUDA)
unsigned long valve_pressure; unsigned long valve_pressure;
unsigned long e_to_p_pressure; unsigned long e_to_p_pressure;
#endif #endif
#if ENABLED(LASERBEAM) #if ENABLED(LASERBEAM)
unsigned long laser_ttlmodulation; unsigned long laser_ttlmodulation;
#endif #endif
volatile char busy; volatile char busy;
} block_t; } block_t;
......
...@@ -58,11 +58,11 @@ volatile static unsigned long step_events_completed; // The number of step event ...@@ -58,11 +58,11 @@ volatile static unsigned long step_events_completed; // The number of step event
#if ENABLED(ADVANCE) #if ENABLED(ADVANCE)
static long advance_rate, advance, final_advance = 0; static long advance_rate, advance, final_advance = 0;
static long old_advance = 0; static long old_advance = 0;
static long e_steps[4]; static long e_steps[6];
#endif #endif
static long acceleration_time, deceleration_time; static long acceleration_time, deceleration_time;
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate; // static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
static unsigned short acc_step_rate; // needed for deceleration start point static unsigned short acc_step_rate; // needed for deceleration start point
static uint8_t step_loops; static uint8_t step_loops;
static uint8_t step_loops_nominal; static uint8_t step_loops_nominal;
...@@ -91,10 +91,14 @@ static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROB ...@@ -91,10 +91,14 @@ static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROB
int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT; int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT;
#endif #endif
#if ENABLED(COLOR_MIXING_EXTRUDER)
static long counter_m[DRIVER_EXTRUDERS];
#endif
static bool check_endstops = true; static bool check_endstops = true;
volatile long count_position[NUM_AXIS] = { 0 }; volatile long count_position[NUM_AXIS] = { 0 }; // Positions of stepper motors, in step units
volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; volatile signed char count_direction[NUM_AXIS] = { 1 };
//=========================================================================== //===========================================================================
...@@ -303,14 +307,7 @@ void checkHitEndstops() { ...@@ -303,14 +307,7 @@ void checkHitEndstops() {
} }
} }
void enable_endstops(bool check) { void enable_endstops(bool check) { check_endstops = check; }
if (debugLevel & DEBUG_DEBUG) {
ECHO_SM(DB, "setup_for_endstop_move > enable_endstops");
if (check) ECHO_EM("(true)");
else ECHO_EM("(false)");
}
check_endstops = check;
}
// Check endstops // Check endstops
inline void update_endstops() { inline void update_endstops() {
...@@ -537,7 +534,12 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) { ...@@ -537,7 +534,12 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
timer = (unsigned short)pgm_read_word_near(table_address); timer = (unsigned short)pgm_read_word_near(table_address);
timer -= (((unsigned short)pgm_read_word_near(table_address + 2) * (unsigned char)(step_rate & 0x0007)) >> 3); timer -= (((unsigned short)pgm_read_word_near(table_address + 2) * (unsigned char)(step_rate & 0x0007)) >> 3);
} }
if (timer < 100) { timer = 100; ECHO_M(SERIAL_STEPPER_TOO_HIGH); ECHO_T(step_rate); }//(20kHz this should never happen)
if (timer < 100) { // (20kHz this should never happen)
timer = 100;
ECHO_EMV(SERIAL_STEPPER_TOO_HIGH, step_rate);
}
return timer; return timer;
} }
...@@ -622,7 +624,13 @@ FORCE_INLINE void trapezoid_generator_reset() { ...@@ -622,7 +624,13 @@ FORCE_INLINE void trapezoid_generator_reset() {
advance = current_block->initial_advance; advance = current_block->initial_advance;
final_advance = current_block->final_advance; final_advance = current_block->final_advance;
// Do E steps + advance steps // Do E steps + advance steps
e_steps[current_block->active_driver] += ((advance >>8) - old_advance); #if ENABLED(COLOR_MIXING_EXTRUDER)
// Move mixing steppers proportionally
for (int8_t j = 0; j < DRIVER_EXTRUDERS; j++)
e_steps[j] += ((advance >> 8) - old_advance) * current_block->mix_steps[j] / current_block->step_event_count;
#else
e_steps[current_block->active_driver] += ((advance >> 8) - old_advance);
#endif
old_advance = advance >>8; old_advance = advance >>8;
#endif #endif
deceleration_time = 0; deceleration_time = 0;
...@@ -657,14 +665,21 @@ ISR(TIMER1_COMPA_vect) { ...@@ -657,14 +665,21 @@ ISR(TIMER1_COMPA_vect) {
if (current_block) { if (current_block) {
current_block->busy = true; current_block->busy = true;
trapezoid_generator_reset(); trapezoid_generator_reset();
counter_x = -(current_block->step_event_count >> 1);
counter_y = counter_z = counter_e = counter_x; // Initialize Bresenham counters to 1/2 the ceiling
long new_count = -(current_block->step_event_count >> 1);
counter_x = counter_y = counter_z = counter_e = new_count;
#if ENABLED(COLOR_MIXING_EXTRUDER)
for (int8_t e = 0; e < DRIVER_EXTRUDERS; e++) counter_m[e] = new_count;
#endif
step_events_completed = 0; step_events_completed = 0;
#if ENABLED(Z_LATE_ENABLE) #if ENABLED(Z_LATE_ENABLE)
if (current_block->steps[Z_AXIS] > 0) { if (current_block->steps[Z_AXIS] > 0) {
enable_z(); enable_z();
OCR1A = 2000; //1ms wait OCR1A = 2000; // 1ms wait
return; return;
} }
#endif #endif
...@@ -674,7 +689,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -674,7 +689,7 @@ ISR(TIMER1_COMPA_vect) {
// #endif // #endif
} }
else { else {
OCR1A = 2000; // 1kHz. OCR1A = 2000; // 1kHz
} }
} }
...@@ -685,17 +700,30 @@ ISR(TIMER1_COMPA_vect) { ...@@ -685,17 +700,30 @@ ISR(TIMER1_COMPA_vect) {
// Take multiple steps per interrupt (For high speed moves) // Take multiple steps per interrupt (For high speed moves)
for (int8_t i = 0; i < step_loops; i++) { for (int8_t i = 0; i < step_loops; i++) {
#ifndef USBCON
MKSERIAL.checkRx(); // Check for serial chars. MKSERIAL.checkRx(); // Check for serial chars.
#endif
#if ENABLED(ADVANCE) #if ENABLED(ADVANCE)
counter_e += current_block->steps[E_AXIS]; counter_e += current_block->steps[E_AXIS];
if (counter_e > 0) { if (counter_e > 0) {
counter_e -= current_block->step_event_count; counter_e -= current_block->step_event_count;
e_steps[current_block->active_driver] += TEST(out_bits, E_AXIS) ? -1 : 1; #if DISABLED(COLOR_MIXING_EXTRUDER)
// Don't step E for mixing extruder
e_steps[current_block->active_driver] += TEST(out_bits, E_AXIS) ? -1 : 1;
#endif
} }
#endif //ADVANCE
#if ENABLED(COLOR_MIXING_EXTRUDER)
long dir = TEST(out_bits, E_AXIS) ? -1 : 1;
for (uint8_t j = 0; j < DRIVER_EXTRUDERS; j++) {
counter_m[j] += current_block->mix_steps[j];
if (counter_m[j] > 0) {
counter_m[j] -= current_block->step_event_count;
e_steps[j] += dir;
}
}
#endif // !COLOR_MIXING_EXTRUDER
#endif // ADVANCE
#define _COUNTER(axis) counter_## axis #define _COUNTER(axis) counter_## axis
#define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
...@@ -705,11 +733,19 @@ ISR(TIMER1_COMPA_vect) { ...@@ -705,11 +733,19 @@ ISR(TIMER1_COMPA_vect) {
_COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \ _COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \
if (_COUNTER(axis) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); } if (_COUNTER(axis) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
STEP_START(x,X); STEP_START(x, X);
STEP_START(y,Y); STEP_START(y, Y);
STEP_START(z,Z); STEP_START(z, Z);
#if DISABLED(ADVANCE) #if DISABLED(ADVANCE)
STEP_START(e,E); #if ENABLED(COLOR_MIXING_EXTRUDER)
counter_e += current_block->steps[E_AXIS];
for (uint8_t j = 0; j < DRIVER_EXTRUDERS; j++) {
counter_m[j] += current_block->mix_steps[j];
if (counter_m[j] > 0) En_STEP_WRITE(j, !INVERT_E_STEP_PIN);
}
#else
STEP_START(e, E);
#endif
#endif #endif
#if ENABLED(STEPPER_HIGH_LOW) && STEPPER_HIGH_LOW_DELAY > 0 #if ENABLED(STEPPER_HIGH_LOW) && STEPPER_HIGH_LOW_DELAY > 0
...@@ -727,7 +763,21 @@ ISR(TIMER1_COMPA_vect) { ...@@ -727,7 +763,21 @@ ISR(TIMER1_COMPA_vect) {
STEP_END(y, Y); STEP_END(y, Y);
STEP_END(z, Z); STEP_END(z, Z);
#if DISABLED(ADVANCE) #if DISABLED(ADVANCE)
STEP_END(e, E); #if ENABLED(MIXING_EXTRUDER_FEATURE)
// Always count the single E axis
if (counter_e > 0) {
counter_e -= current_block->step_event_count;
count_position[E_AXIS] += count_direction[E_AXIS];
}
for (int8_t j = 0; j < DRIVER_EXTRUDERS; j++) {
if (counter_m[j] > 0) {
counter_m[j] -= current_block->step_event_count;
En_STEP_WRITE(j, INVERT_E_STEP_PIN);
}
}
#else
STEP_END(e, E);
#endif
#endif #endif
step_events_completed++; step_events_completed++;
...@@ -882,6 +932,36 @@ ISR(TIMER1_COMPA_vect) { ...@@ -882,6 +932,36 @@ ISR(TIMER1_COMPA_vect) {
} }
} }
#endif #endif
#if DRIVER_EXTRUDERS > 4
if (e_steps[4] != 0) {
E4_STEP_WRITE(INVERT_E_STEP_PIN);
if (e_steps[4] < 0) {
E4_DIR_WRITE(INVERT_E4_DIR);
e_steps[4]++;
E4_STEP_WRITE(!INVERT_E_STEP_PIN);
}
else if (e_steps[4] > 0) {
E4_DIR_WRITE(!INVERT_E4_DIR);
e_steps[4]--;
E4_STEP_WRITE(!INVERT_E_STEP_PIN);
}
}
#endif
#if DRIVER_EXTRUDERS > 5
if (e_steps[5] != 0) {
E5_STEP_WRITE(INVERT_E_STEP_PIN);
if (e_steps[5] < 0) {
E5_DIR_WRITE(INVERT_E5_DIR);
e_steps[5]++;
E5_STEP_WRITE(!INVERT_E_STEP_PIN);
}
else if (e_steps[5] > 0) {
E5_DIR_WRITE(!INVERT_E5_DIR);
e_steps[5]--;
E5_STEP_WRITE(!INVERT_E_STEP_PIN);
}
}
#endif
} }
} }
#endif // ADVANCE #endif // ADVANCE
...@@ -930,6 +1010,12 @@ void st_init() { ...@@ -930,6 +1010,12 @@ void st_init() {
#if HAS(E3_DIR) #if HAS(E3_DIR)
E3_DIR_INIT; E3_DIR_INIT;
#endif #endif
#if HAS(E4_DIR)
E4_DIR_INIT;
#endif
#if HAS(E5_DIR)
E5_DIR_INIT;
#endif
//Initialize Enable Pins - steppers default to disabled. //Initialize Enable Pins - steppers default to disabled.
...@@ -975,6 +1061,14 @@ void st_init() { ...@@ -975,6 +1061,14 @@ void st_init() {
E3_ENABLE_INIT; E3_ENABLE_INIT;
if (!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH); if (!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH);
#endif #endif
#if HAS(E4_ENABLE)
E4_ENABLE_INIT;
if (!E_ENABLE_ON) E4_ENABLE_WRITE(HIGH);
#endif
#if HAS(E5_ENABLE)
E5_ENABLE_INIT;
if (!E_ENABLE_ON) E5_ENABLE_WRITE(HIGH);
#endif
//Choice E0-E1 or E0-E2 or E1-E3 pin //Choice E0-E1 or E0-E2 or E1-E3 pin
#if ENABLED(MKR4) && HAS(E0E1) #if ENABLED(MKR4) && HAS(E0E1)
...@@ -986,6 +1080,12 @@ void st_init() { ...@@ -986,6 +1080,12 @@ void st_init() {
#if ENABLED(MKR4) && HAS(E0E3) #if ENABLED(MKR4) && HAS(E0E3)
OUT_WRITE_RELE(E0E3_CHOICE_PIN, LOW); OUT_WRITE_RELE(E0E3_CHOICE_PIN, LOW);
#endif #endif
#if ENABLED(MKR4) && HAS(E0E4)
OUT_WRITE_RELE(E0E4_CHOICE_PIN, LOW);
#endif
#if ENABLED(MKR4) && HAS(E0E5)
OUT_WRITE_RELE(E0E5_CHOICE_PIN, LOW);
#endif
#if ENABLED(MKR4) && HAS(E1E3) #if ENABLED(MKR4) && HAS(E1E3)
OUT_WRITE_RELE(E1E3_CHOICE_PIN, LOW); OUT_WRITE_RELE(E1E3_CHOICE_PIN, LOW);
#endif #endif
...@@ -1106,6 +1206,12 @@ void st_init() { ...@@ -1106,6 +1206,12 @@ void st_init() {
#if HAS(E3_STEP) #if HAS(E3_STEP)
E_AXIS_INIT(3); E_AXIS_INIT(3);
#endif #endif
#if HAS(E4_STEP)
E_AXIS_INIT(4);
#endif
#if HAS(E5_STEP)
E_AXIS_INIT(5);
#endif
// waveform generation = 0100 = CTC // waveform generation = 0100 = CTC
TCCR1B &= ~BIT(WGM13); TCCR1B &= ~BIT(WGM13);
...@@ -1132,7 +1238,7 @@ void st_init() { ...@@ -1132,7 +1238,7 @@ void st_init() {
TCCR0A &= ~BIT(WGM01); TCCR0A &= ~BIT(WGM01);
TCCR0A &= ~BIT(WGM00); TCCR0A &= ~BIT(WGM00);
#endif #endif
e_steps[0] = e_steps[1] = e_steps[2] = e_steps[3] = 0; e_steps[0] = e_steps[1] = e_steps[2] = e_steps[3] = e_steps[4] = e_steps[5] = 0;
TIMSK0 |= BIT(OCIE0A); TIMSK0 |= BIT(OCIE0A);
#endif //ADVANCE #endif //ADVANCE
......
...@@ -34,7 +34,30 @@ enum AxisEnum {X_AXIS=0, A_AXIS=0, Y_AXIS=1, B_AXIS=1, Z_AXIS=2, C_AXIS=2, E_AXI ...@@ -34,7 +34,30 @@ enum AxisEnum {X_AXIS=0, A_AXIS=0, Y_AXIS=1, B_AXIS=1, Z_AXIS=2, C_AXIS=2, E_AXI
enum EndstopEnum {X_MIN=0, Y_MIN=1, Z_MIN=2, Z_PROBE=3, X_MAX=4, Y_MAX=5, Z_MAX=6, Z2_MIN=7, Z2_MAX=8, E_MIN=9}; enum EndstopEnum {X_MIN=0, Y_MIN=1, Z_MIN=2, Z_PROBE=3, X_MAX=4, Y_MAX=5, Z_MAX=6, Z2_MIN=7, Z2_MAX=8, E_MIN=9};
#if DRIVER_EXTRUDERS > 3 #if ENABLED(COLOR_MIXING_EXTRUDER)
#define E_STEP_WRITE(v) ; /* not used for mixing extruders! */
#if DRIVER_EXTRUDERS > 5
#define En_STEP_WRITE(n,v) { switch (n) { case 0: E0_STEP_WRITE(v); break; case 1: E1_STEP_WRITE(v); break; case 2: E2_STEP_WRITE(v); break; case 3: E3_STEP_WRITE(v); break; case 4: E4_STEP_WRITE(v); break; case 5: E5_STEP_WRITE(v); } }
#define NORM_E_DIR() { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); E2_DIR_WRITE(!INVERT_E2_DIR); E3_DIR_WRITE(!INVERT_E3_DIR); E4_DIR_WRITE(!INVERT_E4_DIR); E5_DIR_WRITE(!INVERT_E5_DIR); }
#define REV_E_DIR() { E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E1_DIR); E2_DIR_WRITE( INVERT_E2_DIR); E3_DIR_WRITE( INVERT_E3_DIR); E4_DIR_WRITE( INVERT_E4_DIR); E5_DIR_WRITE( INVERT_E5_DIR); }
#elif DRIVER_EXTRUDERS > 4
#define En_STEP_WRITE(n,v) { switch (n) { case 0: E0_STEP_WRITE(v); break; case 1: E1_STEP_WRITE(v); break; case 2: E2_STEP_WRITE(v); break; case 3: E3_STEP_WRITE(v); break; case 4: E4_STEP_WRITE(v); } }
#define NORM_E_DIR() { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); E2_DIR_WRITE(!INVERT_E2_DIR); E3_DIR_WRITE(!INVERT_E3_DIR); E4_DIR_WRITE(!INVERT_E4_DIR); }
#define REV_E_DIR() { E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E1_DIR); E2_DIR_WRITE( INVERT_E2_DIR); E3_DIR_WRITE( INVERT_E3_DIR); E4_DIR_WRITE( INVERT_E4_DIR); }
#elif DRIVER_EXTRUDERS > 3
#define En_STEP_WRITE(n,v) { switch (n) { case 0: E0_STEP_WRITE(v); break; case 1: E1_STEP_WRITE(v); break; case 2: E2_STEP_WRITE(v); break; case 3: E3_STEP_WRITE(v); } }
#define NORM_E_DIR() { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); E2_DIR_WRITE(!INVERT_E2_DIR); E3_DIR_WRITE(!INVERT_E3_DIR); }
#define REV_E_DIR() { E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E1_DIR); E2_DIR_WRITE( INVERT_E2_DIR); E3_DIR_WRITE( INVERT_E3_DIR); }
#elif DRIVER_EXTRUDERS > 2
#define En_STEP_WRITE(n,v) { switch (n) { case 0: E0_STEP_WRITE(v); break; case 1: E1_STEP_WRITE(v); break; case 2: E2_STEP_WRITE(v); } }
#define NORM_E_DIR() { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); E2_DIR_WRITE(!INVERT_E2_DIR); }
#define REV_E_DIR() { E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E1_DIR); E2_DIR_WRITE( INVERT_E2_DIR); }
#else
#define En_STEP_WRITE(n,v) { switch (n) { case 0: E0_STEP_WRITE(v); break; case 1: E1_STEP_WRITE(v); } }
#define NORM_E_DIR() { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); }
#define REV_E_DIR() { E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E1_DIR); }
#endif
#elif DRIVER_EXTRUDERS > 3
#define E_STEP_WRITE(v) { if(current_block->active_driver == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_driver == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}} #define E_STEP_WRITE(v) { if(current_block->active_driver == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_driver == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}}
#define NORM_E_DIR() { if(current_block->active_driver == 3) { E3_DIR_WRITE( !INVERT_E3_DIR); } else { if(current_block->active_driver == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}} #define NORM_E_DIR() { if(current_block->active_driver == 3) { E3_DIR_WRITE( !INVERT_E3_DIR); } else { if(current_block->active_driver == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}}
#define REV_E_DIR() { if(current_block->active_driver == 3) { E3_DIR_WRITE(INVERT_E3_DIR); } else { if(current_block->active_driver == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}} #define REV_E_DIR() { if(current_block->active_driver == 3) { E3_DIR_WRITE(INVERT_E3_DIR); } else { if(current_block->active_driver == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}}
......
...@@ -152,6 +152,32 @@ ...@@ -152,6 +152,32 @@
#define E3_ENABLE_WRITE(STATE) WRITE(E3_ENABLE_PIN,STATE) #define E3_ENABLE_WRITE(STATE) WRITE(E3_ENABLE_PIN,STATE)
#define E3_ENABLE_READ READ(E3_ENABLE_PIN) #define E3_ENABLE_READ READ(E3_ENABLE_PIN)
// E4 motor
#define E4_STEP_INIT SET_OUTPUT(E4_STEP_PIN)
#define E4_STEP_WRITE(STATE) WRITE(E4_STEP_PIN,STATE)
#define E4_STEP_READ READ(E4_STEP_PIN)
#define E4_DIR_INIT SET_OUTPUT(E4_DIR_PIN)
#define E4_DIR_WRITE(STATE) WRITE(E4_DIR_PIN,STATE)
#define E4_DIR_READ READ(E4_DIR_PIN)
#define E4_ENABLE_INIT SET_OUTPUT(E4_ENABLE_PIN)
#define E4_ENABLE_WRITE(STATE) WRITE(E4_ENABLE_PIN,STATE)
#define E4_ENABLE_READ READ(E4_ENABLE_PIN)
// E5 motor
#define E5_STEP_INIT SET_OUTPUT(E5_STEP_PIN)
#define E5_STEP_WRITE(STATE) WRITE(E5_STEP_PIN,STATE)
#define E5_STEP_READ READ(E5_STEP_PIN)
#define E5_DIR_INIT SET_OUTPUT(E5_DIR_PIN)
#define E5_DIR_WRITE(STATE) WRITE(E5_DIR_PIN,STATE)
#define E5_DIR_READ READ(E5_DIR_PIN)
#define E5_ENABLE_INIT SET_OUTPUT(E5_ENABLE_PIN)
#define E5_ENABLE_WRITE(STATE) WRITE(E5_ENABLE_PIN,STATE)
#define E5_ENABLE_READ READ(E5_ENABLE_PIN)
#if ENABLED(DUAL_X_CARRIAGE) && HAS(X_ENABLE) && HAS(X2_ENABLE) #if ENABLED(DUAL_X_CARRIAGE) && HAS(X_ENABLE) && HAS(X2_ENABLE)
#define enable_x() do { X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); } while (0) #define enable_x() do { X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); } while (0)
#define disable_x() do { X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } while (0) #define disable_x() do { X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } while (0)
...@@ -159,7 +185,7 @@ ...@@ -159,7 +185,7 @@
#define enable_x() X_ENABLE_WRITE( X_ENABLE_ON) #define enable_x() X_ENABLE_WRITE( X_ENABLE_ON)
#define disable_x() { X_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } #define disable_x() { X_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }
#else #else
#define enable_x() ; #define enable_x() ;
#define disable_x() ; #define disable_x() ;
#endif #endif
...@@ -172,7 +198,7 @@ ...@@ -172,7 +198,7 @@
#define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; } #define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
#endif #endif
#else #else
#define enable_y() ; #define enable_y() ;
#define disable_y() ; #define disable_y() ;
#endif #endif
...@@ -185,43 +211,93 @@ ...@@ -185,43 +211,93 @@
#define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#endif #endif
#else #else
#define enable_z() ; #define enable_z() ;
#define disable_z() ; #define disable_z() ;
#endif #endif
#if HAS(E0_ENABLE) #if ENABLED(COLOR_MIXING_EXTRUDER)
#define enable_e0() E0_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON) #if MIXING_EXTRUDER > 5
#else #define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); E4_ENABLE_WRITE( E_ENABLE_ON); E5_ENABLE_WRITE( E_ENABLE_ON); }
#define enable_e0() /* nothing */ #define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); E4_ENABLE_WRITE(!E_ENABLE_ON); E5_ENABLE_WRITE(!E_ENABLE_ON); }
#define disable_e0() /* nothing */ #elif MIXING_EXTRUDER > 4
#endif #define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); E4_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); E4_ENABLE_WRITE(!E_ENABLE_ON); }
#elif MIXING_EXTRUDER > 3
#define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); }
#elif MIXING_EXTRUDER > 2
#define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); }
#else
#define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); }
#endif
#if (DRIVER_EXTRUDERS > 1) && HAS(E1_ENABLE) #define enable_e1() ;
#define enable_e1() E1_ENABLE_WRITE( E_ENABLE_ON) #define disable_e1() ;
#define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON) #define enable_e2() ;
#else #define disable_e2() ;
#define enable_e1() /* nothing */ #define enable_e3() ;
#define disable_e1() /* nothing */ #define disable_e3() ;
#endif #define enable_e4() ;
#define disable_e4() ;
#define enable_e5() ;
#define disable_e5() ;
#else // !COLOR_MIXING_EXTRUDER
#if HAS(E0_ENABLE)
#define enable_e0() E0_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e0() /* nothing */
#define disable_e0() /* nothing */
#endif
#if (DRIVER_EXTRUDERS > 2) && HAS(E2_ENABLE) #if (DRIVER_EXTRUDERS > 1) && HAS(E1_ENABLE)
#define enable_e2() E2_ENABLE_WRITE( E_ENABLE_ON) #define enable_e1() E1_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON) #define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON)
#else #else
#define enable_e2() /* nothing */ #define enable_e1() /* nothing */
#define disable_e2() /* nothing */ #define disable_e1() /* nothing */
#endif #endif
#if (DRIVER_EXTRUDERS > 2) && HAS(E2_ENABLE)
#define enable_e2() E2_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e2() /* nothing */
#define disable_e2() /* nothing */
#endif
#if (DRIVER_EXTRUDERS > 3) && HAS(E3_ENABLE)
#define enable_e3() E3_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e3() /* nothing */
#define disable_e3() /* nothing */
#endif
#if (DRIVER_EXTRUDERS > 4) && HAS(E4_ENABLE)
#define enable_e4() E4_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e4() E4_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e4() /* nothing */
#define disable_e4() /* nothing */
#endif
#if (DRIVER_EXTRUDERS > 5) && HAS(E5_ENABLE)
#define enable_e5() E5_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e5() E5_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e5() /* nothing */
#define disable_e5() /* nothing */
#endif
#if (DRIVER_EXTRUDERS > 3) && HAS(E3_ENABLE)
#define enable_e3() E3_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e3() /* nothing */
#define disable_e3() /* nothing */
#endif #endif
#define disable_e() {disable_e0(); disable_e1(); disable_e2(); disable_e3();} #define disable_e() { disable_e0(); disable_e1(); disable_e2(); disable_e3(); disable_e4(); disable_e5(); }
////////////////////////////////// //////////////////////////////////
// Pin redefines for TMC drivers. // Pin redefines for TMC drivers.
......
...@@ -1653,6 +1653,28 @@ ...@@ -1653,6 +1653,28 @@
#if !PIN_EXISTS(E3_ENABLE) #if !PIN_EXISTS(E3_ENABLE)
#error DEPENDENCY ERROR: E3_ENABLE_PIN is not defined for your board. You have to define it yourself. #error DEPENDENCY ERROR: E3_ENABLE_PIN is not defined for your board. You have to define it yourself.
#endif #endif
#if DRIVER_EXTRUDERS > 4
#if !PIN_EXISTS(E4_STEP)
#error DEPENDENCY ERROR: E4_STEP_PIN is not defined for your board. You have to define it yourself.
#endif
#if !PIN_EXISTS(E4_DIR)
#error DEPENDENCY ERROR: E4_DIR_PIN is not defined for your board. You have to define it yourself.
#endif
#if !PIN_EXISTS(E4_ENABLE)
#error DEPENDENCY ERROR: E4_ENABLE_PIN is not defined for your board. You have to define it yourself.
#endif
#if DRIVER_EXTRUDERS > 5
#if !PIN_EXISTS(E5_STEP)
#error DEPENDENCY ERROR: E5_STEP_PIN is not defined for your board. You have to define it yourself.
#endif
#if !PIN_EXISTS(E5_DIR)
#error DEPENDENCY ERROR: E5_DIR_PIN is not defined for your board. You have to define it yourself.
#endif
#if !PIN_EXISTS(E5_ENABLE)
#error DEPENDENCY ERROR: E5_ENABLE_PIN is not defined for your board. You have to define it yourself.
#endif
#endif
#endif
#endif #endif
#endif #endif
#endif #endif
...@@ -1665,6 +1687,10 @@ ...@@ -1665,6 +1687,10 @@
#error DEPENDENCY ERROR: You have to set E0E1_CHOICE_PIN and E0E2_CHOICE_PIN to a valid pin if you enable MKR4 with 3 extruder and 1 driver #error DEPENDENCY ERROR: You have to set E0E1_CHOICE_PIN and E0E2_CHOICE_PIN to a valid pin if you enable MKR4 with 3 extruder and 1 driver
#elif (EXTRUDERS == 4) && (DRIVER_EXTRUDERS == 1) && (!PIN_EXISTS(E0E1_CHOICE) || !PIN_EXISTS(E0E2_CHOICE) || !PIN_EXISTS(E0E3_CHOICE)) #elif (EXTRUDERS == 4) && (DRIVER_EXTRUDERS == 1) && (!PIN_EXISTS(E0E1_CHOICE) || !PIN_EXISTS(E0E2_CHOICE) || !PIN_EXISTS(E0E3_CHOICE))
#error DEPENDENCY ERROR: You have to set E0E1_CHOICE_PIN, E0E2_CHOICE_PIN and E0E3_CHOICE_PIN to a valid pin if you enable MKR4 with 4 extruder and 1 driver #error DEPENDENCY ERROR: You have to set E0E1_CHOICE_PIN, E0E2_CHOICE_PIN and E0E3_CHOICE_PIN to a valid pin if you enable MKR4 with 4 extruder and 1 driver
#elif (EXTRUDERS == 5) && (DRIVER_EXTRUDERS == 1) && (!PIN_EXISTS(E0E1_CHOICE) || !PIN_EXISTS(E0E2_CHOICE) || !PIN_EXISTS(E0E3_CHOICE) || !PIN_EXISTS(E0E4_CHOICE))
#error DEPENDENCY ERROR: You have to set E0E1_CHOICE_PIN, E0E2_CHOICE_PIN and E0E3_CHOICE_PIN to a valid pin if you enable MKR4 with 4 extruder and 1 driver
#elif (EXTRUDERS == 6) && (DRIVER_EXTRUDERS == 1) && (!PIN_EXISTS(E0E1_CHOICE) || !PIN_EXISTS(E0E2_CHOICE) || !PIN_EXISTS(E0E3_CHOICE) || !PIN_EXISTS(E0E4_CHOICE) || !PIN_EXISTS(E0E5_CHOICE))
#error DEPENDENCY ERROR: You have to set E0E1_CHOICE_PIN, E0E2_CHOICE_PIN and E0E3_CHOICE_PIN to a valid pin if you enable MKR4 with 4 extruder and 1 driver
#elif (EXTRUDERS == 3) && (DRIVER_EXTRUDERS == 2) && !PIN_EXISTS(E0E2_CHOICE) #elif (EXTRUDERS == 3) && (DRIVER_EXTRUDERS == 2) && !PIN_EXISTS(E0E2_CHOICE)
#error DEPENDENCY ERROR: You have to set E0E2_CHOICE_PIN to a valid pin if you enable MKR4 with 3 extruder and 2 driver #error DEPENDENCY ERROR: You have to set E0E2_CHOICE_PIN to a valid pin if you enable MKR4 with 3 extruder and 2 driver
#elif (EXTRUDERS == 4) && (DRIVER_EXTRUDERS == 2) && (!PIN_EXISTS(E0E2_CHOICE) || !PIN_EXISTS(E1E3_CHOICE)) #elif (EXTRUDERS == 4) && (DRIVER_EXTRUDERS == 2) && (!PIN_EXISTS(E0E2_CHOICE) || !PIN_EXISTS(E1E3_CHOICE))
......
...@@ -15,7 +15,7 @@ extern char fullName[LONG_FILENAME_LENGTH * SD_MAX_FOLDER_DEPTH + SD_MAX_FOLDER_ ...@@ -15,7 +15,7 @@ extern char fullName[LONG_FILENAME_LENGTH * SD_MAX_FOLDER_DEPTH + SD_MAX_FOLDER_
enum LsAction { LS_Count, LS_GetFilename }; enum LsAction { LS_Count, LS_GetFilename };
#include "SdFat.h" #include "SDFat.h"
class CardReader { class CardReader {
public: public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment