Commit 9f3e404f authored by MagoKimbra's avatar MagoKimbra

Fix

parent f8279b07
......@@ -30,6 +30,10 @@
#include "../base.h"
#if ENABLED(RFID_MODULE)
MFRC522 RFID522;
#endif
#if ENABLED(M100_FREE_MEMORY_WATCHER)
void gcode_M100();
#endif
......@@ -125,6 +129,13 @@ double printer_usage_filament;
int old_color = 99;
#endif
#if ENABLED(RFID_MODULE)
bool RFID_ON = false;
unsigned long Spool_ID[EXTRUDERS] = ARRAY_BY_EXTRUDERS (0);
bool Spool_must_read[EXTRUDERS] = ARRAY_BY_EXTRUDERS (false);
bool Spool_must_write[EXTRUDERS] = ARRAY_BY_EXTRUDERS (false);
#endif
#if HAS(SERVO_ENDSTOPS)
const int servo_endstop_id[] = SERVO_ENDSTOP_IDS;
const int servo_endstop_angle[][2] = {X_ENDSTOP_SERVO_ANGLES, Y_ENDSTOP_SERVO_ANGLES, Z_ENDSTOP_SERVO_ANGLES};
......@@ -657,6 +668,12 @@ void setup() {
setup_statled();
#endif
#if ENABLED(RFID_MODULE)
RFID_ON = RFID522.init();
if (RFID_ON)
ECHO_LM(INFO, "RFID CONNECT");
#endif
#if ENABLED(FIRMWARE_TEST)
FirmwareTest();
#endif
......@@ -2518,7 +2535,7 @@ static void clean_up_after_endstop_move() {
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;
float v = code_seen(mixing_codes[e]) ? code_value() : mixing_factor[e];
mixing_factor[e] = v;
mix_total += v;
}
......@@ -2826,6 +2843,10 @@ void gcode_get_destination() {
printer_usage_filament += (destination[E_AXIS] - current_position[E_AXIS]);
#if ENABLED(RFID_MODULE)
RFID522.RfidData[active_extruder].data.lenght -= (destination[E_AXIS] - current_position[E_AXIS]);
#endif
#if ENABLED(NEXTION) && ENABLED(NEXTION_GFX)
if((code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS])) && code_seen(axis_codes[E_AXIS]))
gfx_line_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS]);
......@@ -5615,7 +5636,12 @@ inline void gcode_M221() {
inline void gcode_M222() {
if (setTargetedExtruder(222)) return;
if (code_seen('S')) density_multiplier[target_extruder] = code_value();
if (code_seen('S')) {
density_multiplier[target_extruder] = code_value();
#if ENABLED(RFID_MODULE)
RFID522.RfidData[target_extruder].data.density = density_multiplier[target_extruder];
#endif
}
}
#if ENABLED(COLOR_MIXING_EXTRUDER)
......@@ -6192,6 +6218,31 @@ inline void gcode_M503() {
Config_PrintSettings(code_seen('S') && code_value() == 0);
}
#if ENABLED(RFID_MODULE)
/**
* M522: Read or Write on card. M522 T<extruders> R<read> or W<write> L<list>
*/
inline void gcode_M522() {
if (setTargetedExtruder(522)) return;
if (!RFID_ON) return;
if (code_seen('R')) {
ECHO_LM(DB, "Put RFID on tag!");
Spool_must_read[target_extruder] = true;
}
if (code_seen('W')) {
if (Spool_ID[target_extruder] != 0) {
ECHO_LM(DB, "Put RFID on tag!");
Spool_must_write[target_extruder] = true;
}
else
ECHO_LM(ER, "You have not read this Spool!");
}
if (code_seen('L')) RFID522.printInfo(target_extruder);
}
#endif // RFID_MODULE
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
/**
......@@ -7198,7 +7249,7 @@ void process_next_command() {
#if ENABLED(COLOR_MIXING_EXTRUDER)
case 223: // M223 Set the mix factors for a mixing extruder
gcode_M223; break;
gcode_M223(); break;
#endif
case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
......@@ -7302,6 +7353,11 @@ void process_next_command() {
case 503: // M503 print settings currently in memory
gcode_M503(); break;
#if ENABLED(RFID_MODULE)
case 522: // M422 Read or Write on card. M522 T<extruders> R<read> or W<write>
gcode_M522(); break;
#endif
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
case 540:
gcode_M540(); break;
......@@ -8053,6 +8109,38 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
}
#endif
#if ENABLED(RFID_MODULE)
for (int8_t e = 0; e < EXTRUDERS; e++) {
if (Spool_must_read[e]) {
if (RFID522.getID(e)) {
Spool_ID[e] = RFID522.RfidDataID[e].Spool_ID;
delay(200);
if (RFID522.readBlock(e)) {
Spool_must_read[e] = false;
density_multiplier[e] = RFID522.RfidData[e].data.density;
filament_size[e] = RFID522.RfidData[e].data.size;
calculate_volumetric_multipliers();
RFID522.printInfo(e);
}
}
}
if (Spool_must_write[e]) {
if (RFID522.getID(e)) {
if (Spool_ID[e] == RFID522.RfidDataID[e].Spool_ID) {
delay(200);
if (RFID522.writeBlock(e)) {
Spool_must_write[e] = false;
ECHO_SMV(INFO, "Spool on E", e);
ECHO_EM(" writed!");
RFID522.printInfo(e);
}
}
}
}
}
#endif
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
if(IS_SD_INSERTED && !IS_SD_PRINTING) {
if (!config_readed) {
......
......@@ -606,8 +606,8 @@ float junction_deviation = 0.1;
// 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];
for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++)
block->mix_steps[i] = block->steps[E_AXIS] * mixing_factor[i];
#endif
// Add update block variables for LASER BEAM control
......
......@@ -580,26 +580,7 @@ void set_stepper_direction(bool onlye) {
}
}
#if DISABLED(ADVANCE) && ENABLED(DONDOLO)
if (TEST(out_bits, E_AXIS)) {
switch(active_extruder) {
case 0:
REV_E_DIR(); break;
case 1:
NORM_E_DIR(); break;
}
count_direction[E_AXIS] = -1;
}
else {
switch(active_extruder) {
case 0:
NORM_E_DIR(); break;
case 1:
REV_E_DIR(); break;
}
count_direction[E_AXIS] = 1;
}
#elif DISABLED(ADVANCE)
#if DISABLED(ADVANCE)
if (TEST(out_bits, E_AXIS)) {
REV_E_DIR();
count_direction[E_AXIS] = -1;
......@@ -671,7 +652,7 @@ ISR(TIMER1_COMPA_vect) {
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;
for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) counter_m[i] = new_count;
#endif
step_events_completed = 0;
......@@ -731,7 +712,10 @@ ISR(TIMER1_COMPA_vect) {
#define STEP_START(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); \
_COUNTER(axis) -= current_block->step_event_count; \
count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; }
STEP_START(x, X);
STEP_START(y, Y);
......@@ -739,9 +723,13 @@ ISR(TIMER1_COMPA_vect) {
#if DISABLED(ADVANCE)
#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);
if (counter_e > 0) {
for (int8_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);
}
counter_e -= current_block->step_event_count;
count_position[E_AXIS] += count_direction[E_AXIS];
}
#else
STEP_START(e, E);
......@@ -752,23 +740,13 @@ ISR(TIMER1_COMPA_vect) {
delayMicroseconds(STEPPER_HIGH_LOW_DELAY);
#endif
#define STEP_END(axis, AXIS) \
if (_COUNTER(axis) > 0) { \
_COUNTER(axis) -= current_block->step_event_count; \
count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
_APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
}
#define STEP_END(axis, AXIS) _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0)
STEP_END(x, X);
STEP_END(y, Y);
STEP_END(z, Z);
#if DISABLED(ADVANCE)
#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];
}
#if ENABLED(COLOR_MIXING_EXTRUDER)
for (int8_t j = 0; j < DRIVER_EXTRUDERS; j++) {
if (counter_m[j] > 0) {
counter_m[j] -= current_block->step_event_count;
......
......@@ -57,29 +57,43 @@ enum EndstopEnum {X_MIN=0, Y_MIN=1, Z_MIN=2, Z_PROBE=3, X_MAX=4, Y_MAX=5, Z_MAX=
#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 > 5
#define E_STEP_WRITE(v) { switch(current_block->active_driver) { case 5: E5_STEP_WRITE(v); break; case 4: E4_STEP_WRITE(v); break; case 3: E3_STEP_WRITE(v); break; case 2: E2_STEP_WRITE(v); break; case 1: E1_STEP_WRITE(v); break; case 0: E0_STEP_WRITE(v); break; } }
#define NORM_E_DIR() { switch(current_block->active_driver) { case 5: E5_DIR_WRITE(!INVERT_E5_DIR); break; case 4: E4_DIR_WRITE(!INVERT_E4_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; } }
#define REV_E_DIR() { switch(current_block->active_driver) { case 5: E5_DIR_WRITE( INVERT_E5_DIR); break; case 4: E4_DIR_WRITE( INVERT_E4_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; } }
#elif DRIVER_EXTRUDERS > 4
#define E_STEP_WRITE(v) { switch(current_block->active_driver) { case 4: E4_STEP_WRITE(v); break; case 3: E3_STEP_WRITE(v); break; case 2: E2_STEP_WRITE(v); break; case 1: E1_STEP_WRITE(v); break; case 0: E0_STEP_WRITE(v); break; } }
#define NORM_E_DIR() { switch(current_block->active_driver) { case 4: E4_DIR_WRITE(!INVERT_E4_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; } }
#define REV_E_DIR() { switch(current_block->active_driver) { case 4: E4_DIR_WRITE( INVERT_E4_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; } }
#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 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 E_STEP_WRITE(v) { switch(current_block->active_driver) { case 3: E3_STEP_WRITE(v); break; case 2: E2_STEP_WRITE(v); break; case 1: E1_STEP_WRITE(v); break; case 0: E0_STEP_WRITE(v); break; } }
#define NORM_E_DIR() { switch(current_block->active_driver) { case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; } }
#define REV_E_DIR() { switch(current_block->active_driver) { case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; } }
#elif DRIVER_EXTRUDERS > 2
#define E_STEP_WRITE(v) { 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 == 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 == 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 E_STEP_WRITE(v) { switch(current_block->active_driver) { case 2: E2_STEP_WRITE(v); break; case 1: E1_STEP_WRITE(v); break; case 0: E0_STEP_WRITE(v); break; } }
#define NORM_E_DIR() { switch(current_block->active_driver) { case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; } }
#define REV_E_DIR() { switch(current_block->active_driver) { case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; } }
#elif DRIVER_EXTRUDERS > 1
#if DISABLED(DUAL_X_CARRIAGE)
#define E_STEP_WRITE(v) { if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
#define NORM_E_DIR() { 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 == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
#define E_STEP_WRITE(v) { switch(current_block->active_driver) { case 1: E1_STEP_WRITE(v); break; case 0: E0_STEP_WRITE(v); break; }}
#define NORM_E_DIR() { switch(current_block->active_driver) { case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; }}
#define REV_E_DIR() { switch(current_block->active_driver) { case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; }}
#else
extern bool extruder_duplication_enabled;
#define E_STEP_WRITE(v) { if(extruder_duplication_enabled) { E0_STEP_WRITE(v); E1_STEP_WRITE(v); } else if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
#define NORM_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_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(extruder_duplication_enabled) { E0_DIR_WRITE(INVERT_E0_DIR); E1_DIR_WRITE(INVERT_E1_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(extruder_duplication_enabled) { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_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(extruder_duplication_enabled) { E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E1_DIR); } else if(current_block->active_driver == 1) { E1_DIR_WRITE( INVERT_E1_DIR); } else { E0_DIR_WRITE( INVERT_E0_DIR); }}
#endif
#else
#define E_STEP_WRITE(v) E0_STEP_WRITE(v)
#define NORM_E_DIR() E0_DIR_WRITE(!INVERT_E0_DIR)
#define REV_E_DIR() E0_DIR_WRITE(INVERT_E0_DIR)
#if ENABLED(DONDOLO)
#define E_STEP_WRITE(v) E0_STEP_WRITE(v)
#define NORM_E_DIR() { switch(active_extruder) { case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; }}
#define REV_E_DIR() { switch(active_extruder) { case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; }}
#else
#define E_STEP_WRITE(v) E0_STEP_WRITE(v)
#define NORM_E_DIR() E0_DIR_WRITE(!INVERT_E0_DIR)
#define REV_E_DIR() E0_DIR_WRITE( INVERT_E0_DIR)
#endif
#endif //DRIVER_EXTRUDERS
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
......
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