Преглед изворни кода

Update the filament axis resolution when E resolution is changed

The filament sensor "chunk lenght" needs to be updated every time the
E axis resolution is changed in order to trigger at the same distance.

Introduce a new function fsensor_set_axis_steps_per_unit() and use
it consistent during init, in M92 and M350.
Yuri D'Elia пре 4 година
родитељ
комит
d47363d85a
3 измењених фајлова са 13 додато и 3 уклоњено
  1. 4 2
      Firmware/Marlin_main.cpp
  2. 6 1
      Firmware/fsensor.cpp
  3. 3 0
      Firmware/fsensor.h

+ 4 - 2
Firmware/Marlin_main.cpp

@@ -6673,7 +6673,7 @@ Sigma_Exit:
       {
         if(code_seen(axis_codes[i]))
         {
-          if(i == 3) { // E
+          if(i == E_AXIS) { // E
             float value = code_value();
             if(value < 20.0) {
               float factor = cs.axis_steps_per_unit[i] / value; // increase e constants if M92 E14 is given for netfab.
@@ -6682,6 +6682,7 @@ Sigma_Exit:
               axis_steps_per_sqr_second[i] *= factor;
             }
             cs.axis_steps_per_unit[i] = value;
+            fsensor_set_axis_steps_per_unit(value);
           }
           else {
             cs.axis_steps_per_unit[i] = code_value();
@@ -8429,7 +8430,6 @@ Sigma_Exit:
 				res_valid |= (i == E_AXIS) && ((res_new == 64) || (res_new == 128)); // resolutions valid for E only
 				if (res_valid)
 				{
-					
 					st_synchronize();
 					uint16_t res = tmc2130_get_res(i);
 					tmc2130_set_res(i, res_new);
@@ -8446,6 +8446,8 @@ Sigma_Exit:
 						cs.axis_steps_per_unit[i] /= fac;
 						position[i] /= fac;
 					}
+                    if (i == E_AXIS)
+                        fsensor_set_axis_steps_per_unit(cs.axis_steps_per_unit[i]);
 				}
 			}
 		}

+ 6 - 1
Firmware/fsensor.cpp

@@ -149,6 +149,11 @@ void fsensor_checkpoint_print(void)
     restore_print_from_ram_and_continue(0);
 }
 
+void fsensor_set_axis_steps_per_unit(float u)
+{
+	fsensor_chunk_len = (int16_t)(FSENSOR_CHUNK_LEN * u);
+}
+
 void fsensor_init(void)
 {
 #ifdef PAT9125
@@ -161,7 +166,7 @@ void fsensor_init(void)
 #ifdef PAT9125
 	uint8_t oq_meassure_enabled = eeprom_read_byte((uint8_t*)EEPROM_FSENS_OQ_MEASS_ENABLED);
 	fsensor_oq_meassure_enabled = (oq_meassure_enabled == 1)?true:false;
-	fsensor_chunk_len = (int16_t)(FSENSOR_CHUNK_LEN * cs.axis_steps_per_unit[E_AXIS]);
+    fsensor_set_axis_steps_per_unit(cs.axis_steps_per_unit[E_AXIS]);
 
 	if (!pat9125)
 	{

+ 3 - 0
Firmware/fsensor.h

@@ -29,6 +29,9 @@ extern void fsensor_checkpoint_print(void);
 //! initialize
 extern void fsensor_init(void);
 
+//! update axis resolution
+extern void fsensor_set_axis_steps_per_unit(float u);
+
 //! @name enable/disable
 //! @{
 extern bool fsensor_enable(bool bUpdateEEPROM=true);