浏览代码

long press compatible with timeout to status, temp compensation extrapolation, preheat Z coordinate added, G75 for showing interpolation table

PavelSindler 8 年之前
父节点
当前提交
7e8780ba61
共有 4 个文件被更改,包括 24 次插入16 次删除
  1. 20 13
      Firmware/Marlin_main.cpp
  2. 1 1
      Firmware/language_cz.h
  3. 1 1
      Firmware/language_en.h
  4. 2 1
      Firmware/ultralcd.cpp

+ 20 - 13
Firmware/Marlin_main.cpp

@@ -2793,6 +2793,16 @@ void process_commands()
         break;
 
 
+	case 75:
+	{
+		for (int i = 40; i <= 110; i++) {
+			MYSERIAL.print(i);
+			MYSERIAL.print("  ");
+			MYSERIAL.println(temp_comp_interpolation(i));// / axis_steps_per_unit[Z_AXIS]);
+		}
+	}
+	break;
+
 	case 76: //PINDA probe temperature calibration
 	{
 		setTargetBed(PINDA_MIN_T);
@@ -2814,7 +2824,7 @@ void process_commands()
 		custom_message = MSG_TEMP_CALIBRATION;
 		current_position[X_AXIS] = PINDA_PREHEAT_X;
 		current_position[Y_AXIS] = PINDA_PREHEAT_Y;
-		current_position[Z_AXIS] = 0;
+		current_position[Z_AXIS] = PINDA_PREHEAT_Z;
 		plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
 		st_synchronize();
 
@@ -2847,7 +2857,7 @@ void process_commands()
 			setTargetBed(t_c);
 			current_position[X_AXIS] = PINDA_PREHEAT_X;
 			current_position[Y_AXIS] = PINDA_PREHEAT_Y;
-			current_position[Z_AXIS] = 0;
+			current_position[Z_AXIS] = PINDA_PREHEAT_Z;
 			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
 			st_synchronize();
 			while (degBed() < t_c) delay_keep_alive(1000);
@@ -6317,7 +6327,7 @@ void temp_compensation_start() {
 	
 	current_position[X_AXIS] = PINDA_PREHEAT_X;
 	current_position[Y_AXIS] = PINDA_PREHEAT_Y;
-	current_position[Z_AXIS] = 0;
+	current_position[Z_AXIS] = PINDA_PREHEAT_Z;
 	plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
 	st_synchronize();
 
@@ -6336,12 +6346,11 @@ void temp_compensation_apply() {
 	float z_shift_mm;
 
 	if (calibration_status() == CALIBRATION_STATUS_CALIBRATED) {
-		if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 50 && target_temperature_bed <= 100) {
+		if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 60 && target_temperature_bed <= 100) {
 			i_add = (target_temperature_bed - 60) / 10;
 			EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i_add * 2, &z_shift);
 			z_shift_mm = z_shift / axis_steps_per_unit[Z_AXIS];
-		}
-		else {
+		}else {
 			//interpolation
 			z_shift_mm = temp_comp_interpolation(target_temperature_bed) / axis_steps_per_unit[Z_AXIS];
 		}
@@ -6353,7 +6362,7 @@ void temp_compensation_apply() {
 		plan_set_z_position(current_position[Z_AXIS]);
 	}
 	else {		
-		//message that we have no temp compensation data ?
+		//we have no temp compensation data
 	}
 }
 
@@ -6362,23 +6371,21 @@ float temp_comp_interpolation(float inp_temperature) {
 	//cubic spline interpolation
 
 	int n, i, j, k;
-	float h[10], a, b, c, d, sum, s[10] = { 0 }, x[10], F[10], f[10], p, m[10][10] = { 0 }, temp;
+	float h[10], a, b, c, d, sum, s[10] = { 0 }, x[10], F[10], f[10], m[10][10] = { 0 }, temp;
 	int shift[10];
 	int temp_C[10];
 
-	p = inp_temperature;
 	n = 6; //number of measured points
 
 	shift[0] = 0;
 	for (i = 0; i < n; i++) {
-		//scanf_s("%f%f", &x[i], &f[i]);
 		if (i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i-1) * 2, &shift[i]); //read shift in steps from EEPROM
 		temp_C[i] = 50 + i * 10; //temperature in C
 		
 		x[i] = (float)temp_C[i];
 		f[i] = (float)shift[i];
 	}
-
+	if (inp_temperature < x[0]) return 0;
 
 
 	for (i = n - 1; i>0; i--) {
@@ -6409,12 +6416,12 @@ float temp_comp_interpolation(float inp_temperature) {
 	}
 
 		for (i = 0; i<n - 1; i++)
-			if (x[i] <= p&&p <= x[i + 1]) {
+			if ((x[i] <= inp_temperature && inp_temperature <= x[i + 1]) || (i == n-2 && inp_temperature > x[i + 1])) {
 				a = (s[i + 1] - s[i]) / (6 * h[i]);
 				b = s[i] / 2;
 				c = (f[i + 1] - f[i]) / h[i] - (2 * h[i] * s[i] + s[i + 1] * h[i]) / 6;
 				d = f[i];
-				sum = a*pow((p - x[i]), 3) + b*pow((p - x[i]), 2) + c*(p - x[i]) + d;
+				sum = a*pow((inp_temperature - x[i]), 3) + b*pow((inp_temperature - x[i]), 2) + c*(inp_temperature - x[i]) + d;
 			}
 
 		return sum;

+ 1 - 1
Firmware/language_cz.h

@@ -277,7 +277,7 @@
 #define MSG_CALIBRATE_PINDA								"Zkalibrovat"
 #define MSG_CALIBRATION_PINDA_MENU						"Teplotni kalibrace"
 #define MSG_PINDA_NOT_CALIBRATED						"Tiskarna nebyla teplotne zkalibrovana"
-#define MSG_PINDA_PREHEAT								"Predehrivani"
+#define MSG_PINDA_PREHEAT								"Predehrivani        "
 #define MSG_TEMP_CALIBRATION							"Tepl. kal.          "
 #define MSG_TEMP_CALIBRATION_DONE						"Teplotni kalibrace dokoncena. Pokracujte stiskem tlacitka."
 #define MSG_TEMP_CALIBRATION_ON							"Tepl. kal. [ON]"

+ 1 - 1
Firmware/language_en.h

@@ -278,7 +278,7 @@
 #define(length=17, lines=1) MSG_CALIBRATE_PINDA					"Calibrate"
 #define(length=17, lines=1) MSG_CALIBRATION_PINDA_MENU			"Temp. calibration"
 #define(length=20, lines=4) MSG_PINDA_NOT_CALIBRATED			"Temperature calibration has not been run yet"
-#define(length=20, lines=1) MSG_PINDA_PREHEAT					"Preheating"
+#define(length=20, lines=1) MSG_PINDA_PREHEAT					"Preheating          "
 #define(length=20, lines=1) MSG_TEMP_CALIBRATION				"Temp. cal.          "
 #define(length=20, lines=4) MSG_TEMP_CALIBRATION_DONE			"Temperature calibration is finished. Click to continue."
 #define(length=20, lines=1) MSG_TEMP_CALIBRATION_ON				"Temp. cal. [ON]"

+ 2 - 1
Firmware/ultralcd.cpp

@@ -4651,7 +4651,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
 		  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;
 #endif//ULTIPANEL
 
 #ifdef DOGLCD        // Changes due to different driver architecture of the DOGM display
@@ -4788,6 +4788,7 @@ void lcd_buttons_update()
 #if BTN_ENC > 0
   if (lcd_update_enabled == true) { //if we are in non-modal mode, long press can be used and short press triggers with button release
 	  if (READ(BTN_ENC) == 0) { //button is pressed	  
+		  lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
 		  if (millis() > button_blanking_time) {
 			  button_blanking_time = millis() + BUTTON_BLANKING_TIME;
 			  if (button_pressed == false && long_press_active == false) {