Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M850 add possibility to set sheet as active #4328

Merged
merged 6 commits into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7724,14 +7724,14 @@ SERIAL_PROTOCOLPGM("\n\n");

case 850: {
//! ### M850 - set sheet parameters
//! //!@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;
//! //!@n M850 - Set sheet data S[id] Z[offset] L[label] B[bed_temp] P[PINDA_TEMP] A[IS_ACTIVE]
uint8_t iSel = 0;
int16_t zraw = 0;
float z_val = 0;
char strLabel[8];
uint8_t iBedC = 0;
uint8_t iPindaC = 0;
bool bIsActive=false;
strLabel[7] = '\0'; // null terminate.
size_t max_sheets = sizeof(EEPROM_Sheets_base->s)/sizeof(EEPROM_Sheets_base->s[0]);

Expand All @@ -7747,6 +7747,7 @@ SERIAL_PROTOCOLPGM("\n\n");
} else {
break;
}

if (code_seen('Z')){
z_val = code_value();
zraw = z_val*cs.axis_steps_per_mm[Z_AXIS];
Expand All @@ -7755,7 +7756,7 @@ SERIAL_PROTOCOLPGM("\n\n");
SERIAL_PROTOCOLLNPGM(" Z VALUE OUT OF RANGE");
break;
}
bHasZ = true;
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[iSel].z_offset)),zraw);
}
else
{
Expand All @@ -7765,13 +7766,13 @@ SERIAL_PROTOCOLPGM("\n\n");

if (code_seen('L'))
{
bHasLabel = true;
char *src = strchr_pointer + 1;
while (*src == ' ') ++src;
if (*src != '\0')
{
strncpy(strLabel,src,7);
}
eeprom_update_block(strLabel,EEPROM_Sheets_base->s[iSel].name,sizeof(Sheet::name));
}
else
{
Expand All @@ -7780,8 +7781,8 @@ SERIAL_PROTOCOLPGM("\n\n");

if (code_seen('B'))
{
bHasBed = true;
iBedC = code_value_uint8();
eeprom_update_byte(&EEPROM_Sheets_base->s[iSel].bed_temp, iBedC);
}
else
{
Expand All @@ -7790,35 +7791,29 @@ SERIAL_PROTOCOLPGM("\n\n");

if (code_seen('P'))
{
bHasPinda = true;
iPindaC = code_value_uint8();
eeprom_update_byte(&EEPROM_Sheets_base->s[iSel].pinda_temp, iPindaC);
}
else
{
iPindaC = eeprom_read_byte(&EEPROM_Sheets_base->s[iSel].pinda_temp);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to have an empty line like the other block


if (code_seen('A'))
gudnimg marked this conversation as resolved.
Show resolved Hide resolved
{
bIsActive |= code_value_uint8() || (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == iSel);
if(bIsActive) eeprom_update_byte(&EEPROM_Sheets_base->active_sheet, iSel);
}
else
{
wavexx marked this conversation as resolved.
Show resolved Hide resolved
bIsActive = (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == iSel);
gudnimg marked this conversation as resolved.
Show resolved Hide resolved
}

SERIAL_PROTOCOLPGM("Sheet ");
SERIAL_PROTOCOL((int)iSel);
if (!eeprom_is_sheet_initialized(iSel))
SERIAL_PROTOCOLLNPGM(" NOT INITIALIZED");

if (bHasZ)
{
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[iSel].z_offset)),zraw);
}
if (bHasLabel)
{
eeprom_update_block(strLabel,EEPROM_Sheets_base->s[iSel].name,sizeof(Sheet::name));
}
if (bHasBed)
{
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");
SERIAL_PROTOCOL_F(z_val,4);
Expand All @@ -7830,7 +7825,8 @@ SERIAL_PROTOCOLPGM("\n\n");
SERIAL_PROTOCOL((int)iBedC);
SERIAL_PROTOCOLPGM(" P");
SERIAL_PROTOCOLLN((int)iPindaC);

SERIAL_PROTOCOLPGM(" A");
SERIAL_PROTOCOLLN((int)bIsActive);
break;
}

Expand Down