Skip to content

Accept struct color types in setBaseColor() and setTextColor() - #358

Merged
lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:struct_color_palette
Oct 15, 2026
Merged

lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:struct_color_palette

Conversation

@ainyan03

Copy link
Copy Markdown
Contributor

Accept struct color types in setBaseColor() and setTextColor()

  • setBaseColor(), setTextColor() (one and two arguments) and the functions that call setBaseColor() (clear(), clearDisplay(), setScrollRect() with a color) failed to compile when given a struct color type such as lgfx::rgb565_t or lgfx::rgb888_t (cannot convert 'lgfx::v1::rgb565_t' to 'uint32_t'). This happened for every target, not only sprites with a palette, because the palette branch is compiled in any case.
  • The value for the palette branch is now cast explicitly. With a palette, the value is used as the palette index, the same as setColor(). Without a palette, it is converted to RGB888 as before. Numeric color types behave as before.

Testing

  • A sketch calling these functions with rgb332_t, rgb565_t, rgb888_t, argb8888_t, bgr888_t, bgr666_t and swap565_t (plus uint16_t / uint32_t) builds on ESP-IDF 5.1 to 6.1 and Arduino 2.x / 3.x (the versions in this repository's CI, all chips) and the native (SDL) build. It failed to compile before this change. CI on the fork: passed.

With a palette, these functions stored the given value as is, which needed an
implicit conversion to uint32_t. The struct color types (rgb565_t, rgb888_t, ...)
only convert explicitly, so passing one failed to compile even when drawing to a
display without a palette. The value is now cast explicitly: with a palette it is
used as the palette index, as setColor() already does; without one it is converted
to RGB888 as before.
@lovyan03
lovyan03 merged commit 48dcff4 into m5stack:develop Oct 15, 2026
25 checks passed
@ainyan03
ainyan03 deleted the struct_color_palette branch October 15, 2026 12:12
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.

2 participants