Forráskód Böngészése

Merge pull request #942 from XPila/MK3-new_lang

LCD menu + fsensor + tmc2130 speed/accel limitation
PavelSindler 5 éve
szülő
commit
fbd586ff87

+ 42 - 16
Firmware/ConfigurationStore.cpp

@@ -56,8 +56,8 @@ void Config_StoreSettings(uint16_t offset, uint8_t level)
   int i = offset;
   EEPROM_WRITE_VAR(i,ver); // invalidate data first 
   EEPROM_WRITE_VAR(i,axis_steps_per_unit);
-  EEPROM_WRITE_VAR(i,max_feedrate);  
-  EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second);
+  EEPROM_WRITE_VAR(i,max_feedrate_normal);
+  EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second_normal);
   EEPROM_WRITE_VAR(i,acceleration);
   EEPROM_WRITE_VAR(i,retract_acceleration);
   EEPROM_WRITE_VAR(i,minimumfeedrate);
@@ -126,12 +126,9 @@ void Config_StoreSettings(uint16_t offset, uint8_t level)
   }
 #endif //LIN_ADVANCE
 
-/*  MYSERIAL.print("Top address used:\n");
-  MYSERIAL.print(i); 
-  MYSERIAL.print("; (0x");
-  MYSERIAL.print(i, HEX);
-  MYSERIAL.println(")");
-*/ 
+  EEPROM_WRITE_VAR(i,max_feedrate_silent);
+  EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second_silent);
+
   char ver2[4]=EEPROM_VERSION;
   i=offset;
   EEPROM_WRITE_VAR(i,ver2); // validate data
@@ -144,10 +141,30 @@ void Config_StoreSettings(uint16_t offset, uint8_t level)
 #ifndef DISABLE_M503
 void Config_PrintSettings(uint8_t level)
 {  // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
+#ifdef TMC2130
+	printf_P(PSTR(
+		"%SSteps per unit:\n%S  M92 X%.2f Y%.2f Z%.2f E%.2f\n"
+		"%SMaximum feedrates - normal (mm/s):\n%S  M203 X%.2f Y%.2f Z%.2f E%.2f\n"
+		"%SMaximum feedrates - stealth (mm/s):\n%S  M203 X%.2f Y%.2f Z%.2f E%.2f\n"
+		"%SMaximum acceleration - normal (mm/s2):\n%S  M201 X%lu Y%lu Z%lu E%lu\n"
+		"%SMaximum acceleration - stealth (mm/s2):\n%S  M201 X%lu Y%lu Z%lu E%lu\n"
+		"%SAcceleration: S=acceleration, T=retract acceleration\n%S  M204 S%.2f T%.2f\n"
+		"%SAdvanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s),  Z=maximum Z jerk (mm/s),  E=maximum E jerk (mm/s)\n%S  M205 S%.2f T%.2f B%.2f X%.2f Y%.2f Z%.2f E%.2f\n"
+		"%SHome offset (mm):\n%S  M206 X%.2f Y%.2f Z%.2f\n"
+		),
+		echomagic, echomagic, axis_steps_per_unit[X_AXIS], axis_steps_per_unit[Y_AXIS], axis_steps_per_unit[Z_AXIS], axis_steps_per_unit[E_AXIS],
+		echomagic, echomagic, max_feedrate_normal[X_AXIS], max_feedrate_normal[Y_AXIS], max_feedrate_normal[Z_AXIS], max_feedrate_normal[E_AXIS],
+		echomagic, echomagic, max_feedrate_silent[X_AXIS], max_feedrate_silent[Y_AXIS], max_feedrate_silent[Z_AXIS], max_feedrate_silent[E_AXIS],
+		echomagic, echomagic, max_acceleration_units_per_sq_second_normal[X_AXIS], max_acceleration_units_per_sq_second_normal[Y_AXIS], max_acceleration_units_per_sq_second_normal[Z_AXIS], max_acceleration_units_per_sq_second_normal[E_AXIS],
+		echomagic, echomagic, max_acceleration_units_per_sq_second_silent[X_AXIS], max_acceleration_units_per_sq_second_silent[Y_AXIS], max_acceleration_units_per_sq_second_silent[Z_AXIS], max_acceleration_units_per_sq_second_silent[E_AXIS],
+		echomagic, echomagic, acceleration, retract_acceleration,
+		echomagic, echomagic, minimumfeedrate, mintravelfeedrate, minsegmenttime, max_jerk[X_AXIS], max_jerk[Y_AXIS], max_jerk[Z_AXIS], max_jerk[E_AXIS],
+		echomagic, echomagic, add_homing[X_AXIS], add_homing[Y_AXIS], add_homing[Z_AXIS]
+#else //TMC2130
 	printf_P(PSTR(
 		"%SSteps per unit:\n%S  M92 X%.2f Y%.2f Z%.2f E%.2f\n"
 		"%SMaximum feedrates (mm/s):\n%S  M203 X%.2f Y%.2f Z%.2f E%.2f\n"
-		"%SMaximum Acceleration (mm/s2):\n%S  M201 X%.2f Y%.2f Z%.2f E%.2f\n"
+		"%SMaximum acceleration (mm/s2):\n%S  M201 X%lu Y%lu Z%lu E%lu\n"
 		"%SAcceleration: S=acceleration, T=retract acceleration\n%S  M204 S%.2f T%.2f\n"
 		"%SAdvanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s),  Z=maximum Z jerk (mm/s),  E=maximum E jerk (mm/s)\n%S  M205 S%.2f T%.2f B%.2f X%.2f Y%.2f Z%.2f E%.2f\n"
 		"%SHome offset (mm):\n%S  M206 X%.2f Y%.2f Z%.2f\n"
@@ -158,6 +175,7 @@ void Config_PrintSettings(uint8_t level)
 		echomagic, echomagic, acceleration, retract_acceleration,
 		echomagic, echomagic, minimumfeedrate, mintravelfeedrate, minsegmenttime, max_jerk[X_AXIS], max_jerk[Y_AXIS], max_jerk[Z_AXIS], max_jerk[E_AXIS],
 		echomagic, echomagic, add_homing[X_AXIS], add_homing[Y_AXIS], add_homing[Z_AXIS]
+#endif //TMC2130
 	);
 #ifdef PIDTEMP
 	printf_P(PSTR("%SPID settings:\n%S   M301 P%.2f I%.2f D%.2f\n"),
@@ -219,11 +237,10 @@ bool Config_RetrieveSettings(uint16_t offset, uint8_t level)
     {
         // version number match
         EEPROM_READ_VAR(i,axis_steps_per_unit);
-        EEPROM_READ_VAR(i,max_feedrate);  
-        EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second);
+        EEPROM_READ_VAR(i,max_feedrate_normal);
+        EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second_normal);
         
         // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
-		reset_acceleration_rates();
         
         EEPROM_READ_VAR(i,acceleration);
         EEPROM_READ_VAR(i,retract_acceleration);
@@ -293,6 +310,11 @@ bool Config_RetrieveSettings(uint16_t offset, uint8_t level)
 #endif //LIN_ADVANCE
     calculate_extruder_multipliers();
 
+        EEPROM_READ_VAR(i,max_feedrate_silent);  
+        EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second_silent);
+
+		reset_acceleration_rates();
+
 		// Call updatePID (similar to when we have processed M301)
 		updatePID();
         SERIAL_ECHO_START;
@@ -321,14 +343,18 @@ void Config_ResetDefault()
     float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
     float tmp2[]=DEFAULT_MAX_FEEDRATE;
     long tmp3[]=DEFAULT_MAX_ACCELERATION;
+    float tmp4[]=DEFAULT_MAX_FEEDRATE_SILENT;
+    long tmp5[]=DEFAULT_MAX_ACCELERATION_SILENT;
     for (short i=0;i<4;i++) 
     {
         axis_steps_per_unit[i]=tmp1[i];  
-        max_feedrate[i]=tmp2[i];  
-        max_acceleration_units_per_sq_second[i]=tmp3[i];
+        max_feedrate_normal[i]=tmp2[i];  
+        max_acceleration_units_per_sq_second_normal[i]=tmp3[i];
+        max_feedrate_silent[i]=tmp4[i];  
+        max_acceleration_units_per_sq_second_silent[i]=tmp5[i];
     }
-    
-    // steps per sq second need to be updated to agree with the units per sq second
+
+	// steps per sq second need to be updated to agree with the units per sq second
     reset_acceleration_rates();
     
     acceleration=DEFAULT_ACCELERATION;

+ 69 - 28
Firmware/Marlin_main.cpp

@@ -484,9 +484,7 @@ static float feedrate = 1500.0, next_feedrate, saved_feedrate;
 // Also there is bool axis_relative_modes[] per axis flag.
 static bool relative_mode = false;  
 
-#ifndef _DISABLE_M42_M226
 const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
-#endif //_DISABLE_M42_M226
 
 //static float tt = 0;
 //static float bt = 0;
@@ -858,7 +856,7 @@ void factory_reset(char level, bool quiet)
             eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0);
 
             fsensor_enable();
-            fautoload_set(true);
+            fsensor_autoload_set(true);
                        
             WRITE(BEEPER, HIGH);
             _delay_ms(100);
@@ -1378,7 +1376,6 @@ void setup()
 #ifdef TMC2130
 	uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
 	if (silentMode == 0xff) silentMode = 0;
-//	tmc2130_mode = silentMode?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
 	tmc2130_mode = TMC2130_MODE_NORMAL;
 	uint8_t crashdet = eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET);
 	if (crashdet && !farm_mode)
