I have a couple of max7219 matrix displays joined together as a ‘ticker’ that displays text derived from a sensor defined in Home Assistant. When this sensor is longer than the number of characters that can be displayed it scrolls. This is fine, except whatever I do I cannot get a space between the sentences as they scroll across a screen. So instead of:
"This is a message - This is a message"
I get
"This is a message -This is a message".
Here is my display configuration in esphome:
display:
- platform: max7219digit
id: max7219digitdisplay
cs_pin: GPIO5
scroll_delay: 0s
num_chips: 12
scroll_speed: 20ms
intensity: 1
lambda: |-
std::string text = "";
if (id(display_content).has_state()) {
text = id(display_content).state.c_str();
} else {
text = "No Data";
}
it.printf(0, 0, id(display_font), "%s - ", text.c_str());
But it always trims that space after the hyphen. I have tried:
it.printf(0, 0, id(display_font), "%s%.3s", text.c_str(), " - ");`
and
text += "\u2009"; // Unicode thin space
it.print(0, 0, id(display_font), text.c_str());
(This causes problems because i’m using a 8x8 font with a limit character set so not sure if it would work otherwise).
And I’ve tried anything else I can find from Google, ChatGPT and Claude.AI. Padding is usually based on the string being a fixed width but this string could be any length.
Anybody got any ideas?