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

add SHOW_CUSTOM_BOOTSCREEN support to HD44780 #26793

Merged

Conversation

ellensp
Copy link
Contributor

@ellensp ellensp commented Feb 14, 2024

Description

Adds SHOW_CUSTOM_BOOTSCREEN to text LCD's (HD44780)
The custom boot screen can include up to 8 custom 5*8 pixel characters

Eg
20x4 custom boot screen test

Requirements

A Text based LCD display, SHOW_CUSTOM_BOOTSCREEN, and a properly configured _Bootscreen.h

Benefits

Adds SHOW_CUSTOM_BOOTSCREEN to text LCD's

Configurations

EG Configuration files for RAMPS + REPRAP_DISCOUNT_SMART_CONTROLLER and _Bootscreen.h

Related Issues

I'm sure this has been asked for a number of times, but cannot quickly locate an issues for it

NOTES:

Need somewhere to put the example _Bootscreen.h for users to find and base theirs on.

Stock Configuration_adv.h needs updated to allow setting SHOW_CUSTOM_BOOTSCREEN with HAS_MARLINUI_HD44780

@thisiskeithb
Copy link
Member

Need somewhere to put the example _Bootscreen.h for users to find and base theirs on.

We have an "AnimationExample" folder in the Configurations repo, so one could be added for this.

@ellensp
Copy link
Contributor Author

ellensp commented Feb 14, 2024

There should probably be a _Bootscreen.h page in the documentation, that documents all the current 128x64 options and the new 20x4 options

@thinkyhead
Copy link
Member

Presumably the call to goto_screen after showing the custom boot screen will revert to either Status Screen or Menu custom characters (for LCD_PRINTER_INFO_IS_BOOTSCREEN). So I just moved the new code to set_custom_characters. I also applied more specific names…

TERN_(HAS_CUSTOM_BOOT_CHAR_0, createChar_P(0x0, customBootChar0));

…so you'll want to adjust your example custom boot screen to match these updated names.

@ellensp
Copy link
Contributor Author

ellensp commented Mar 12, 2024

Updated _Bootscreen.h example _Bootscreen.zip

@thinkyhead
Copy link
Member

I've adjusted the code to just use the single array customBootChar[][8] containing all the custom characters.

customBootChars
/**
 * Up to 8 custom characters of 5 x 8 pixels
 * Use an online editor such as https://maxpromer.github.io/LCD-Character-Creator/
 */
const static PROGMEM byte customBootChars[][8] = {
  {         // '\x00'
    B00100,
    B01110,
    B11011,
    B01110,
    B10101,
    B01110,
    B00100,
    B00100
  }, {      // '\x01'
    B00001,
    B00001,
    B00011,
    B00010,
    B00110,
    B10100,
    B11100,
    B01000
  }, {      // '\x02'
    B00000,
    B00000,
    B00011,
    B00100,
    B01000,
    B01000,
    B10001,
    B10001
  }, {      // '\x03'
    B00000,
    B11111,
    B00000,
    B00000,
    B00000,
    B00000,
    B10001,
    B10001
  }, {      // '\x04'
    B00000,
    B00000,
    B11000,
    B00100,
    B00010,
    B00010,
    B10001,
    B10001
  }, {      // '\x05'
    B10000,
    B10000,
    B10000,
    B01000,
    B01000,
    B00100,
    B00011,
    B00000
  }, {      // '\x06'
    B00000,
    B00000,
    B00000,
    B10001,
    B01110,
    B00000,
    B00000,
    B11111
  }, {      // '\x07'
    B00001,
    B00001,
    B00001,
    B00010,
    B00010,
    B00100,
    B11000,
    B00000
  }
};

I'm also thinking the boot screen string may be better defined with strings instead of char arrays (PROGMEM strings stored as a PROGMEM array of string pointers):

#define CHR0 "\x00"
#define CHR1 "\x01"
#define CHR2 "\x02"
#define CHR3 "\x03"
#define CHR4 "\x04"
#define CHR5 "\x05"
#define CHR6 "\x06"
#define CHR7 "\x07"

const char * const custom_boot_lines[] PROGMEM = {
  PSTR(CHR0 " CUSTOM BOOT " CHR2 CHR3 CHR4),
  PSTR(CHR1 " SCREEN TEST " CHR5 CHR6 CHR7)
};

So custom_start_char[n] is a pointer stored in PROGMEM and both the pointer and chars would be fetched with code like this (similar to the code for M111)…

PGM_P const pstr = (PGM_P)pgm_read_ptr(&custom_boot_lines[i]);
const lchar_t c = (lchar_t)pgm_read_byte(&pstr[i]);

@ellensp
Copy link
Contributor Author

ellensp commented Mar 12, 2024

I used char arrays for ease of design. With chars you can easily see in code where each char will be on the display, with strings you have to count spaces to align data to where you want it. But perhaps its not as bad as I imagined ...

@thinkyhead
Copy link
Member

thinkyhead commented Mar 12, 2024

I used char arrays for ease of design.

Although _Bootscreen.h is likely to be generated by a tool, it can't hurt to make it more Human-readable. Using strings (where the boot screen contains no custom chars) the alignment will be easier to see at a glance. Adding custom chars hampers readability unless the custom chars are in the same positions on all lines, which is no guarantee. So I think double-quoted strings are nicer here than char arrays.

Here's the updated _Bootscreen.h that works with the applied changes.

@thinkyhead
Copy link
Member

thinkyhead commented Mar 12, 2024

Another minor update. Of course character 0 has to be treated specially because it's a string terminator. So I just redefined CHR0 as '\x08' (BAK) and that character is replaced during screen drawing. Tested in the simulator.

_Bootscreen.h

@ellensp
Copy link
Contributor Author

ellensp commented Mar 13, 2024

link to _Bootscreen.h is a 404 error for me.

@ellensp
Copy link
Contributor Author

ellensp commented Mar 13, 2024

If using

const char * const custom_boot_lines[] = {
  PSTR(CHR0 " CUSTOM BOOT " CHR2 CHR3 CHR4),
  PSTR(CHR1 " SCREEN TEST " CHR5 CHR6 CHR7)
};

Works on sim, but will not build on 8 bit AVR

Marlin/src/lcd/HD44780/../../../_Bootscreen.h:49:3: error: statement-expressions are not allowed outside functions nor in template-argument lists
PSTR(CHR0 " CUSTOM BOOT " CHR2 CHR3 CHR4),

@thinkyhead
Copy link
Member

The current _Bootscreen and code is fine. Those errors are from an earlier iteration. The link to the file works for me, so perhaps refresh the page.

thinkyhead added a commit to MarlinFirmware/Configurations that referenced this pull request May 18, 2024
MarlinFirmware/Marlin#26793

Co-Authored-By: ellensp <530024+ellensp@users.noreply.github.com>
ini/native.ini Outdated
@@ -113,7 +113,7 @@ build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags}
[simulator_macos]
build_unflags = -lGL -fstack-protector-strong
build_flags =
-DHAS_LIBBSD
-DHAS_LIBBSD -DGLM_ENABLE_EXPERIMENTAL
Copy link
Member

Choose a reason for hiding this comment

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

Is this flag known also known be needed for macOS? I know we just added it for Windows. Maybe some Linux need it too…?

Copy link
Member

Choose a reason for hiding this comment

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

On current bugfix-2.1.x / without this PR, both simulator_macos_debug and simulator_macos_release environments build the default Simulator config fine on my Intel-based Mac.

Copy link
Contributor Author

@ellensp ellensp May 18, 2024

Choose a reason for hiding this comment

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

Not required on Ubuntu 22.04.4 LTS or Ubuntu 24.04 LTS

Copy link
Member

Choose a reason for hiding this comment

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

Sometimes macOS needs it, and probably it's ok to use the flag on Linux, or does it complain?

@ellensp
Copy link
Contributor Author

ellensp commented May 18, 2024

The example _bootscreen link is now working..

At the time I refreshed and even vpned out to another country and tried the link from there,, it was broken.

@ellensp
Copy link
Contributor Author

ellensp commented May 19, 2024

This works as expected.

@thinkyhead thinkyhead merged commit feca9a3 into MarlinFirmware:bugfix-2.1.x May 19, 2024
62 checks passed
@ellensp ellensp deleted the text-custom-boot-screen branch July 16, 2024 14:26
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.

3 participants