@@ -1432,6 +1429,7 @@ void setup()
 
 #ifdef TMC2130
 	tmc2130_mode = silentMode?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
+	update_mode_profile();
 	tmc2130_init();
 #endif //TMC2130
     
@@ -2600,6 +2598,7 @@ void force_high_power_mode(bool start_high_power_section) {
 		st_synchronize();
 		cli();
 		tmc2130_mode = (start_high_power_section == true) ? TMC2130_MODE_NORMAL : TMC2130_MODE_SILENT;
+		update_mode_profile();
 		tmc2130_init();
     // We may have missed a stepper timer interrupt due to the time spent in the tmc2130_init() routine.
     // Be safe than sorry, reset the stepper timer before re-enabling interrupts.
@@ -3108,6 +3107,8 @@ void gcode_M114()
 
 void gcode_M701()
 {
+	printf_P(PSTR("gcode_M701 begin\n"));
+
 #if defined (SNMM) || defined (SNMM_V2)
 	extr_adj(snmm_extruder);//loads current extruder
 #else
@@ -3115,7 +3116,13 @@ void gcode_M701()
 	custom_message = true;
 	custom_message_type = 2;
 
-	
+	bool old_watch_runout = fsensor_watch_runout;
+	fsensor_watch_runout = false;
+	fsensor_st_sum = 0;
+	fsensor_yd_sum = 0;
+	fsensor_er_sum = 0;
+	fsensor_yd_min = 255;
+	fsensor_yd_max = 0;
 
 	lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT));
 	current_position[E_AXIS] += 40;
@@ -3157,6 +3164,11 @@ void gcode_M701()
 	custom_message_type = 0;
 #endif
 
+	fsensor_err_cnt = 0;
+	fsensor_watch_runout = old_watch_runout;
+	printf_P(_N("\nFSENSOR st_sum=%lu yd_sum=%lu er_sum=%lu\n"), fsensor_st_sum, fsensor_yd_sum, fsensor_er_sum);
+	printf_P(_N("\nFSENSOR yd_min=%hhu yd_max=%hhu yd_avg=%hhu\n"), fsensor_yd_min, fsensor_yd_max, fsensor_yd_sum * FSENSOR_CHUNK_LEN / fsensor_st_sum);
+	printf_P(PSTR("gcode_M701 end\n"));
 }
 /**
  * @brief Get serial number from 32U2 processor
@@ -4870,7 +4882,6 @@ void process_commands()
       autotempShutdown();
       }
       break;
-#ifndef _DISABLE_M42_M226
     case 42: //M42 -Change pin status via gcode
       if (code_seen('S'))
       {
@@ -4898,7 +4909,6 @@ void process_commands()
         }
       }
      break;
-#endif //_DISABLE_M42_M226
     case 44: // M44: Prusa3D: Reset the bed skew and offset calibration.
 
 		// Reset the baby step value and the baby step applied flag.
@@ -5764,16 +5774,29 @@ Sigma_Exit:
       }
       break;
     case 201: // M201
-      for(int8_t i=0; i < NUM_AXIS; i++)
-      {
-        if(code_seen(axis_codes[i]))
-        {
-          max_acceleration_units_per_sq_second[i] = code_value();
-        }
-      }
-      // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
-      reset_acceleration_rates();
-      break;
+		for (int8_t i = 0; i < NUM_AXIS; i++)
+		{
+			if (code_seen(axis_codes[i]))
+			{
+				int val = code_value();
+#ifdef TMC2130
+				if ((i == X_AXIS) || (i == Y_AXIS))
+				{
+					int max_val = 0;
+					if (tmc2130_mode == TMC2130_MODE_NORMAL)
+						max_val = NORMAL_MAX_ACCEL_XY;
+					else if (tmc2130_mode == TMC2130_MODE_SILENT)
+						max_val = SILENT_MAX_ACCEL_XY;
+					if (val > max_val)
+						val = max_val;
+				}
+#endif
+				max_acceleration_units_per_sq_second[i] = val;
+			}
+		}
+		// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
+		reset_acceleration_rates();
+		break;
     #if 0 // Not used for Sprinter/grbl gen6
     case 202: // M202
       for(int8_t i=0; i < NUM_AXIS; i++) {
@@ -5782,10 +5805,27 @@ Sigma_Exit:
       break;
     #endif
     case 203: // M203 max feedrate mm/sec
-      for(int8_t i=0; i < NUM_AXIS; i++) {
-        if(code_seen(axis_codes[i])) max_feedrate[i] = code_value();
-      }
-      break;
+		for (int8_t i = 0; i < NUM_AXIS; i++)
+		{
+			if (code_seen(axis_codes[i]))
+			{
+				float val = code_value();
+#ifdef TMC2130
+				if ((i == X_AXIS) || (i == Y_AXIS))
+				{
+					float max_val = 0;
+					if (tmc2130_mode == TMC2130_MODE_NORMAL)
+						max_val = NORMAL_MAX_FEEDRATE_XY;
+					else if (tmc2130_mode == TMC2130_MODE_SILENT)
+						max_val = SILENT_MAX_FEEDRATE_XY;
+					if (val > max_val)
+						val = max_val;
+				}
+#endif //TMC2130
+				max_feedrate[i] = val;
+			}
+		}
+		break;
     case 204: // M204 acclereration S normal moves T filmanent only moves
       {
         if(code_seen('S')) acceleration = code_value() ;
@@ -5932,7 +5972,6 @@ Sigma_Exit:
     }
     break;
 
-#ifndef _DISABLE_M42_M226
 	case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
 	{
       if(code_seen('P')){
@@ -5984,7 +6023,6 @@ Sigma_Exit:
       }
     }
     break;
-#endif //_DISABLE_M42_M226
 
     #if NUM_SERVOS > 0
     case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
@@ -6518,15 +6556,14 @@ Sigma_Exit:
 		KEEPALIVE_STATE(PAUSED_FOR_USER);
 
 #ifdef PAT9125
-		if (filament_autoload_enabled && (old_fsensor_enabled || fsensor_M600)) fsensor_autoload_check_start();
+		if (filament_autoload_enabled && (old_fsensor_enabled || !fsensor_watch_runout)) fsensor_autoload_check_start();
 #endif //PAT9125
-//		  printf_P(PSTR("M600 PAT9125 filament_autoload_enabled=%d, old_fsensor_enabled=%d, fsensor_M600=%d"), filament_autoload_enabled, old_fsensor_enabled, fsensor_M600);
         while(!lcd_clicked())
 		{
           manage_heater();
           manage_inactivity(true);
 #ifdef PAT9125
-		  if (filament_autoload_enabled && (old_fsensor_enabled || fsensor_M600) && fsensor_check_autoload())
+		  if (filament_autoload_enabled && (old_fsensor_enabled || !fsensor_watch_runout) && fsensor_check_autoload())
 		  {
 			tone(BEEPER, 1000);
 			delay_keep_alive(50);
@@ -6542,7 +6579,7 @@ Sigma_Exit:
 
         }
 #ifdef PAT9125
-		if (filament_autoload_enabled && (old_fsensor_enabled || fsensor_M600)) fsensor_autoload_check_stop();
+		if (filament_autoload_enabled && (old_fsensor_enabled || !fsensor_watch_runout)) fsensor_autoload_check_stop();
 #endif //PAT9125
 		//WRITE(BEEPER, LOW);
 		KEEPALIVE_STATE(IN_HANDLER);
@@ -6692,6 +6729,7 @@ Sigma_Exit:
 	  custom_message_type = 0;
 
 #ifdef PAT9125
+/*
 //      fsensor_enabled = old_fsensor_enabled; //temporary solution for unexpected restarting
 
 	  if (fsensor_M600)
@@ -6708,6 +6746,7 @@ Sigma_Exit:
 		fsensor_restore_print_and_continue();
 	  }
 	fsensor_M600 = false;
+*/
 #endif //PAT9125
         
     }
@@ -6910,6 +6949,7 @@ Sigma_Exit:
 	case 914: // M914 Set normal mode
     {
 		tmc2130_mode = TMC2130_MODE_NORMAL;
+		update_mode_profile();
 		tmc2130_init();
     }
     break;
@@ -6917,6 +6957,7 @@ Sigma_Exit:
 	case 915: // M915 Set silent mode
     {
 		tmc2130_mode = TMC2130_MODE_SILENT;
+		update_mode_profile();
 		tmc2130_init();
     }
     break;
@@ -7632,7 +7673,7 @@ static void handleSafetyTimer()
 void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h
 {
 #ifdef PAT9125
-	if (fsensor_enabled && filament_autoload_enabled && !fsensor_M600 && !moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL))
+	if (fsensor_enabled && filament_autoload_enabled && fsensor_watch_runout && !moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL))
 	{
 		if (fsensor_autoload_enabled)
 		{

+ 40 - 41
Firmware/fsensor.cpp

@@ -16,8 +16,6 @@ const char ERRMSG_PAT9125_NOT_RESP[] PROGMEM = "PAT9125 not responding (%d)!\n";
 #define FSENSOR_ERR_MAX         10  //filament sensor max error count
 #define FSENSOR_INT_PIN         63  //filament sensor interrupt pin PK1
 #define FSENSOR_INT_PIN_MSK   0x02  //filament sensor interrupt pin mask (bit1)
-//#define FSENSOR_CHUNK_LEN      280  //filament sensor chunk length in steps - 1mm
-#define FSENSOR_CHUNK_LEN      180  //filament sensor chunk length in steps - 0.64mm
 
 extern void stop_and_save_print_to_ram(float z_move, float e_move);
 extern void restore_print_from_ram_and_continue(float e_move);
@@ -36,11 +34,15 @@ void fsensor_restore_print_and_continue()
 //uint8_t fsensor_int_pin = FSENSOR_INT_PIN;
 uint8_t fsensor_int_pin_old = 0;
 int16_t fsensor_chunk_len = FSENSOR_CHUNK_LEN;
+
 bool fsensor_enabled = true;
+bool fsensor_watch_runout = true;
 bool fsensor_not_responding = false;
-bool fsensor_M600 = false;
+
 uint8_t fsensor_err_cnt = 0;
 int16_t fsensor_st_cnt = 0;
+
+
 uint8_t fsensor_log = 1;
 
 //autoload enable/disable flag
@@ -53,15 +55,8 @@ uint8_t fsensor_autoload_sum = 0;
 uint32_t fsensor_st_sum = 0;
 uint32_t fsensor_yd_sum = 0;
 uint32_t fsensor_er_sum = 0;
-
-void fsensor_block()
-{
-	fsensor_enabled = false;
-}
-
-void fsensor_unblock() {
-	fsensor_enabled = (eeprom_read_byte((uint8_t*)EEPROM_FSENSOR) == 0x01);
-}
+uint8_t fsensor_yd_min = 255;
+uint8_t fsensor_yd_max = 0;
 
 bool fsensor_enable()
 {
@@ -73,7 +68,7 @@ bool fsensor_enable()
 	else
 		fsensor_not_responding = true;
 	fsensor_enabled = pat9125?true:false;
-	fsensor_M600 = false;
+	fsensor_watch_runout = true;
 	fsensor_err_cnt = 0;
 	eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, fsensor_enabled?0x01:0x00); 
 	FSensorStateMenu = fsensor_enabled?1:0;
@@ -94,7 +89,7 @@ void fsensor_disable()
 	FSensorStateMenu = 0;
 }
 
-void fautoload_set(bool State)
+void fsensor_autoload_set(bool State)
 {
 	filament_autoload_enabled = State;
 	eeprom_update_byte((unsigned char *)EEPROM_FSENS_AUTOLOAD_ENABLED, filament_autoload_enabled);
@@ -211,9 +206,14 @@ ISR(PCINT2_vect)
 			{
 				if (fsensor_err_cnt)
 					fsensor_err_cnt--;
-				fsensor_st_sum += st_cnt;
-				fsensor_yd_sum += pat9125_y;
+				if (st_cnt == FSENSOR_CHUNK_LEN)
+				{
+					if (fsensor_yd_min > pat9125_y) fsensor_yd_min = pat9125_y;
+					if (fsensor_yd_max < pat9125_y) fsensor_yd_max = pat9125_y;
+				}
 			}
+			fsensor_st_sum += st_cnt;
+			fsensor_yd_sum += pat9125_y;
 		}
 		else //negative movement
 		{
@@ -264,36 +264,35 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
 
 void fsensor_update()
 {
-	if (!fsensor_enabled || fsensor_M600) return;
-	if (fsensor_err_cnt > FSENSOR_ERR_MAX)
-	{
-		fsensor_stop_and_save_print();
+	if (fsensor_enabled && fsensor_watch_runout)
+		if (fsensor_err_cnt > FSENSOR_ERR_MAX)
+		{
+			fsensor_stop_and_save_print();
 
-		fsensor_err_cnt = 0;
+			fsensor_err_cnt = 0;
 
-		enquecommand_front_P((PSTR("G1 E-3 F200")));
-		process_commands();
-	    cmdqueue_pop_front();
-		st_synchronize();
+			enquecommand_front_P((PSTR("G1 E-3 F200")));
+			process_commands();
+			cmdqueue_pop_front();
+			st_synchronize();
 
-		enquecommand_front_P((PSTR("G1 E3 F200")));
-		process_commands();
-	    cmdqueue_pop_front();
-		st_synchronize();
+			enquecommand_front_P((PSTR("G1 E3 F200")));
+			process_commands();
+			cmdqueue_pop_front();
+			st_synchronize();
 
-		if (fsensor_err_cnt == 0)
-		{
-			fsensor_restore_print_and_continue();
-		}
-		else
-		{
-			eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
-			eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
-			enquecommand_front_P((PSTR("M600")));
-			fsensor_M600 = true;
-//			fsensor_enabled = false;
+			if (fsensor_err_cnt == 0)
+			{
+				fsensor_restore_print_and_continue();
+			}
+			else
+			{
+				eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
+				eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
+				enquecommand_front_P((PSTR("M600")));
+				fsensor_watch_runout = false;
+			}
 		}
-	}
 }
 
 #endif //PAT9125

+ 14 - 7
Firmware/fsensor.h

@@ -3,20 +3,19 @@
 
 #include "planner.h"
 
+//#define FSENSOR_CHUNK_LEN      280  //filament sensor chunk length in steps - 1mm
+#define FSENSOR_CHUNK_LEN      180  //filament sensor chunk length in steps - 0.64mm
+
 //save restore printing
 extern void fsensor_stop_and_save_print();
 extern void fsensor_restore_print_and_continue();
 
-//temporarily enable/disable without writing to eeprom
-extern void fsensor_block();
-extern void fsensor_unblock();
-
 //enable/disable
 extern bool fsensor_enable();
 extern void fsensor_disable();
 
 extern bool filament_autoload_enabled;
-extern void fautoload_set(bool State);
+extern void fsensor_autoload_set(bool State);
 
 //update (perform M600 on filament runout)
 extern void fsensor_update();
@@ -39,15 +38,23 @@ extern void fsensor_st_block_chunk(block_t* bl, int cnt);
 
 //minimum meassured chunk length in steps
 extern int16_t fsensor_chunk_len;
-//M600 in progress
-extern bool fsensor_M600;
 //enable/disable flag
 extern bool fsensor_enabled;
+//watch runout flag
+extern bool fsensor_watch_runout;
 //not responding flag
 extern bool fsensor_not_responding;
 
+extern uint8_t fsensor_err_cnt;
+
 //autoload enable/disable flag
 extern bool fsensor_autoload_enabled;
 
 
+extern uint32_t fsensor_st_sum;
+extern uint32_t fsensor_yd_sum;
+extern uint32_t fsensor_er_sum;
+extern uint8_t fsensor_yd_min;
+extern uint8_t fsensor_yd_max;
+
 #endif //FSENSOR_H

+ 0 - 38
Firmware/lcd.cpp

@@ -844,44 +844,6 @@ void lcd_buttons_update(void)
 }
 
 
-
-
-
-
-
-
-
-
-
-
-void lcd_drawedit(const char* pstr, char* value)
-{
-    lcd_set_cursor(1, 1);
-    lcd_puts_P(pstr);
-    lcd_print(':');
-   #if LCD_WIDTH < 20
-      lcd_set_cursor(LCD_WIDTH - strlen(value), 1);
-    #else
-      lcd_set_cursor(LCD_WIDTH -1 - strlen(value), 1);
-   #endif
-    lcd_print(value);
-}
-
-void lcd_drawedit_2(const char* pstr, char* value)
-{
-    lcd_set_cursor(0, 1);
-    lcd_puts_P(pstr);
-    lcd_print(':');
-
-    lcd_set_cursor((LCD_WIDTH - strlen(value))/2, 3);
-
-    lcd_print(value);
-    lcd_print(" mm");
-}
-
-
-
-
 ////////////////////////////////////////////////////////////////////////////////
 // Custom character data
 

+ 0 - 2
Firmware/lcd.h

@@ -217,8 +217,6 @@ extern void lcd_set_custom_characters_progress(void);
 extern void lcd_set_custom_characters_nextpage(void);
 extern void lcd_set_custom_characters_degree(void);
 
-extern void lcd_drawedit(const char* pstr, char* value);
-extern void lcd_drawedit_2(const char* pstr, char* value);
 
 
 #endif //_LCD_H

+ 14 - 0
Firmware/menu.cpp

@@ -225,7 +225,11 @@ uint8_t menu_item_gcode_P(const char* str, const char* str_gcode)
 }
 
 const char menu_20x_space[] PROGMEM = "                    ";
+
 const char menu_fmt_int3[] PROGMEM = "%c%.15S:%s%3d";
+
+const char menu_fmt_float31[] PROGMEM = "%c%.12S:%s%+06.3f";
+
 void menu_draw_int3(char chr, const char* str, int16_t val)
 {
 	int text_len = strlen_P(str);
@@ -236,6 +240,15 @@ void menu_draw_int3(char chr, const char* str, int16_t val)
 	lcd_printf_P(menu_fmt_int3, chr, str, spaces, val);
 }
 
+void menu_draw_float31(char chr, const char* str, float val)
+{
+	int text_len = strlen_P(str);
+	if (text_len > 12) text_len = 12;
+	char spaces[21];
+	strcpy_P(spaces, menu_20x_space);
+	spaces[12 - text_len] = 0;
+	lcd_printf_P(menu_fmt_float31, chr, str, spaces, val);
+}
 
 #define _menu_data (*((menu_data_edit_t*)menu_data))
 void _menu_edit_int3(void)
@@ -277,6 +290,7 @@ uint8_t menu_item_edit_int3(const char* str, int16_t* pval, int16_t min_val, int
 	menu_item++;
 	return 0;
 }
+
 #undef _menu_data
 
 

+ 8 - 0
Firmware/menu.h

@@ -89,7 +89,15 @@ extern uint8_t menu_item_gcode_P(const char* str, const char* str_gcode);
 
 
 extern const char menu_fmt_int3[];
+
+extern const char menu_fmt_float31[];
+
+extern void menu_draw_int3(char chr, const char* str, int16_t val);
+
+extern void menu_draw_float31(char chr, const char* str, float val);
+
 extern void _menu_edit_int3(void);
+
 #define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) do { if (menu_item_edit_int3(str, pval, minval, maxval)) return; } while (0)
 //#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) MENU_ITEM_EDIT(int3, str, pval, minval, maxval)
 extern uint8_t menu_item_edit_int3(const char* str, int16_t* pval, int16_t min_val, int16_t max_val);

+ 34 - 70
Firmware/planner.cpp

@@ -72,9 +72,20 @@
 //===========================================================================
 
 unsigned long minsegmenttime;
-float max_feedrate[NUM_AXIS]; // set the max speeds
+
+// Use M203 to override by software
+float max_feedrate_normal[NUM_AXIS];       // max speeds for normal mode
+float max_feedrate_silent[NUM_AXIS];       // max speeds for silent mode
+float* max_feedrate = max_feedrate_normal;
+
+// Use M92 to override by software
 float axis_steps_per_unit[NUM_AXIS];
-unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
+
+// Use M201 to override by software
+unsigned long max_acceleration_units_per_sq_second_normal[NUM_AXIS];
+unsigned long max_acceleration_units_per_sq_second_silent[NUM_AXIS];
+unsigned long* max_acceleration_units_per_sq_second = max_acceleration_units_per_sq_second_normal;
+
 float minimumfeedrate;
 float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
 float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX
@@ -953,32 +964,8 @@ Having the real displacement of the head, we can calculate the total movement le
   for(int i=0; i < 4; i++)
   {
     current_speed[i] = delta_mm[i] * inverse_second;
-#ifdef TMC2130
-#ifdef FEEDRATE_LIMIT
-	float max_fr = max_feedrate[i];
-	if (i < 2) // X, Y
-	{
-		if (tmc2130_mode == TMC2130_MODE_SILENT)
-		{
-			if (max_fr > SILENT_MAX_FEEDRATE)
-				max_fr = SILENT_MAX_FEEDRATE;
-		}
-		else
-		{
-			if (max_fr > NORMAL_MAX_FEEDRATE)
-				max_fr = NORMAL_MAX_FEEDRATE;
-		}
-	}
-    if(fabs(current_speed[i]) > max_fr)
-      speed_factor = min(speed_factor, max_fr / fabs(current_speed[i]));
-#else //FEEDRATE_LIMIT
-    if(fabs(current_speed[i]) > max_feedrate[i])
-      speed_factor = min(speed_factor, max_feedrate[i] / fabs(current_speed[i]));
-#endif //FEEDRATE_LIMIT
-#else //TMC2130
-    if(fabs(current_speed[i]) > max_feedrate[i])
+	if(fabs(current_speed[i]) > max_feedrate[i])
       speed_factor = min(speed_factor, max_feedrate[i] / fabs(current_speed[i]));
-#endif //TMC2130
   }
 
   // Correct the speed  
@@ -1003,45 +990,6 @@ Having the real displacement of the head, we can calculate the total movement le
   else
   {
     block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
-#ifdef TMC2130
-#ifdef SIMPLE_ACCEL_LIMIT // in some cases can be acceleration limited inproperly
-	if (tmc2130_mode == TMC2130_MODE_SILENT)
-	{
-		if (block->steps_x.wide || block->steps_y.wide)
-			if (block->acceleration_st > SILENT_MAX_ACCEL_ST) block->acceleration_st = SILENT_MAX_ACCEL_ST;
-	}
-	else
-	{
-		if (block->steps_x.wide || block->steps_y.wide)
-			if (block->acceleration_st > NORMAL_MAX_ACCEL_ST) block->acceleration_st = NORMAL_MAX_ACCEL_ST;
-	}
-	if (block->steps_x.wide && (block->acceleration_st > axis_steps_per_sqr_second[X_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
-	if (block->steps_y.wide && (block->acceleration_st > axis_steps_per_sqr_second[Y_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
-	if (block->steps_z.wide && (block->acceleration_st > axis_steps_per_sqr_second[Z_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
-	if (block->steps_e.wide && (block->acceleration_st > axis_steps_per_sqr_second[E_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
-#else // SIMPLE_ACCEL_LIMIT
-#ifdef ACCEL_LIMIT
-	if (tmc2130_mode == TMC2130_MODE_SILENT)
-	{
-		if ((block->steps_x.wide > block->step_event_count.wide / 2) || (block->steps_y.wide > block->step_event_count.wide / 2))
-			if (block->acceleration_st > SILENT_MAX_ACCEL_ST) block->acceleration_st = SILENT_MAX_ACCEL_ST;
-	}
-	else
-	{
-		if ((block->steps_x.wide > block->step_event_count.wide / 2) || (block->steps_y.wide > block->step_event_count.wide / 2))
-			if (block->acceleration_st > NORMAL_MAX_ACCEL_ST) block->acceleration_st = NORMAL_MAX_ACCEL_ST;
-	}
-    if(((float)block->acceleration_st * (float)block->steps_x.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[X_AXIS])
-      block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
-    if(((float)block->acceleration_st * (float)block->steps_y.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[Y_AXIS])
-      block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
-    if(((float)block->acceleration_st * (float)block->steps_z.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[Z_AXIS])
-      block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
-    if(((float)block->acceleration_st * (float)block->steps_e.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[E_AXIS])
-      block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
-#endif // ACCEL_LIMIT
-#endif // SIMPLE_ACCEL_LIMIT
-#else //TMC2130
     // Limit acceleration per axis
     //FIXME Vojtech: One shall rather limit a projection of the acceleration vector instead of using the limit.
     if(((float)block->acceleration_st * (float)block->steps_x.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[X_AXIS])
@@ -1052,7 +1000,6 @@ Having the real displacement of the head, we can calculate the total movement le
       block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
     if(((float)block->acceleration_st * (float)block->steps_z.wide / (float)block->step_event_count.wide ) > axis_steps_per_sqr_second[Z_AXIS])
       block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
-#endif //TMC2130
   }
   // Acceleration of the segment, in mm/sec^2
   block->acceleration = block->acceleration_st / steps_per_mm;
@@ -1347,11 +1294,28 @@ void set_extrude_min_temp(float temp)
 void reset_acceleration_rates()
 {
 	for(int8_t i=0; i < NUM_AXIS; i++)
-        {
         axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
-        }
 }
-unsigned char number_of_blocks() {
+
+#ifdef TMC2130
+void update_mode_profile()
+{
+	if (tmc2130_mode == TMC2130_MODE_NORMAL)
+	{
+		max_feedrate = max_feedrate_normal;
+		max_acceleration_units_per_sq_second = max_acceleration_units_per_sq_second_normal;
+	}
+	else if (tmc2130_mode == TMC2130_MODE_SILENT)
+	{
+		max_feedrate = max_feedrate_silent;
+		max_acceleration_units_per_sq_second = max_acceleration_units_per_sq_second_silent;
+	}
+	reset_acceleration_rates();
+}
+#endif //TMC2130
+
+unsigned char number_of_blocks()
+{
 	return (block_buffer_head + BLOCK_BUFFER_SIZE - block_buffer_tail) & (BLOCK_BUFFER_SIZE - 1);
 }
 #ifdef PLANNER_DIAGNOSTICS

+ 15 - 2
Firmware/planner.h

@@ -159,9 +159,20 @@ void plan_set_e_position(const float &e);
 void check_axes_activity();
 
 extern unsigned long minsegmenttime;
-extern float max_feedrate[NUM_AXIS]; // set the max speeds
+
+// Use M203 to override by software
+extern float max_feedrate_normal[NUM_AXIS];
+extern float max_feedrate_silent[NUM_AXIS];
+extern float* max_feedrate;
+
+// Use M92 to override by software
 extern float axis_steps_per_unit[NUM_AXIS];
-extern unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
+
+// Use M201 to override by software
+extern unsigned long max_acceleration_units_per_sq_second_normal[NUM_AXIS];
+extern unsigned long max_acceleration_units_per_sq_second_silent[NUM_AXIS];
+extern unsigned long* max_acceleration_units_per_sq_second; 
+
 extern float minimumfeedrate;
 extern float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
 extern float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX
@@ -241,6 +252,8 @@ void set_extrude_min_temp(float temp);
 void reset_acceleration_rates();
 #endif
 
+void update_mode_profile();
+
 unsigned char number_of_blocks();
 
 // #define PLANNER_DIAGNOSTICS

+ 154 - 151
Firmware/ultralcd.cpp

@@ -146,8 +146,6 @@ int8_t FSensorStateMenu = 1;
 
 int8_t CrashDetectMenu = 1;
 
-extern void fsensor_block();
-extern void fsensor_unblock();
 
 extern bool fsensor_enable();
 extern void fsensor_disable();
@@ -2282,7 +2280,7 @@ void lcd_set_fan_check() {
 }
 
 void lcd_set_filament_autoload() {
-     fautoload_set(!filament_autoload_enabled);
+     fsensor_autoload_set(!filament_autoload_enabled);
 }
 
 void lcd_unLoadFilament()
@@ -2616,67 +2614,75 @@ void lcd_menu_statistics()
 }
 
 
-static void _lcd_move(const char *name, int axis, int min, int max) {
-    if (!menuData._lcd_moveMenu.initialized)
-    {
-        menuData._lcd_moveMenu.endstopsEnabledPrevious = enable_endstops(false);
-        menuData._lcd_moveMenu.initialized = true;
-    }
-
-	if (lcd_encoder != 0) {
-    refresh_cmd_timeout();
-    if (! planner_queue_full()) {
-      current_position[axis] += float((int)lcd_encoder) * move_menu_scale;
-      if (min_software_endstops && current_position[axis] < min) current_position[axis] = min;
-      if (max_software_endstops && current_position[axis] > max) current_position[axis] = max;
-      lcd_encoder = 0;
-      world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
-      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis] / 60, active_extruder);
-      lcd_draw_update = 1;
-    }
-  }
-  if (lcd_draw_update) lcd_drawedit(name, ftostr31(current_position[axis]));
-  if (menuExiting || LCD_CLICKED) (void)enable_endstops(menuData._lcd_moveMenu.endstopsEnabledPrevious);
-  if (LCD_CLICKED) menu_back();
+static void _lcd_move(const char *name, int axis, int min, int max)
+{
+	if (!menuData._lcd_moveMenu.initialized)
+	{
+		menuData._lcd_moveMenu.endstopsEnabledPrevious = enable_endstops(false);
+		menuData._lcd_moveMenu.initialized = true;
+	}
+	if (lcd_encoder != 0)
+	{
+		refresh_cmd_timeout();
+		if (! planner_queue_full())
+		{
+			current_position[axis] += float((int)lcd_encoder) * move_menu_scale;
+			if (min_software_endstops && current_position[axis] < min) current_position[axis] = min;
+			if (max_software_endstops && current_position[axis] > max) current_position[axis] = max;
+			lcd_encoder = 0;
+			world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
+			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis] / 60, active_extruder);
+			lcd_draw_update = 1;
+		}
+	}
+	if (lcd_draw_update)
+	{
+	    lcd_set_cursor(0, 1);
+		menu_draw_float31(' ', name, current_position[axis]);
+	}
+	if (menuExiting || LCD_CLICKED) (void)enable_endstops(menuData._lcd_moveMenu.endstopsEnabledPrevious);
+	if (LCD_CLICKED) menu_back();
 }
 
 
 static void lcd_move_e()
 {
-	if (degHotend0() > EXTRUDE_MINTEMP) {
-  if (lcd_encoder != 0)
-  {
-    refresh_cmd_timeout();
-    if (! planner_queue_full()) {
-      current_position[E_AXIS] += float((int)lcd_encoder) * move_menu_scale;
-      lcd_encoder = 0;
-      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[E_AXIS] / 60, active_extruder);
-      lcd_draw_update = 1;
-    }
-  }
-  if (lcd_draw_update)
-  {
-    lcd_drawedit(PSTR("Extruder"), ftostr31(current_position[E_AXIS]));
-  }
-  if (LCD_CLICKED) menu_back();
-}
-	else {
+	if (degHotend0() > EXTRUDE_MINTEMP)
+	{
+		if (lcd_encoder != 0)
+		{
+			refresh_cmd_timeout();
+			if (! planner_queue_full())
+			{
+				current_position[E_AXIS] += float((int)lcd_encoder) * move_menu_scale;
+				lcd_encoder = 0;
+				plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[E_AXIS] / 60, active_extruder);
+				lcd_draw_update = 1;
+			}
+		}
+		if (lcd_draw_update)
+		{
+		    lcd_set_cursor(0, 1);
+			menu_draw_float31(' ', PSTR("Extruder"), current_position[E_AXIS]);
+		}
+		if (LCD_CLICKED) menu_back();
+	}
+	else
+	{
 		lcd_clear();
 		lcd_set_cursor(0, 0);
 		lcd_puts_P(_T(MSG_ERROR));
 		lcd_set_cursor(0, 2);
 		lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
-
 		delay(2000);
 		lcd_return_to_status();
 	}
 }
-/**
- * @brief Show measured Y distance of front calibration points from Y_MIN_POS
- *
- * If those points are detected too close to edge of reachable area, their confidence is lowered.
- * This functionality is applied more often for MK2 printers.
- */
+
+
+//@brief Show measured Y distance of front calibration points from Y_MIN_POS
+//If those points are detected too close to edge of reachable area, their confidence is lowered.
+//This functionality is applied more often for MK2 printers.
 static void lcd_menu_xyz_y_min()
 {
 //|01234567890123456789|
@@ -2708,9 +2714,8 @@ static void lcd_menu_xyz_y_min()
     if (lcd_clicked())
         menu_goto(lcd_menu_xyz_skew, 0, true, true);
 }
-/**
- * @brief Show measured axis skewness
- */
+
+//@brief Show measured axis skewness
 float _deg(float rad)
 {
 	return rad * 180 / M_PI;
@@ -2807,56 +2812,61 @@ static void lcd_move_z() {
  */
 static void _lcd_babystep(int axis, const char *msg) 
 {
-    if (menuData.babyStep.status == 0) {
-        // Menu was entered.
-        // Initialize its status.
-        menuData.babyStep.status = 1;
+	if (menuData.babyStep.status == 0)
+	{
+		// Menu was entered.
+		// Initialize its status.
+		menuData.babyStep.status = 1;
 		check_babystep();
 
 		EEPROM_read_B(EEPROM_BABYSTEP_X, &menuData.babyStep.babystepMem[0]);
-        EEPROM_read_B(EEPROM_BABYSTEP_Y, &menuData.babyStep.babystepMem[1]);
-        EEPROM_read_B(EEPROM_BABYSTEP_Z, &menuData.babyStep.babystepMem[2]);
-		
-        menuData.babyStep.babystepMemMM[0] = menuData.babyStep.babystepMem[0]/axis_steps_per_unit[X_AXIS];
-        menuData.babyStep.babystepMemMM[1] = menuData.babyStep.babystepMem[1]/axis_steps_per_unit[Y_AXIS];
-        menuData.babyStep.babystepMemMM[2] = menuData.babyStep.babystepMem[2]/axis_steps_per_unit[Z_AXIS];
-        lcd_draw_update = 1;
+		EEPROM_read_B(EEPROM_BABYSTEP_Y, &menuData.babyStep.babystepMem[1]);
+		EEPROM_read_B(EEPROM_BABYSTEP_Z, &menuData.babyStep.babystepMem[2]);
+
+		menuData.babyStep.babystepMemMM[0] = menuData.babyStep.babystepMem[0]/axis_steps_per_unit[X_AXIS];
+		menuData.babyStep.babystepMemMM[1] = menuData.babyStep.babystepMem[1]/axis_steps_per_unit[Y_AXIS];
+		menuData.babyStep.babystepMemMM[2] = menuData.babyStep.babystepMem[2]/axis_steps_per_unit[Z_AXIS];
+		lcd_draw_update = 1;
 		//SERIAL_ECHO("Z baby step: ");
 		//SERIAL_ECHO(menuData.babyStep.babystepMem[2]);
-        // Wait 90 seconds before closing the live adjust dialog.
-        lcd_timeoutToStatus = millis() + 90000;
-    }
-
-  if (lcd_encoder != 0) 
-  {
-	if (homing_flag) lcd_encoder = 0;
+		// Wait 90 seconds before closing the live adjust dialog.
+		lcd_timeoutToStatus = millis() + 90000;
+	}
 
-    menuData.babyStep.babystepMem[axis] += (int)lcd_encoder;
-	if (axis == 2) {
-		if (menuData.babyStep.babystepMem[axis] < Z_BABYSTEP_MIN) menuData.babyStep.babystepMem[axis] = Z_BABYSTEP_MIN; //-3999 -> -9.99 mm
-		else  if (menuData.babyStep.babystepMem[axis] > Z_BABYSTEP_MAX) menuData.babyStep.babystepMem[axis] = Z_BABYSTEP_MAX; //0
-		else {
-			CRITICAL_SECTION_START
+	if (lcd_encoder != 0) 
+	{
+		if (homing_flag) lcd_encoder = 0;
+		menuData.babyStep.babystepMem[axis] += (int)lcd_encoder;
+		if (axis == 2)
+		{
+			if (menuData.babyStep.babystepMem[axis] < Z_BABYSTEP_MIN) menuData.babyStep.babystepMem[axis] = Z_BABYSTEP_MIN; //-3999 -> -9.99 mm
+			else if (menuData.babyStep.babystepMem[axis] > Z_BABYSTEP_MAX) menuData.babyStep.babystepMem[axis] = Z_BABYSTEP_MAX; //0
+			else
+			{
+				CRITICAL_SECTION_START
 				babystepsTodo[axis] += (int)lcd_encoder;
-			CRITICAL_SECTION_END		
+				CRITICAL_SECTION_END		
+			}
 		}
+		menuData.babyStep.babystepMemMM[axis] = menuData.babyStep.babystepMem[axis]/axis_steps_per_unit[axis]; 
+		delay(50);
+		lcd_encoder = 0;
+		lcd_draw_update = 1;
 	}
-    menuData.babyStep.babystepMemMM[axis] = menuData.babyStep.babystepMem[axis]/axis_steps_per_unit[axis]; 
-	  delay(50);
-	  lcd_encoder = 0;
-    lcd_draw_update = 1;
-  }
-  if (lcd_draw_update)
-    lcd_drawedit_2(msg, ftostr13ns(menuData.babyStep.babystepMemMM[axis]));
-  if (LCD_CLICKED || menuExiting) {
-    // Only update the EEPROM when leaving the menu.
-    EEPROM_save_B(
-      (axis == X_AXIS) ? EEPROM_BABYSTEP_X : ((axis == Y_AXIS) ? EEPROM_BABYSTEP_Y : EEPROM_BABYSTEP_Z),
-      &menuData.babyStep.babystepMem[axis]);
-
-    if(Z_AXIS == axis) calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
-  }
-  if (LCD_CLICKED) menu_back();
+	if (lcd_draw_update)
+	{
+	    lcd_set_cursor(0, 1);
+		menu_draw_float31(' ', msg, menuData.babyStep.babystepMemMM[axis]);
+	}
+	if (LCD_CLICKED || menuExiting)
+	{
+		// Only update the EEPROM when leaving the menu.
+		EEPROM_save_B(
+		(axis == X_AXIS) ? EEPROM_BABYSTEP_X : ((axis == Y_AXIS) ? EEPROM_BABYSTEP_Y : EEPROM_BABYSTEP_Z),
+		&menuData.babyStep.babystepMem[axis]);
+		if(Z_AXIS == axis) calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
+	}
+	if (LCD_CLICKED) menu_back();
 }
 
 static void lcd_babystep_x() {
@@ -4054,8 +4064,9 @@ static void lcd_silent_mode_set() {
 //	  MYSERIAL.print("standstill OK");
 //  else
 //	  MYSERIAL.print("standstill NG!");
-  cli();
+	cli();
 	tmc2130_mode = (SilentModeMenu != SILENT_MODE_NORMAL)?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
+	update_mode_profile();
 	tmc2130_init();
   // We may have missed a stepper timer interrupt due to the time spent in tmc2130_init.
   // Be safe than sorry, reset the stepper timer before re-enabling interrupts.
@@ -4452,9 +4463,6 @@ void lcd_wizard(int state) {
 			state = 7;
 			break;
 		case 7: //load filament 
-#ifdef PAT9125
-			fsensor_block();
-#endif //PAT9125
 			lcd_show_fullscreen_message_and_wait_P(_i("Please insert PLA filament to the extruder, then press knob to load it."));////MSG_WIZARD_LOAD_FILAMENT c=20 r=8
 			lcd_update_enable(false);
 			lcd_clear();
@@ -4463,9 +4471,6 @@ void lcd_wizard(int state) {
 			change_extr(0);
 #endif
 			gcode_M701();
-#ifdef PAT9125
-			fsensor_unblock();
-#endif //PAT9125
 			state = 9;
 			break;
 		case 8:
@@ -7515,60 +7520,58 @@ void menu_lcd_charsetup_func(void)
 void menu_lcd_lcdupdate_func(void)
 {
 #if (SDCARDDETECT > 0)
-  if ((IS_SD_INSERTED != lcd_oldcardstatus))
-  {
-	  lcd_draw_update = 2;
-	  lcd_oldcardstatus = IS_SD_INSERTED;
-	  lcd_refresh(); // to maybe revive the LCD if static electricity killed it.
-
-	  if (lcd_oldcardstatus)
-	  {
-		  card.initsd();
-		  LCD_MESSAGERPGM(_i("Card inserted"));////MSG_SD_INSERTED c=0 r=0
-		  //get_description();
-	  }
-	  else
-	  {
-		  card.release();
-		  LCD_MESSAGERPGM(_i("Card removed"));////MSG_SD_REMOVED c=0 r=0
-	  }
-  }
+	if ((IS_SD_INSERTED != lcd_oldcardstatus))
+	{
+		lcd_draw_update = 2;
+		lcd_oldcardstatus = IS_SD_INSERTED;
+		lcd_refresh(); // to maybe revive the LCD if static electricity killed it.
+		if (lcd_oldcardstatus)
+		{
+			card.initsd();
+			LCD_MESSAGERPGM(_i("Card inserted"));////MSG_SD_INSERTED c=0 r=0
+			//get_description();
+		}
+		else
+		{
+			card.release();
+			LCD_MESSAGERPGM(_i("Card removed"));////MSG_SD_REMOVED c=0 r=0
+		}
+	}
 #endif//CARDINSERTED
+	if (lcd_next_update_millis < millis())
+	{
+		if (abs(lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP)
+		{
+			if (lcd_draw_update == 0)
+			lcd_draw_update = 1;
+			lcd_encoder += lcd_encoder_diff / ENCODER_PULSES_PER_STEP;
+			lcd_encoder_diff = 0;
+			lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
+		}
 
-  if (lcd_next_update_millis < millis())
-  {
-
-	  if (abs(lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP)
-	  {
-      if (lcd_draw_update == 0)
-		    lcd_draw_update = 1;
-		  lcd_encoder += lcd_encoder_diff / ENCODER_PULSES_PER_STEP;
-		  lcd_encoder_diff = 0;
-		  lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
-	  }
-
-	  if (LCD_CLICKED) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
+		if (LCD_CLICKED) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
 
-	  (*menu_menu)();
+		(*menu_menu)();
 
-	  if (lcd_timeoutToStatus < millis() && menu_menu != lcd_status_screen)
-	  {
-      // Exiting a menu. Let's call the menu function the last time with menuExiting flag set to true
-      // to give it a chance to save its state.
-      // This is useful for example, when the babystep value has to be written into EEPROM.
-      if (menu_menu != NULL) {
-        menuExiting = true;
-        (*menu_menu)();
-        menuExiting = false;
-      }
-	      lcd_clear();
-		  lcd_return_to_status();
-		  lcd_draw_update = 2;
-	  }
-	  if (lcd_draw_update == 2) lcd_clear();
-	  if (lcd_draw_update) lcd_draw_update--;
-	  lcd_next_update_millis = millis() + LCD_UPDATE_INTERVAL;
-	  }
+		if (lcd_timeoutToStatus < millis() && menu_menu != lcd_status_screen)
+		{
+		// Exiting a menu. Let's call the menu function the last time with menuExiting flag set to true
+		// to give it a chance to save its state.
+		// This is useful for example, when the babystep value has to be written into EEPROM.
+			if (menu_menu != NULL)
+			{
+				menuExiting = true;
+				(*menu_menu)();
+				menuExiting = false;
+			}
+			lcd_clear();
+			lcd_return_to_status();
+			lcd_draw_update = 2;
+		}
+		if (lcd_draw_update == 2) lcd_clear();
+		if (lcd_draw_update) lcd_draw_update--;
+		lcd_next_update_millis = millis() + LCD_UPDATE_INTERVAL;
+	}
 	if (!SdFatUtil::test_stack_integrity()) stack_error();
 	lcd_ping(); //check that we have received ping command if we are in farm mode
 	lcd_send_status();

+ 9 - 14
Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h

@@ -86,8 +86,11 @@
  */
 #define SHEET_PRINT_ZERO_REF_Y -2.f
 
-#define DEFAULT_MAX_FEEDRATE          {200, 200, 12, 120}      // (mm/sec)   max feedrate (M203)
-#define DEFAULT_MAX_ACCELERATION      {1000, 1000, 200, 5000}  // (mm/sec^2) max acceleration (M201)
+#define DEFAULT_MAX_FEEDRATE                {200, 200, 12, 120}      // (mm/sec)   max feedrate (M203)
+#define DEFAULT_MAX_FEEDRATE_SILENT         {172, 172, 12, 120}      // (mm/sec)   max feedrate (M203), silent mode
+
+#define DEFAULT_MAX_ACCELERATION            {1000, 1000, 200, 5000}  // (mm/sec^2) max acceleration (M201)
+#define DEFAULT_MAX_ACCELERATION_SILENT     {960, 960, 200, 5000}    // (mm/sec^2) max acceleration (M201), silent mode
 
 
 #define DEFAULT_ACCELERATION          1250   // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S)
@@ -96,18 +99,12 @@
 #define MANUAL_FEEDRATE {2700, 2700, 1000, 100}   // set the speeds for manual moves (mm/min)
 
 //Silent mode limits
-//#define SILENT_MAX_ACCEL  960 // max axxeleration in silent mode in mm/s^2
-//#define SILENT_MAX_ACCEL_ST (100*SILENT_MAX_ACCEL) // max accel in steps/s^2
-//#define SILENT_MAX_FEEDRATE 172  //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min)
+#define SILENT_MAX_ACCEL_XY      960  // max acceleration in silent mode in mm/s^2
+#define SILENT_MAX_FEEDRATE_XY   172  // max feedrate in mm/s
 
 //Normal mode limits
-//#define NORMAL_MAX_ACCEL 2500 // Y-axis max axxeleration in normal mode in mm/s^2
-//#define NORMAL_MAX_ACCEL_ST (100*NORMAL_MAX_ACCEL) // max accel in steps/s^2
-//#define NORMAL_MAX_FEEDRATE 200  //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min)
-
-//#define FEEDRATE_LIMIT                 //limitation method for normal/silent
-//#define ACCEL_LIMIT                 //limitation method for normal/silent
-//#define SIMPLE_ACCEL_LIMIT          //new limitation method for normal/silent
+#define NORMAL_MAX_ACCEL_XY     2500  // max acceleration in normal mode in mm/s^2
+#define NORMAL_MAX_FEEDRATE_XY   200  // max feedrate in mm/s
 
 //number of bytes from end of the file to start check
 #define END_FILE_SECTION 10000
@@ -141,8 +138,6 @@
 //#define BACKLASH_X
 //#define BACKLASH_Y
 
-// Disable some commands
-#define _DISABLE_M42_M226
 
 // Minimum ambient temperature limit to start triggering MINTEMP errors [C]
 // this value is litlebit higher that real limit, because ambient termistor is on the board and is temperated from it,