Selaa lähdekoodia

Split lcd_service_mode_show_result screens to separate functions. Make them non blocking. Remove global array distance_from_min, pass it as function return value. Make Support submenus returning to Support menu.

Marek Bel 6 vuotta sitten
vanhempi
commit
ae08788c99

+ 0 - 1
Firmware/Marlin.h

@@ -343,7 +343,6 @@ extern unsigned long t_fan_rising_edge;
 extern bool mesh_bed_leveling_flag;
 extern bool mesh_bed_run_from_menu;
 
-extern float distance_from_min[2];
 extern bool sortAlpha;
 
 extern char dir_names[3][9];

+ 0 - 2
Firmware/Marlin_main.cpp

@@ -324,8 +324,6 @@ unsigned int custom_message_type;
 unsigned int custom_message_state;
 char snmm_filaments_used = 0;
 
-float distance_from_min[2];
-
 bool fan_state[2];
 int fan_edge_counter[2];
 int fan_speed[2];

+ 7 - 4
Firmware/mesh_bed_calibration.cpp

@@ -2960,8 +2960,8 @@ void babystep_reset()
       babystepLoadZ = 0;    
 }
 
-void count_xyz_details() {
-	float a1, a2;
+DistanceMin count_xyz_details() {
+    DistanceMin distanceMin;
 	float cntr[2] = {
 		eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER + 0)),
 		eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER + 4))
@@ -2974,12 +2974,15 @@ void count_xyz_details() {
 		eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_VEC_Y + 0)),
 		eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_VEC_Y + 4))
 	};
+#if 0
 	a2 = -1 * asin(vec_y[0] / MACHINE_AXIS_SCALE_Y);
 	a1 = asin(vec_x[1] / MACHINE_AXIS_SCALE_X);
-	//angleDiff = fabs(a2 - a1);
+	angleDiff = fabs(a2 - a1);
+#endif
 	for (uint8_t mesh_point = 0; mesh_point < 2; ++mesh_point) {
 		float y = vec_x[1] * pgm_read_float(bed_ref_points_4 + mesh_point * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + mesh_point * 2 + 1) + cntr[1];
-		distance_from_min[mesh_point] = (y - Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH);
+		distanceMin.d[mesh_point] = (y - Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH);
 	}
+	return distanceMin;
 }
 

+ 2 - 1
Firmware/mesh_bed_calibration.h

@@ -181,7 +181,8 @@ extern void babystep_undo();
 
 // Reset the current babystep counter without moving the axes.
 extern void babystep_reset();
-extern void count_xyz_details();
+typedef struct{ float d[2];} DistanceMin;
+extern DistanceMin count_xyz_details();
 extern bool sample_z();
 
 #endif /* MESH_BED_CALIBRATION_H */

+ 58 - 58
Firmware/ultralcd.cpp

@@ -222,6 +222,8 @@ static void prusa_stat_temperatures();
 static void prusa_stat_printinfo();
 static void lcd_farm_no();
 static void lcd_menu_extruder_info();
+static void lcd_menu_xyz_y_min();
+static void lcd_menu_xyz_skew();
 #if defined(TMC2130) || defined(PAT9125)
 static void lcd_menu_fails_stats();
 #endif //TMC2130 or PAT9125
@@ -1582,7 +1584,7 @@ static void lcd_menu_extruder_info()
     if (lcd_clicked())
     {
         lcd_quick_feedback();
-        lcd_return_to_status();
+        menu_action_back();
     }
 }
 
@@ -1686,7 +1688,7 @@ static void lcd_menu_debug()
 	if (lcd_clicked())
     {
         lcd_quick_feedback();
-        lcd_return_to_status();
+        menu_action_back();
     }
 }
 #endif /* DEBUG_BUILD */
@@ -1703,7 +1705,7 @@ static void lcd_menu_temperatures()
 	if (lcd_clicked())
     {
         lcd_quick_feedback();
-        lcd_return_to_status();
+        menu_action_back();
     }
 }
 
@@ -1721,7 +1723,7 @@ static void lcd_menu_voltages()
     if (lcd_clicked())
     {
         lcd_quick_feedback();
-        lcd_return_to_status();
+        menu_action_back();
     }
 }
 #endif //defined VOLT_BED_PIN || defined VOLT_PWR_PIN
@@ -1733,7 +1735,7 @@ static void lcd_menu_belt_status()
     if (lcd_clicked())
     {
         lcd_quick_feedback();
-        lcd_return_to_status();
+        menu_action_back();
     }
 }
 #endif //TMC2130
@@ -1831,7 +1833,7 @@ static void lcd_support_menu()
   }
   #ifndef MK1BP
   MENU_ITEM(back, PSTR("------------"), 0);
-  if (!IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL)) MENU_ITEM(function, MSG_XYZ_DETAILS, lcd_service_mode_show_result);
+  if (!IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL)) MENU_ITEM(submenu, MSG_XYZ_DETAILS, lcd_menu_xyz_y_min);
   MENU_ITEM(submenu, MSG_INFO_EXTRUDER, lcd_menu_extruder_info);
 
 #ifdef TMC2130
@@ -2285,62 +2287,60 @@ static void lcd_move_e()
 	}
 }
 
-void lcd_service_mode_show_result() {
-	float angleDiff;
-	lcd_set_custom_characters_degree();
-	count_xyz_details();
-	angleDiff = eeprom_read_float((float*)(EEPROM_XYZ_CAL_SKEW));
-	lcd_update_enable(false);
-	lcd_implementation_clear();
-	lcd_printPGM(MSG_Y_DISTANCE_FROM_MIN);
-	lcd_print_at_PGM(0, 1, MSG_LEFT);
-	lcd_print_at_PGM(0, 2, MSG_RIGHT);
-
-	for (int i = 0; i < 2; i++) {
-		if(distance_from_min[i] < 200) {
-			lcd_print_at_PGM(11, i + 1, PSTR(""));
-			lcd.print(distance_from_min[i]);
-			lcd_print_at_PGM((distance_from_min[i] < 0) ? 17 : 16, i + 1, PSTR("mm"));		
-		} else lcd_print_at_PGM(11, i + 1, PSTR("N/A"));
-	}
-	delay_keep_alive(500);
-	KEEPALIVE_STATE(PAUSED_FOR_USER);
-	while (!lcd_clicked()) {
-		delay_keep_alive(100);
-	}
-	delay_keep_alive(500);
-	lcd_implementation_clear();
-	
-
-	lcd_printPGM(MSG_MEASURED_SKEW);
-	if (angleDiff < 100) {
-		lcd.setCursor(15, 0);
-		lcd.print(angleDiff * 180 / M_PI);
-		lcd.print(LCD_STR_DEGREE);
-	}else lcd_print_at_PGM(16, 0, PSTR("N/A"));
-	lcd_print_at_PGM(0, 1, PSTR("--------------------"));
-	lcd_print_at_PGM(0, 2, MSG_SLIGHT_SKEW);
-	lcd_print_at_PGM(15, 2, PSTR(""));
-	lcd.print(bed_skew_angle_mild * 180 / M_PI);
-	lcd.print(LCD_STR_DEGREE);
-	lcd_print_at_PGM(0, 3, MSG_SEVERE_SKEW);
-	lcd_print_at_PGM(15, 3, PSTR(""));
-	lcd.print(bed_skew_angle_extreme * 180 / M_PI);
-	lcd.print(LCD_STR_DEGREE);
-	delay_keep_alive(500);
-	while (!lcd_clicked()) {
-		delay_keep_alive(100);
-	}
-	KEEPALIVE_STATE(NOT_BUSY);
-	delay_keep_alive(500);
-	lcd_set_custom_characters_arrows();
-	lcd_return_to_status();
-	lcd_update_enable(true);
-	lcd_update(2);
+static void lcd_menu_xyz_y_min()
+{
+    lcd.setCursor(0,0);
+    lcd_printPGM(MSG_Y_DISTANCE_FROM_MIN);
+    lcd_print_at_PGM(0, 1, PSTR("--------------------"));
+    lcd_print_at_PGM(0, 2, MSG_LEFT);
+    lcd_print_at_PGM(0, 3, MSG_RIGHT);
+
+    DistanceMin distanceMin = count_xyz_details();
+
+    for (int i = 0; i < 2; i++) {
+        if(distanceMin.d[i] < 200) {
+            lcd_print_at_PGM(11, i + 2, PSTR(""));
+            lcd.print(distanceMin.d[i]);
+            lcd_print_at_PGM((distanceMin.d[i] < 0) ? 17 : 16, i + 2, PSTR("mm"));
+        } else lcd_print_at_PGM(11, i + 2, PSTR("N/A"));
+    }
+    if (lcd_clicked())
+    {
+        lcd_quick_feedback();
+        lcd_set_custom_characters_degree();
+        lcd_goto_menu(lcd_menu_xyz_skew);
+    }
 }
 
+static void lcd_menu_xyz_skew()
+{
+    float angleDiff;
+    angleDiff = eeprom_read_float((float*)(EEPROM_XYZ_CAL_SKEW));
 
+    lcd.setCursor(0,0);
+    lcd_printPGM(MSG_MEASURED_SKEW);
+    if (angleDiff < 100) {
+        lcd.setCursor(15, 0);
+        lcd.print(angleDiff * 180 / M_PI);
+        lcd.print(LCD_STR_DEGREE);
+    }else lcd_print_at_PGM(16, 0, PSTR("N/A"));
+    lcd_print_at_PGM(0, 1, PSTR("--------------------"));
+    lcd_print_at_PGM(0, 2, MSG_SLIGHT_SKEW);
+    lcd_print_at_PGM(15, 2, PSTR(""));
+    lcd.print(bed_skew_angle_mild * 180 / M_PI);
+    lcd.print(LCD_STR_DEGREE);
+    lcd_print_at_PGM(0, 3, MSG_SEVERE_SKEW);
+    lcd_print_at_PGM(15, 3, PSTR(""));
+    lcd.print(bed_skew_angle_extreme * 180 / M_PI);
+    lcd.print(LCD_STR_DEGREE);
 
+    if (lcd_clicked())
+    {
+        lcd_set_custom_characters_arrows();
+        lcd_quick_feedback();
+        menu_action_back();
+    }
+}
 
 // Save a single axis babystep value.
 void EEPROM_save_B(int pos, int* value)

+ 0 - 2
Firmware/ultralcd.h

@@ -296,8 +296,6 @@ void lcd_temp_calibration_set();
 
 void display_loading();
 
-void lcd_service_mode_show_result();
-
 #if !SDSORT_USES_RAM
  void lcd_set_degree();
  void lcd_set_progress();