Bläddra i källkod

Merge pull request #245 from PavelSindler/lin_adv_issue

LIN_ADVANCE: high e_steps value error fixed
PavelSindler 7 år sedan
förälder
incheckning
98d0abcf2a
3 ändrade filer med 13 tillägg och 5 borttagningar
  1. 2 2
      Firmware/Marlin_main.cpp
  2. 6 0
      Firmware/planner.cpp
  3. 5 3
      Firmware/stepper.cpp

+ 2 - 2
Firmware/Marlin_main.cpp

@@ -5769,7 +5769,9 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
 
   else if(code_seen('T'))
   {
+	#ifdef SNMM
 	  int index;
+	  st_synchronize();
 	  for (index = 1; *(strchr_pointer + index) == ' ' || *(strchr_pointer + index) == '\t'; index++);
 	   
 	  if ((*(strchr_pointer + index) < '0' || *(strchr_pointer + index) > '9') && *(strchr_pointer + index) != '?') {
@@ -5783,7 +5785,6 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
 			  tmp_extruder = code_value();
 		  }
 		  snmm_filaments_used |= (1 << tmp_extruder); //for stop print
-#ifdef SNMM
       #ifdef LIN_ADVANCE
         if (snmm_extruder != tmp_extruder)
           clear_current_adv_vars(); //Check if the selected extruder is not the active one and reset LIN_ADVANCE variables if so.
@@ -5791,7 +5792,6 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
       
       snmm_extruder = tmp_extruder;
 
-		  st_synchronize();
 		  delay(100);
 
 		  disable_e0();

+ 6 - 0
Firmware/planner.cpp

@@ -1288,12 +1288,18 @@ void plan_set_position(float x, float y, float z, const float &e)
 // Only useful in the bed leveling routine, when the mesh bed leveling is off.
 void plan_set_z_position(const float &z)
 {
+    #ifdef LIN_ADVANCE
+	position_float[Z_AXIS] = z;
+    #endif
     position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
     st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]);
 }
 
 void plan_set_e_position(const float &e)
 {
+  #ifdef LIN_ADVANCE
+  position_float[E_AXIS] = e;
+  #endif
   position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);  
   st_set_e_position(position[E_AXIS]);
 }

+ 5 - 3
Firmware/stepper.cpp

@@ -735,8 +735,6 @@ void isr() {
 
   void advance_isr() {
 
-    nextAdvanceISR = eISR_Rate;
-
     if (e_steps) {
       bool dir =
       #ifdef SNMM
@@ -752,7 +750,11 @@ void isr() {
         e_steps < 0 ? ++e_steps : --e_steps;
         WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
       }
-    }
+	}
+	else{
+		eISR_Rate = ADV_NEVER;
+	}
+	nextAdvanceISR = eISR_Rate;
   }
 
   void advance_isr_scheduler() {