Skip to content

LCD: refactor MKS H43 display code and UI #27776

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

Merged
merged 27 commits into from
Apr 5, 2025

Conversation

narno2202
Copy link
Contributor

Description

For my personal use, I have refactored the MKS H43 code and I am submitting this PR.

Summary of changes :

  1. Fix compiler warnings
  2. Fix some bugs related to typos.
  3. Comment variables absent from MKS H43 firmwares (1.30, 1.31)
  4. Improve UI wording : text more consistent with the supposed function (for example "Steps/mm" instead of "MotorPluse")
  5. Change variable names accordingly

Requirements

MKS H43 display

Benefits

More consistency in the UI, bug fix

Configurations

Related Issues

@narno2202
Copy link
Contributor Author

narno2202 commented Apr 1, 2025

Some screenshots :

Before After
Before 1 After 1
Before After 1 After 2
Before 2 After 2 After 21

@thinkyhead
Copy link
Member

Looking pretty good, but there were a variety of actual bugs. I'll merge all the cosmetic changes separately so the more relevant changes will be more obvious here … for posterity.

@thinkyhead thinkyhead force-pushed the MKS_H43 branch 2 times, most recently from 36542b7 to 1bd6a75 Compare April 2, 2025 09:36
@thinkyhead
Copy link
Member

thinkyhead commented Apr 3, 2025

Strings in Arduino can sometimes be tricky to understand and we haven't propagated consistent string usage to all parts of the code yet, sorry about that.

FTOP(F("String")) can be replaced with PSTR("String") … but it is preferable to use F() as arguments because a PSTR cannot be differentiated from a const char *. Polymorphic methods taking FSTR_P should have plain names like sendInfoScreen, but methods that require (or expect) PSTR_P should be named with a _P suffix to clearly indicate that all the const char * (PSTR) arguments refer to Flash and not RAM, e.g., sendInfoScreen_P.

Speaking of sendInfoScreen, the method declarations are all outdated. They take flags to indicate whether a given string argument is in RAM or Flash. Since our use of __FlashStringHelper makes it possible to detect F() strings at compile time we can now do proper polymorphism. Then we can add methods to handle special cases where F() and PSTR() strings are meant to be mixed with C-strings.

@thinkyhead
Copy link
Member

As with the FTOP(F()) redundancy, FTOP(GET_TEXT_F(MSG_HALTED)) should be GET_TEXT(MSG_HALTED) to get the PSTR form of the named string.

@thinkyhead thinkyhead merged commit c5de0c6 into MarlinFirmware:bugfix-2.1.x Apr 5, 2025
65 checks passed
@narno2202 narno2202 deleted the MKS_H43 branch April 5, 2025 08:27
thinkyhead pushed a commit that referenced this pull request Apr 7, 2025
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 15, 2025
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants