A component for ESPHome that enables use of the RGBDigit. Similar to a TM1637, but with RGB color for each segment.
Example:
external_components:
- source: github://calumr/rgbdigit-esphome@master
# Example configuration entry
display:
- platform: rgbdigit
pin: 4
num_digits: 4
update_interval: 0.1s
lambda: |-
const auto now = id(sntp_time).now();
const char * fmt = now.second % 2 ? "%l.%M" : "%l%M";
it.strftime(Color::WHITE, fmt, now);
rainbow_colours(it, 4.0f, 255);
- pin (Required): The pin you have the data line hooked up to.
- num_digits (Required, integer): The number of RGBDigits.
- lambda (Optional): The lambda to use for rendering the content on the RGBDigits. See "Rendering Lambda" below for more information.
- update_interval (Optional): The interval to re-draw the screen. Defaults to
1s
. - id (Optional): Manually specify the ID used for code generation.
The RGBDigit has a similar API to the fully fledged Display, but it's only a subset as the RGBDigit
7-segment displays don't have a concept of individual pixels. In the lambda you're passed a variable called it
as with all other displays. In this case however, it
is a RGBDigitDisplay instance (see API Reference).
display:
- platform: rgbdigit
# ...
lambda: |-
it.print(Color{255, 0, 0}, "12.34"); // Prints "12.34" in red
it.set_color(2, Color{0, 255, 0}); // Sets digit 2 to green
it.set_color(1, 7, Color{0, 0, 255}); // Sets the decimal point (segment 7) to blue
Please see Formatted Text] for a quick introduction into the printf
formatting rules and
Displaying Time for an introduction into the strftime
time formatting.