Browse Source

Save z_offset, bed_temp and pinda_temp with sheet calibration.

Marek Bel 4 years ago
parent
commit
4a16fe6902
5 changed files with 28 additions and 12 deletions
  1. 6 4
      Firmware/Marlin_main.cpp
  2. 2 1
      Firmware/eeprom.cpp
  3. 5 2
      Firmware/eeprom.h
  4. 3 2
      Firmware/mesh_bed_calibration.cpp
  5. 12 3
      Firmware/ultralcd.cpp

+ 6 - 4
Firmware/Marlin_main.cpp

@@ -1492,7 +1492,6 @@ void setup()
 		SilentModeMenu_MMU = 1;
 		eeprom_write_byte((uint8_t*)EEPROM_MMU_STEALTH, SilentModeMenu_MMU);
 	}
-	check_babystep(); //checking if Z babystep is in allowed range
 
 #if !defined(DEBUG_DISABLE_FANCHECK) && defined(FANCHECK) && defined(TACH_1) && TACH_1 >-1
 	setup_fan_interrupt();
@@ -8146,12 +8145,15 @@ static void wait_for_heater(long codenum, uint8_t extruder) {
 
 void check_babystep()
 {
-	int babystep_z;
-	EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystep_z);
+	int babystep_z = eeprom_read_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
+            s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)));
+
 	if ((babystep_z < Z_BABYSTEP_MIN) || (babystep_z > Z_BABYSTEP_MAX)) {
 		babystep_z = 0; //if babystep value is out of min max range, set it to 0
 		SERIAL_ECHOLNPGM("Z live adjust out of range. Setting to 0");
-		EEPROM_save_B(EEPROM_BABYSTEP_Z, &babystep_z);
+		eeprom_write_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
+            s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)),
+                    babystep_z);
 		lcd_show_fullscreen_message_and_wait_P(PSTR("Z live adjust out of range. Setting to 0. Click to continue."));
 		lcd_update_enable(true);		
 	}	

+ 2 - 1
Firmware/eeprom.cpp

@@ -3,6 +3,7 @@
 //! @author Marek Běl
 
 #include "eeprom.h"
+#include "Marlin.h"
 
 #include <avr/eeprom.h>
 #include <stdint.h>
@@ -66,7 +67,7 @@ void eeprom_init()
             eeprom_write(&(EEPROM_Sheets_base->s[i].name[1]), '\0');
         }
     }
-
+    check_babystep();
 }
 
 

+ 5 - 2
Firmware/eeprom.h

@@ -173,7 +173,10 @@ void eeprom_init();
 
 typedef struct
 {
-    char name[7];
+    char name[7];     //!< Can be null terminated, doesn't need to be null terminated
+    int16_t z_offset; //!< Z_BABYSTEP_MIN .. Z_BABYSTEP_MAX = Z_BABYSTEP_MIN*2/1000 [mm] .. Z_BABYSTEP_MAX*2/1000 [mm]
+    uint8_t bed_temp; //!< 0 .. 254 [°C]
+    uint8_t pinda_temp; //!< 0 .. 254 [°C]
 } Sheet;
 
 typedef struct
@@ -183,7 +186,7 @@ typedef struct
 } Sheets;
 // sizeof(Sheets). Do not change it unless EEPROM_Sheets_base is last item in EEPROM.
 // Otherwise it would move following items.
-#define EEPROM_SHEETS_SIZEOF 22
+#define EEPROM_SHEETS_SIZEOF 34
 
 static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_NOZZLE_DIAMETER - EEPROM_SHEETS_SIZEOF);
 

+ 3 - 2
Firmware/mesh_bed_calibration.cpp

@@ -3031,7 +3031,8 @@ void babystep_load()
         check_babystep(); //checking if babystep is in allowed range, otherwise setting babystep to 0
         
         // End of G80: Apply the baby stepping value.
-        EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystepLoadZ);
+        babystepLoadZ = eeprom_read_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
+                    s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)));
                             
     #if 0
         SERIAL_ECHO("Z baby step: ");
@@ -3186,4 +3187,4 @@ void mbl_interpolation(uint8_t meas_points) {
 			}
 		}
 	}
-}
+}

+ 12 - 3
Firmware/ultralcd.cpp

@@ -3073,7 +3073,7 @@ static void lcd_babystep_z()
 	typedef struct
 	{
 		int8_t status;
-		int babystepMemZ;
+		int16_t babystepMemZ;
 		float babystepMemMMZ;
 	} _menu_data_t;
 	static_assert(sizeof(menu_data)>= sizeof(_menu_data_t),"_menu_data_t doesn't fit into menu_data");
@@ -3085,7 +3085,8 @@ static void lcd_babystep_z()
 		_md->status = 1;
 		check_babystep();
 
-		EEPROM_read_B(EEPROM_BABYSTEP_Z, &_md->babystepMemZ);
+		_md->babystepMemZ = eeprom_read_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
+		        s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)));
 
 		// same logic as in babystep_load
 	    if (calibration_status() >= CALIBRATION_STATUS_LIVE_ADJUST)
@@ -3126,7 +3127,15 @@ static void lcd_babystep_z()
 	if (LCD_CLICKED || menu_leaving)
 	{
 		// Only update the EEPROM when leaving the menu.
-		EEPROM_save_B(EEPROM_BABYSTEP_Z, &_md->babystepMemZ);
+		eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
+                s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)),
+		        _md->babystepMemZ);
+		eeprom_update_byte(&(EEPROM_Sheets_base->s[(eeprom_read_byte(
+		        &(EEPROM_Sheets_base->active_sheet)))].bed_temp),
+		        target_temperature_bed);
+		eeprom_update_byte(&(EEPROM_Sheets_base->s[(eeprom_read_byte(
+		        &(EEPROM_Sheets_base->active_sheet)))].pinda_temp),
+		        current_temperature_pinda);
 		calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
 	}
 	if (LCD_CLICKED) menu_back();