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

Conversation

dawidpieper
Copy link
Contributor

#2201 added possibility to set sheet parameters using new M850 gCode, but there still lacks possibility to set or check what sheet is active.
Added A parameter to set sheet as Active.
Related to #3610

New usage

M850 S[sheet] Z[offset] L[label] B[Bed temp] P[PINDA temp] A[is active]

  • A1 enables the selected sheet
    • If A set to 0 or missing, current status is reported

@github-actions
Copy link

github-actions bot commented Aug 15, 2023

Target ΔFlash (bytes) ΔSRAM (bytes)
MK3S_MULTILANG 136 0
MK3_MULTILANG 114 0

@dawidpieper
Copy link
Contributor Author

My oversight. Now I standardized the formatting in all the code responsible for this gCode.

Copy link
Collaborator

@wavexx wavexx left a comment

Choose a reason for hiding this comment

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

Looks very sensible to me. @gudnimg what do you think?

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

Firmware/Marlin_main.cpp Outdated Show resolved Hide resolved
@dawidpieper
Copy link
Contributor Author

I made suggested optimizations, but as for the last if statement, I think the code may be a bit less readable now. Previously only conditions for bHasXXX were used and I think the compiler optimizes it well. But these are only my feelings. :)

@gudnimg
Copy link
Collaborator

gudnimg commented Aug 16, 2023

Code size seems to have increased according to our Github bot 🤔 I wonder why
image

@dawidpieper
Copy link
Contributor Author

I don't know AVR architecture as well. In fact I'm not sure if statement
bIsActive |= code_value_uint8() || (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == iSel);
is calculated in RAM or CPU registers.
May it be the issue here?

@gudnimg
Copy link
Collaborator

gudnimg commented Aug 16, 2023

It's measured in Flash memory and SRAM. The if statement is in Flash memory, while global variables and static variables are in SRAM.

I usually stash my changes and check the current build stats:

Then re-apply my stash and re-build to check if the optimisation reduces code size (memory). We try to save memory whenever we can as we don't have much left of Flash (94% full).
image

Copy link
Collaborator

@gudnimg gudnimg left a comment

Choose a reason for hiding this comment

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

Approving, but I have not tested the changes.

@dawidpieper
Copy link
Contributor Author

Thanks, original commit seemed to work on MK3S+. I have no access to printer now to check the last one, if no one overtakes me, I'll do it tomorrow or the day after tomorrow.

@dawidpieper
Copy link
Contributor Author

We can reduce flash usage by 14 bytes (MK3S) that way. Is it okay?

@gudnimg
Copy link
Collaborator

gudnimg commented Aug 16, 2023

We can reduce flash usage by 14 bytes (MK3S) that way. Is it okay?

Sounds good 💪

@3d-gussner 3d-gussner added this to the FW 3.14.0 milestone Aug 22, 2023
@dawidpieper
Copy link
Contributor Author

Seems to work on MK3S plus with MMU2S

@3d-gussner 3d-gussner merged commit c84985e into prusa3d:MK3 Sep 11, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants