void check_axes_activity() { unsigned char x_active = 0; unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; unsigned char fan_speed = 0; unsigned char tail_fan_speed = 0; block_t *block; if(block_buffer_tail != block_buffer_head) { uint8_t block_index = block_buffer_tail; tail_fan_speed = block_buffer[block_index].fan_speed; while(block_index != block_buffer_head) { block = &block_buffer[block_index]; if(block->steps_x != 0) x_active++; if(block->steps_y != 0) y_active++; if(block->steps_z != 0) z_active++; if(block->steps_e != 0) e_active++; if(block->fan_speed != 0) fan_speed++; block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1); } } else { #if FAN_PIN > -1 if (FanSpeed != 0){ analogWrite(FAN_PIN,FanSpeed); // If buffer is empty use current fan speed } #endif } if((DISABLE_X) && (x_active == 0)) disable_x(); if((DISABLE_Y) && (y_active == 0)) disable_y(); if((DISABLE_Z) && (z_active == 0)) disable_z(); if((DISABLE_E) && (e_active == 0)) { disable_e0(); disable_e1(); disable_e2(); } #if FAN_PIN > -1 if((FanSpeed == 0) && (fan_speed ==0)) { analogWrite(FAN_PIN, 0); } if (FanSpeed != 0 && tail_fan_speed !=0) { analogWrite(FAN_PIN,tail_fan_speed); } #endif #ifdef AUTOTEMP getHighESpeed(); #endif }
void check_axes_activity() { unsigned char x_active = 0; unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; unsigned char tail_fan_speed = fanSpeed; block_t *block; if(block_buffer_tail != block_buffer_head) { uint8_t block_index = block_buffer_tail; tail_fan_speed = block_buffer[block_index].fan_speed; while(block_index != block_buffer_head) { block = &block_buffer[block_index]; if(block->steps_x != 0) x_active++; if(block->steps_y != 0) y_active++; if(block->steps_z != 0) z_active++; if(block->steps_e != 0) e_active++; block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1); } } if((DISABLE_X) && (x_active == 0)) disable_x(); if((DISABLE_Y) && (y_active == 0)) disable_y(); if((DISABLE_Z) && (z_active == 0)) disable_z(); if((DISABLE_E) && (e_active == 0)) { disable_e0(); disable_e1(); disable_e2(); } #if FAN_PIN > -1 #ifndef FAN_SOFT_PWM #ifdef FAN_KICKSTART_TIME static unsigned long fan_kick_end; if (tail_fan_speed) { if (fan_kick_end == 0) { // Just starting up fan - run at full power. fan_kick_end = millis() + FAN_KICKSTART_TIME; tail_fan_speed = 255; } else if (fan_kick_end > millis()) // Fan still spinning up. tail_fan_speed = 255; } else { fan_kick_end = 0; } #endif//FAN_KICKSTART_TIME analogWrite(FAN_PIN,tail_fan_speed); #endif//!FAN_SOFT_PWM #endif//FAN_PIN > -1 #ifdef AUTOTEMP getHighESpeed(); #endif }
void check_axes_activity() { unsigned char x_active = 0; unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; block_t *block; if(block_buffer_tail != block_buffer_head) { char block_index = block_buffer_tail; while(block_index != block_buffer_head) { block = &block_buffer[block_index]; if(block->steps_x != 0) x_active++; if(block->steps_y != 0) y_active++; if(block->steps_z != 0) z_active++; if(block->steps_e != 0) e_active++; block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1); } } if((DISABLE_X) && (x_active == 0)) disable_x(); if((DISABLE_Y) && (y_active == 0)) disable_y(); if((DISABLE_Z) && (z_active == 0)) disable_z(); if((DISABLE_E) && (e_active == 0)) disable_e(); }
void kill(int debug) { /* if (HEATER_0_PIN != NC) { p_heater0 = 0; } */ disable_x(); disable_y(); disable_z(); disable_e(); if (PS_ON_PIN != NC) { //pinMode(PS_ON_PIN,INPUT); } while (1) { switch (debug) { case 1: pc.printf("Inactivity Shutdown, Last Line: "); break; case 2: pc.printf("Linear Move Abort, Last Line: "); break; case 3: pc.printf("Homing X Min Stop Fail, Last Line: "); break; case 4: pc.printf("Homing Y Min Stop Fail, Last Line: "); break; } pc.printf("%s \n",gcode_LastN); wait(5); // 5 Second delay } }
void check_axes_activity() { unsigned char axis_active[NUM_AXIS] = { 0 }, tail_fan_speed = fanSpeed; #if ENABLED(BARICUDA) unsigned char tail_valve_pressure = ValvePressure, tail_e_to_p_pressure = EtoPPressure; #endif block_t *block; if (blocks_queued()) { uint8_t block_index = block_buffer_tail; tail_fan_speed = block_buffer[block_index].fan_speed; #if ENABLED(BARICUDA) block = &block_buffer[block_index]; tail_valve_pressure = block->valve_pressure; tail_e_to_p_pressure = block->e_to_p_pressure; #endif while (block_index != block_buffer_head) { block = &block_buffer[block_index]; for (int i=0; i<NUM_AXIS; i++) if (block->steps[i]) axis_active[i]++; block_index = next_block_index(block_index); } } if (DISABLE_X && !axis_active[X_AXIS]) disable_x(); if (DISABLE_Y && !axis_active[Y_AXIS]) disable_y(); if (DISABLE_Z && !axis_active[Z_AXIS]) disable_z(); if (DISABLE_E && !axis_active[E_AXIS]) { disable_e0(); disable_e1(); disable_e2(); disable_e3(); } #if HAS_FAN #ifdef FAN_KICKSTART_TIME static millis_t fan_kick_end; if (tail_fan_speed) { millis_t ms = millis(); if (fan_kick_end == 0) { // Just starting up fan - run at full power. fan_kick_end = ms + FAN_KICKSTART_TIME; tail_fan_speed = 255; } else if (fan_kick_end > ms) // Fan still spinning up. tail_fan_speed = 255; } else { fan_kick_end = 0; } #endif //FAN_KICKSTART_TIME #if ENABLED(FAN_MIN_PWM) #define CALC_FAN_SPEED (tail_fan_speed ? ( FAN_MIN_PWM + (tail_fan_speed * (255 - FAN_MIN_PWM)) / 255 ) : 0) #else #define CALC_FAN_SPEED tail_fan_speed #endif // FAN_MIN_PWM #if ENABLED(FAN_SOFT_PWM) fanSpeedSoftPwm = CALC_FAN_SPEED; #else analogWrite(FAN_PIN, CALC_FAN_SPEED); #endif // FAN_SOFT_PWM #endif // HAS_FAN #if ENABLED(AUTOTEMP) getHighESpeed(); #endif #if ENABLED(BARICUDA) #if HAS_HEATER_1 analogWrite(HEATER_1_PIN,tail_valve_pressure); #endif #if HAS_HEATER_2 analogWrite(HEATER_2_PIN,tail_e_to_p_pressure); #endif #endif }
void check_axes_activity() { unsigned char x_active = 0; unsigned char y_active = 0; unsigned char z_active = 0; unsigned char j_active = 0; unsigned char e_active = 0; unsigned char tail_fan_speed = fanSpeed; #ifdef BARICUDA unsigned char tail_valve_pressure = ValvePressure; unsigned char tail_e_to_p_pressure = EtoPPressure; #endif block_t *block; if(block_buffer_tail != block_buffer_head) { uint8_t block_index = block_buffer_tail; tail_fan_speed = block_buffer[block_index].fan_speed; #ifdef BARICUDA tail_valve_pressure = block_buffer[block_index].valve_pressure; tail_e_to_p_pressure = block_buffer[block_index].e_to_p_pressure; #endif while(block_index != block_buffer_head) { block = &block_buffer[block_index]; if(block->steps_x != 0) x_active++; if(block->steps_y != 0) y_active++; if(block->steps_z != 0) z_active++; if(block->steps_j != 0) j_active++; if(block->steps_e != 0) e_active++; block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1); } } if((DISABLE_X) && (x_active == 0)) disable_x(); if((DISABLE_Y) && (y_active == 0)) disable_y(); if((DISABLE_Z) && (z_active == 0)) disable_z(); if((DISABLE_J) && (j_active == 0)) disable_j(); if((DISABLE_E) && (e_active == 0)) { disable_e0(); disable_e1(); disable_e2(); } #if defined(FAN_PIN) && FAN_PIN > -1 #ifdef FAN_KICKSTART_TIME static unsigned long fan_kick_end; if (tail_fan_speed) { if (fan_kick_end == 0) { // Just starting up fan - run at full power. fan_kick_end = millis() + FAN_KICKSTART_TIME; tail_fan_speed = 255; } else if (fan_kick_end > millis()) // Fan still spinning up. tail_fan_speed = 255; } else { fan_kick_end = 0; } #endif//FAN_KICKSTART_TIME #ifdef FAN_SOFT_PWM fanSpeedSoftPwm = tail_fan_speed; #else analogWrite(FAN_PIN,tail_fan_speed); #endif//!FAN_SOFT_PWM #endif//FAN_PIN > -1 #ifdef AUTOTEMP getHighESpeed(); #endif #ifdef BARICUDA #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 analogWrite(HEATER_1_PIN,tail_valve_pressure); #endif #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 analogWrite(HEATER_2_PIN,tail_e_to_p_pressure); #endif #endif }
/** * Maintain fans, paste extruder pressure, */ void Planner::check_axes_activity() { unsigned char axis_active[NUM_AXIS] = { 0 }, tail_fan_speed[FAN_COUNT]; #if FAN_COUNT > 0 for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fanSpeeds[i]; #endif #if ENABLED(BARICUDA) unsigned char tail_valve_pressure = baricuda_valve_pressure, tail_e_to_p_pressure = baricuda_e_to_p_pressure; #endif if (blocks_queued()) { #if FAN_COUNT > 0 for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = block_buffer[block_buffer_tail].fan_speed[i]; #endif block_t* block; #if ENABLED(BARICUDA) block = &block_buffer[block_buffer_tail]; tail_valve_pressure = block->valve_pressure; tail_e_to_p_pressure = block->e_to_p_pressure; #endif for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { block = &block_buffer[b]; for (int i = 0; i < NUM_AXIS; i++) if (block->steps[i]) axis_active[i]++; } } #if ENABLED(DISABLE_X) if (!axis_active[X_AXIS]) disable_x(); #endif #if ENABLED(DISABLE_Y) if (!axis_active[Y_AXIS]) disable_y(); #endif #if ENABLED(DISABLE_Z) if (!axis_active[Z_AXIS]) disable_z(); #endif #if ENABLED(DISABLE_E) if (!axis_active[E_AXIS]) { disable_e0(); disable_e1(); disable_e2(); disable_e3(); } #endif #if FAN_COUNT > 0 #if defined(FAN_MIN_PWM) #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? ( FAN_MIN_PWM + (tail_fan_speed[f] * (255 - FAN_MIN_PWM)) / 255 ) : 0) #else #define CALC_FAN_SPEED(f) tail_fan_speed[f] #endif #ifdef FAN_KICKSTART_TIME static millis_t fan_kick_end[FAN_COUNT] = { 0 }; #define KICKSTART_FAN(f) \ if (tail_fan_speed[f]) { \ millis_t ms = millis(); \ if (fan_kick_end[f] == 0) { \ fan_kick_end[f] = ms + FAN_KICKSTART_TIME; \ tail_fan_speed[f] = 255; \ } else { \ if (PENDING(ms, fan_kick_end[f])) { \ tail_fan_speed[f] = 255; \ } \ } \ } else { \ fan_kick_end[f] = 0; \ } #if HAS_FAN0 KICKSTART_FAN(0); #endif #if HAS_FAN1 KICKSTART_FAN(1); #endif #if HAS_FAN2 KICKSTART_FAN(2); #endif #endif //FAN_KICKSTART_TIME #if ENABLED(FAN_SOFT_PWM) #if HAS_FAN0 thermalManager.fanSpeedSoftPwm[0] = CALC_FAN_SPEED(0); #endif #if HAS_FAN1 thermalManager.fanSpeedSoftPwm[1] = CALC_FAN_SPEED(1); #endif #if HAS_FAN2 thermalManager.fanSpeedSoftPwm[2] = CALC_FAN_SPEED(2); #endif #else #if HAS_FAN0 analogWrite(FAN_PIN, CALC_FAN_SPEED(0)); #endif #if HAS_FAN1 analogWrite(FAN1_PIN, CALC_FAN_SPEED(1)); #endif #if HAS_FAN2 analogWrite(FAN2_PIN, CALC_FAN_SPEED(2)); #endif #endif #endif // FAN_COUNT > 0 #if ENABLED(AUTOTEMP) getHighESpeed(); #endif #if ENABLED(BARICUDA) #if HAS_HEATER_1 analogWrite(HEATER_1_PIN, tail_valve_pressure); #endif #if HAS_HEATER_2 analogWrite(HEATER_2_PIN, tail_e_to_p_pressure); #endif #endif }
void check_axes_activity() { unsigned char axis_active[NUM_AXIS], tail_fan_speed = fanSpeed; #ifdef BARICUDA unsigned char tail_valve_pressure = ValvePressure, tail_e_to_p_pressure = EtoPPressure; #endif block_t *block; if (blocks_queued()) { uint8_t block_index = block_buffer_tail; tail_fan_speed = block_buffer[block_index].fan_speed; #ifdef BARICUDA block = &block_buffer[block_index]; tail_valve_pressure = block->valve_pressure; tail_e_to_p_pressure = block->e_to_p_pressure; #endif while (block_index != block_buffer_head) { block = &block_buffer[block_index]; for (int i=0; i<NUM_AXIS; i++) if (block->steps[i]) axis_active[i]++; block_index = next_block_index(block_index); } } if (DISABLE_X && !axis_active[X_AXIS]) disable_x(); if (DISABLE_Y && !axis_active[Y_AXIS]) disable_y(); if (DISABLE_Z && !axis_active[Z_AXIS]) disable_z(); if (DISABLE_E && !axis_active[E_AXIS]) { disable_e0(); disable_e1(); disable_e2(); disable_e3(); } #if defined(FAN_PIN) && FAN_PIN > -1 // HAS_FAN #ifdef FAN_KICKSTART_TIME static unsigned long fan_kick_end; if (tail_fan_speed) { if (fan_kick_end == 0) { // Just starting up fan - run at full power. fan_kick_end = millis() + FAN_KICKSTART_TIME; tail_fan_speed = 255; } else if (fan_kick_end > millis()) // Fan still spinning up. tail_fan_speed = 255; } else { fan_kick_end = 0; } #endif//FAN_KICKSTART_TIME #ifdef FAN_SOFT_PWM fanSpeedSoftPwm = tail_fan_speed; #else analogWrite(FAN_PIN, tail_fan_speed); #endif //!FAN_SOFT_PWM #endif //FAN_PIN > -1 #ifdef AUTOTEMP getHighESpeed(); #endif #ifdef BARICUDA #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 // HAS_HEATER_1 analogWrite(HEATER_1_PIN,tail_valve_pressure); #endif #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 // HAS_HEATER_2 analogWrite(HEATER_2_PIN,tail_e_to_p_pressure); #endif #endif }
void process_commands() { unsigned long codenum; //throw away variable if (code_seen('N')) { gcode_N = code_value_long(); if (gcode_N != gcode_LastN+1 && (strstr(cmdbuffer, "M110") == NULL) ) { gcode_LastN=0; pc.printf("ok"); //if(gcode_N != gcode_LastN+1 && !code_seen("M110") ) { //Hmm, compile size is different between using this vs the line above even though it should be the same thing. Keeping old method. //pc.printf("Serial Error: Line Number is not Last Line Number+1, Last Line:"); //pc.printf("%d\n",gcode_LastN); //FlushSerialRequestResend(); return; } if (code_seen('*')) { int checksum = 0; int count=0; while (cmdbuffer[count] != '*') checksum = checksum^cmdbuffer[count++]; if ( (int)code_value() != checksum) { //pc.printf("Error: checksum mismatch, Last Line:"); //pc.printf("%d\n",gcode_LastN); //FlushSerialRequestResend(); return; } //if no errors, continue parsing } else { //pc.printf("Error: No Checksum with line number, Last Line:"); //pc.printf("%d\n",gcode_LastN); //FlushSerialRequestResend(); return; } gcode_LastN = gcode_N; //if no errors, continue parsing } else { // if we don't receive 'N' but still see '*' if (code_seen('*')) { //pc.printf("Error: No Line Number with checksum, Last Line:"); //pc.printf("%d\n",gcode_LastN); return; } } //continues parsing only if we don't receive any 'N' or '*' or no errors if we do. :) if (code_seen('G')) { switch ((int)code_value()) { case 0: // G0 -> G1 case 1: // G1 reset_timers();//avoid timer overflow after 30 seconds get_coordinates(); // For X Y Z E F x_steps_to_take = abs(destination_x - current_x)*x_steps_per_unit; y_steps_to_take = abs(destination_y - current_y)*y_steps_per_unit; z_steps_to_take = abs(destination_z - current_z)*z_steps_per_unit; e_steps_to_take = abs(destination_e - current_e)*e_steps_per_unit; //printf(" x_steps_to_take:%d\n", x_steps_to_take); time_for_move = max(X_TIME_FOR_MOVE,Y_TIME_FOR_MOVE); time_for_move = max(time_for_move,Z_TIME_FOR_MOVE); time_for_move = max(time_for_move,E_TIME_FOR_MOVE); if (x_steps_to_take) x_interval = time_for_move/x_steps_to_take; if (y_steps_to_take) y_interval = time_for_move/y_steps_to_take; if (z_steps_to_take) z_interval = time_for_move/z_steps_to_take; if (e_steps_to_take) e_interval = time_for_move/e_steps_to_take; x_steps_remaining = x_steps_to_take; y_steps_remaining = y_steps_to_take; z_steps_remaining = z_steps_to_take; e_steps_remaining = e_steps_to_take; if (DEBUGGING) { pc.printf("destination_x: %f\n",destination_x); pc.printf("current_x: %f\n",current_x); pc.printf("x_steps_to_take: %d\n",x_steps_to_take); pc.printf("X_TIME_FOR_MOVE: %f\n",X_TIME_FOR_MOVE); pc.printf("x_interval: %f\n\n",x_interval); pc.printf("destination_y: %f\n",destination_y); pc.printf("current_y: %f\n",current_y); pc.printf("y_steps_to_take: %d\n",y_steps_to_take); pc.printf("Y_TIME_FOR_MOVE: %f\n",Y_TIME_FOR_MOVE); pc.printf("y_interval: %f\n\n",y_interval); pc.printf("destination_z: %f\n",destination_z); pc.printf("current_z: %f\n",current_z); pc.printf("z_steps_to_take: %d\n",z_steps_to_take); pc.printf("Z_TIME_FOR_MOVE: %f\n",Z_TIME_FOR_MOVE); pc.printf("z_interval: %f\n\n",z_interval); pc.printf("destination_e: %f\n",destination_e); pc.printf("current_e: %f\n",current_e); pc.printf("e_steps_to_take: %d\n",e_steps_to_take); pc.printf("E_TIME_FOR_MOVE: %f\n",E_TIME_FOR_MOVE); pc.printf("e_interval: %f\n\n",e_interval); } linear_move(); // make the move ClearToSend(); return; case 4: // G4 dwell codenum = 0; if (code_seen('P')) codenum = code_value(); // milliseconds to wait if (code_seen('S')) codenum = code_value()*1000; // seconds to wait previous_millis_heater = millis(); // keep track of when we started waiting while ((millis() - previous_millis_heater) < codenum ) manage_heater(); //manage heater until time is up break; case 90: // G90 relative_mode = false; break; case 91: // G91 relative_mode = true; break; case 92: // G92 if (code_seen('X')) current_x = code_value(); if (code_seen('Y')) current_y = code_value(); if (code_seen('Z')) current_z = code_value(); if (code_seen('E')) current_e = code_value(); break; case 93: // G93 pc.printf("previous_micros:%d\n", previous_micros); pc.printf("previous_micros_x:%d\n", previous_micros_x); pc.printf("previous_micros_y:%d\n", previous_micros_y); pc.printf("previous_micros_z:%d\n", previous_micros_z); break; } } if (code_seen('M')) { switch ( (int)code_value() ) { case 104: // M104 - set hot-end temp if (code_seen('S')) { target_raw = temp2analog(code_value()); //pc.printf("target_raw: %d\n ", target_raw); } break; case 140: // M140 - set heated-printbed temp if (code_seen('S')) { target_raw1 = temp2analog(code_value()); //pc.printf("target_raw1: %d\n ", target_raw); } break; case 105: // M105 pc.printf("ok T:"); if (TEMP_0_PIN != NC) { pc.printf("%f\n", analog2temp( (p_temp0.read_u16()) )); } else { pc.printf("0.0\n"); } if (!code_seen('N')) return; // If M105 is sent from generated gcode, then it needs a response. break; case 109: // M109 - Wait for heater to reach target. if (code_seen('S')) target_raw = temp2analog(code_value()); previous_millis_heater = millis(); while (current_raw < target_raw) { if ( (millis()-previous_millis_heater) > 1000 ) { //Print Temp Reading every 1 second while heating up. pc.printf("ok T:"); if (TEMP_0_PIN != NC) { pc.printf("%f\n", analog2temp(p_temp0.read_u16())); } else { pc.printf("0.0\n"); } previous_millis_heater = millis(); } manage_heater(); } break; case 106: //M106 Fan On p_fan = 1; break; case 107: //M107 Fan Off p_fan = 0; break; case 80: // M81 - ATX Power On //if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,OUTPUT); //GND break; case 81: // M81 - ATX Power Off //if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT); //Floating break; case 82: relative_mode_e = false; break; case 83: relative_mode_e = true; break; case 84: disable_x(); disable_y(); disable_z(); disable_e(); break; case 85: // M85 code_seen('S'); max_inactive_time = code_value()*1000; break; case 86: // M86 If Endstop is Not Activated then Abort Print if (code_seen('X')) { if (X_MIN_PIN != NC) { if ( p_X_min == ENDSTOPS_INVERTING ) { kill(3); } } } if (code_seen('Y')) { if (Y_MIN_PIN != NC) { if ( p_Y_min == ENDSTOPS_INVERTING ) { kill(4); } } } break; case 92: // M92 if (code_seen('X')) x_steps_per_unit = code_value(); if (code_seen('Y')) y_steps_per_unit = code_value(); if (code_seen('Z')) z_steps_per_unit = code_value(); if (code_seen('E')) e_steps_per_unit = code_value(); break; } } ClearToSend(); }
void linear_move() { // make linear move with preset speeds and destinations, see G0 and G1 //Determine direction of movement if (destination_x > current_x) { p_X_dir = !INVERT_X_DIR; } else { p_X_dir = INVERT_X_DIR; } if (destination_y > current_y) { p_Y_dir = !INVERT_Y_DIR; } else { p_Y_dir = INVERT_Y_DIR; } if (destination_z > current_z) { p_Z_dir = !INVERT_Z_DIR; } else { p_Z_dir = INVERT_Z_DIR; } if (destination_e > current_e) { p_E_dir = !INVERT_E_DIR; } else { p_E_dir = INVERT_E_DIR; } //Only enable axis that are moving. If the axis doesn't need to move then it can stay disabled depending on configuration. if (x_steps_remaining) enable_x(); if (y_steps_remaining) enable_y(); if (z_steps_remaining) enable_z(); if (e_steps_remaining) enable_e(); check_x_min_endstop(); check_y_min_endstop(); check_z_min_endstop(); previous_millis_heater = millis(); while (x_steps_remaining + y_steps_remaining + z_steps_remaining + e_steps_remaining > 0) { // move until no more steps remain if (x_steps_remaining>0) { if ((micros()-previous_micros_x) >= x_interval) { do_x_step(); x_steps_remaining--; } check_x_min_endstop(); led1 = 1; } else { led1 = 0; wait_us(2); } if (y_steps_remaining>0) { if ((micros()-previous_micros_y) >= y_interval) { do_y_step(); y_steps_remaining--; } check_y_min_endstop(); led2=1; } else { led2=0; wait_us(2); } if (z_steps_remaining>0) { if ((micros()-previous_micros_z) >= z_interval) { do_z_step(); z_steps_remaining--; } check_z_min_endstop(); led3=1; } else { led3=0; wait_us(2); } if (e_steps_remaining>0) { if ((micros()-previous_micros_e) >= e_interval) { do_e_step(); e_steps_remaining--; led4=1; } } else { led4=0; wait_us(2); } if ( (millis() - previous_millis_heater) >= 500 ) { manage_heater(); previous_millis_heater = millis(); manage_inactivity(2); } wait_us(2); } led1=0; led2=0; led3=0; led4=0; if (DISABLE_X) disable_x(); if (DISABLE_Y) disable_y(); if (DISABLE_Z) disable_z(); if (DISABLE_E) disable_e(); // Update current position partly based on direction, we probably can combine this with the direction code above... if (destination_x > current_x) current_x = current_x + x_steps_to_take/x_steps_per_unit; else current_x = current_x - x_steps_to_take/x_steps_per_unit; if (destination_y > current_y) current_y = current_y + y_steps_to_take/y_steps_per_unit; else current_y = current_y - y_steps_to_take/y_steps_per_unit; if (destination_z > current_z) current_z = current_z + z_steps_to_take/z_steps_per_unit; else current_z = current_z - z_steps_to_take/z_steps_per_unit; if (destination_e > current_e) current_e = current_e + e_steps_to_take/e_steps_per_unit; else current_e = current_e - e_steps_to_take/e_steps_per_unit; }