From 6ad105f91fa20f15093497841acff949cb40aa80 Mon Sep 17 00:00:00 2001 From: vintagepc Date: Thu, 12 Sep 2019 18:32:13 -0400 Subject: [PATCH 1/4] Add M850 code for setting sheet label and offsets --- Firmware/Marlin_main.cpp | 84 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) mode change 100755 => 100644 Firmware/Marlin_main.cpp diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp old mode 100755 new mode 100644 index 607d028b5..970cb69f3 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3429,6 +3429,7 @@ extern uint8_t st_backlash_y; //!@n M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) //!@n M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] //!@n M605 - Set dual x-carriage movement mode: S [ X R ] +//!@n M850 - Set sheet data S[id] Z[offset] L[label] //!@n M860 - Wait for PINDA thermistor to reach target temperature. //!@n M861 - Set / Read PINDA temperature compensation offsets //!@n M900 - Set LIN_ADVANCE options, if enabled. See Configuration_adv.h for details. @@ -7209,6 +7210,89 @@ Sigma_Exit: case 603: { lcd_print_stop(); } + + case 850: { + //! ### M850 - set sheet parameters + //! //!@n M850 - Set sheet data S[id] Z[offset] L[label] + bool bHasZ = false, bHasLabel = false; + uint8_t iSel = 0; + int16_t zraw = 0; + float z_val = 0; + char strLabel[8]; + strLabel[7] = '\0'; // null terminate. + size_t max_sheets = sizeof(EEPROM_Sheets_base->s)/sizeof(EEPROM_Sheets_base->s[0]); + + if (code_seen('S')) { + iSel = code_value_uint8(); + if (iSel>=max_sheets) + { + SERIAL_PROTOCOLPGM("Invalid sheet ID. Allowed: 0.."); + SERIAL_PROTOCOL(max_sheets-1); + SERIAL_PROTOCOLLN(""); + break; // invalid sheet ID + } + } else { + break; + } + if (code_seen('Z')){ + z_val = code_value_float(); + zraw = z_val*cs.axis_steps_per_unit[Z_AXIS]; + if ((zraw < Z_BABYSTEP_MIN) || (zraw > Z_BABYSTEP_MAX)) + { + SERIAL_PROTOCOLLNPGM(" Z VALUE OUT OF RANGE"); + break; + } + bHasZ = true; + } + + if (code_seen('L')) + { + bHasLabel = true; + char *src = strchr_pointer + 1; + starpos = strchr(src, '*'); + if (starpos != NULL) *(starpos) = '\0'; + while (*src == ' ') ++src; + if (*src != '\0') + { + strncpy(strLabel,src,7); + } + } + + SERIAL_PROTOCOLPGM("Sheet "); + SERIAL_PROTOCOL((int)iSel); + if (!bHasZ && !bHasLabel&& !eeprom_is_sheet_initialized(iSel)) + { + SERIAL_PROTOCOLLNPGM(" NOT INITIALIZED"); + break; + } + + if (bHasZ) + { + eeprom_update_word(reinterpret_cast(&(EEPROM_Sheets_base->s[iSel].z_offset)),zraw); + } + else + { + zraw = eeprom_read_word(reinterpret_cast(&(EEPROM_Sheets_base->s[iSel].z_offset))); + z_val = ((float)zraw/cs.axis_steps_per_unit[Z_AXIS]); + } + if (bHasLabel) + { + eeprom_update_block(strLabel,EEPROM_Sheets_base->s[iSel].name,sizeof(Sheet::name)); + } + else + { + eeprom_read_block(strLabel, EEPROM_Sheets_base->s[iSel].name, 7); + } + + SERIAL_PROTOCOLPGM(" Z"); + SERIAL_PROTOCOL_F(z_val,4); + SERIAL_PROTOCOLPGM(" R"); + SERIAL_PROTOCOL((int)zraw); + SERIAL_PROTOCOLPGM(" L"); + SERIAL_PROTOCOLLN(strLabel); + + break; +} #ifdef PINDA_THERMISTOR //! ### M860 - Wait for extruder temperature (PINDA) From bc31de2201c35ff45d805a4a9d0420ca9499bcca Mon Sep 17 00:00:00 2001 From: vintagepc Date: Fri, 13 Sep 2019 18:17:53 -0400 Subject: [PATCH 2/4] Add Bed/Pinda temp setting support to M850 --- Firmware/Marlin_main.cpp | 61 ++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 970cb69f3..c63febe73 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3429,7 +3429,7 @@ extern uint8_t st_backlash_y; //!@n M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) //!@n M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] //!@n M605 - Set dual x-carriage movement mode: S [ X R ] -//!@n M850 - Set sheet data S[id] Z[offset] L[label] +//!@n M850 - Set sheet data S[id] Z[offset] L[label] B[bed_temp] P[PINDA_TEMP] //!@n M860 - Wait for PINDA thermistor to reach target temperature. //!@n M861 - Set / Read PINDA temperature compensation offsets //!@n M900 - Set LIN_ADVANCE options, if enabled. See Configuration_adv.h for details. @@ -7213,12 +7213,14 @@ Sigma_Exit: case 850: { //! ### M850 - set sheet parameters - //! //!@n M850 - Set sheet data S[id] Z[offset] L[label] - bool bHasZ = false, bHasLabel = false; + //! //!@n M850 - Set sheet data S[id] Z[offset] L[label] B[bed_temp] P[PINDA_TEMP] + bool bHasZ = false, bHasLabel = false, bHasBed = false, bHasPinda = false; uint8_t iSel = 0; int16_t zraw = 0; float z_val = 0; char strLabel[8]; + uint8_t iBedC = 0; + uint8_t iPindaC = 0; strLabel[7] = '\0'; // null terminate. size_t max_sheets = sizeof(EEPROM_Sheets_base->s)/sizeof(EEPROM_Sheets_base->s[0]); @@ -7244,6 +7246,11 @@ Sigma_Exit: } bHasZ = true; } + else + { + zraw = eeprom_read_word(reinterpret_cast(&(EEPROM_Sheets_base->s[iSel].z_offset))); + z_val = ((float)zraw/cs.axis_steps_per_unit[Z_AXIS]); + } if (code_seen('L')) { @@ -7257,31 +7264,51 @@ Sigma_Exit: strncpy(strLabel,src,7); } } + else + { + eeprom_read_block(strLabel, EEPROM_Sheets_base->s[iSel].name, sizeof(Sheet::name)); + } + + if (code_seen('B')) + { + bHasBed = true; + iBedC = code_value_uint8(); + } + else + { + iBedC = eeprom_read_byte(&EEPROM_Sheets_base->s[iSel].bed_temp); + } + + if (code_seen('P')) + { + bHasPinda = true; + iPindaC = code_value_uint8(); + } + else + iPindaC = eeprom_read_byte(&EEPROM_Sheets_base->s[iSel].pinda_temp); + { + } SERIAL_PROTOCOLPGM("Sheet "); SERIAL_PROTOCOL((int)iSel); - if (!bHasZ && !bHasLabel&& !eeprom_is_sheet_initialized(iSel)) - { + if (!eeprom_is_sheet_initialized(iSel)) SERIAL_PROTOCOLLNPGM(" NOT INITIALIZED"); - break; - } if (bHasZ) { eeprom_update_word(reinterpret_cast(&(EEPROM_Sheets_base->s[iSel].z_offset)),zraw); } - else - { - zraw = eeprom_read_word(reinterpret_cast(&(EEPROM_Sheets_base->s[iSel].z_offset))); - z_val = ((float)zraw/cs.axis_steps_per_unit[Z_AXIS]); - } if (bHasLabel) { eeprom_update_block(strLabel,EEPROM_Sheets_base->s[iSel].name,sizeof(Sheet::name)); } - else + if (bHasBed) { - eeprom_read_block(strLabel, EEPROM_Sheets_base->s[iSel].name, 7); + eeprom_update_byte(&EEPROM_Sheets_base->s[iSel].bed_temp, iBedC); + } + if (bHasPinda) + { + eeprom_update_byte(&EEPROM_Sheets_base->s[iSel].pinda_temp, iPindaC); } SERIAL_PROTOCOLPGM(" Z"); @@ -7289,7 +7316,11 @@ Sigma_Exit: SERIAL_PROTOCOLPGM(" R"); SERIAL_PROTOCOL((int)zraw); SERIAL_PROTOCOLPGM(" L"); - SERIAL_PROTOCOLLN(strLabel); + SERIAL_PROTOCOL(strLabel); + SERIAL_PROTOCOLPGM(" B"); + SERIAL_PROTOCOL((int)iBedC); + SERIAL_PROTOCOLPGM(" P"); + SERIAL_PROTOCOLLN((int)iPindaC); break; } From 032d5ebe5bca5eeebaaa94120e94c11b6b4f9445 Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Fri, 17 Feb 2023 08:31:27 -0500 Subject: [PATCH 3/4] Update Marlin_main.cpp Fix use of removed function --- Firmware/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d3d9ee8bd..2ff6e653d 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7737,7 +7737,7 @@ Sigma_Exit: break; } if (code_seen('Z')){ - z_val = code_value_float(); + z_val = code_value(); zraw = z_val*cs.axis_steps_per_unit[Z_AXIS]; if ((zraw < Z_BABYSTEP_MIN) || (zraw > Z_BABYSTEP_MAX)) { From 235ce62cd3a14cb4ba9f021fe1bb289d38533abb Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Fri, 17 Feb 2023 08:58:17 -0500 Subject: [PATCH 4/4] Update Marlin_main.cpp Remove more stale code --- Firmware/Marlin_main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 2ff6e653d..74dae1d0f 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7756,8 +7756,6 @@ Sigma_Exit: { bHasLabel = true; char *src = strchr_pointer + 1; - starpos = strchr(src, '*'); - if (starpos != NULL) *(starpos) = '\0'; while (*src == ' ') ++src; if (*src != '\0') {