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

drivers: display: Add LED-Strip matrix display driver #68614

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

soburi
Copy link
Member

@soburi soburi commented Feb 6, 2024

This type of product is available from Adafruit's Adafruit NeoPixel Shield for Arduino.
But electrically, it is just an LED strip, so it is a general-purpose product.
https://www.adafruit.com/product/1430

There is no problem in merging this patch itself, but
Changes may occur depending on the progress of #68514 and #67610.


I verify this PR with 16x16 WS2812 matrix with following overlay.

  • samples/drivers/display/boards/rpi_pico.overlay
#include <zephyr/dt-bindings/led/led.h>
#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>

/ {
        aliases {
                led-strip = &ws2812;
        };
};

&pinctrl {
        ws2812_pio0_default: ws2812_pio0_default {
                ws2812 {
                        pinmux = <PIO0_P21>;
                };
        };
};

&pio0 {
        status = "okay";

        pio-ws2812 {
                compatible = "worldsemi,ws2812-rpi_pico-pio";
                status = "okay";
                pinctrl-0 = <&ws2812_pio0_default>;
                pinctrl-names = "default";
                bit-waveform = <3>, <3>, <4>;

                ws2812: ws2812 {
                        status = "okay";
                        output-pin = <21>;
                        chain-length = <255>;
                        color-mapping = <LED_COLOR_ID_GREEN
                                         LED_COLOR_ID_RED
                                         LED_COLOR_ID_BLUE>;
                        reset-delay = <280>;
                        frequency = <800000>;
                };

        };
};

/ {
        chosen {
                zephyr,display = &led_strip_matrix;
        };

        led_strip_matrix: led-strip-matrix {
                compatible = "led-strip-matrix";
                status = "okay";

                led-strip = <&ws2812>;
                width = <16>;
                height = <16>;
                start-from-right;
        };
};
  • samples/drivers/display/boards/rpi_pico.conf
CONFIG_WS2812_STRIP_RPI_PICO_PIO=y
CONFIG_LOG=y
CONFIG_LED_STRIP=y
CONFIG_LED_STRIP_LOG_LEVEL_DBG=y
CONFIG_WS2812_STRIP=y

@soburi soburi force-pushed the led-strip-matrix-driver branch 2 times, most recently from d4a7fcb to 14b73c7 Compare February 6, 2024 10:50
@soburi soburi marked this pull request as ready for review February 6, 2024 11:54
@zephyrbot zephyrbot added area: Devicetree Binding PR modifies or adds a Device Tree binding area: Display labels Feb 6, 2024
dts/bindings/display/led-strip-matrix.yaml Show resolved Hide resolved
dts/bindings/display/led-strip-matrix.yaml Outdated Show resolved Hide resolved
dts/bindings/display/led-strip-matrix.yaml Outdated Show resolved Hide resolved
@simonguinot
Copy link
Collaborator

This is fun :)

Copy link
Member

@fabiobaltieri fabiobaltieri left a comment

Choose a reason for hiding this comment

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

Cool, can you also add a build case in tests/drivers/build_all/display/?

drivers/display/Kconfig.led_strip_matrix Show resolved Hide resolved
drivers/display/display_led_strip_matrix.c Outdated Show resolved Hide resolved
drivers/display/display_led_strip_matrix.c Outdated Show resolved Hide resolved
drivers/display/display_led_strip_matrix.c Outdated Show resolved Hide resolved
drivers/display/display_led_strip_matrix.c Outdated Show resolved Hide resolved
drivers/display/display_led_strip_matrix.c Outdated Show resolved Hide resolved
drivers/display/display_led_strip_matrix.c Outdated Show resolved Hide resolved
@soburi soburi force-pushed the led-strip-matrix-driver branch from 14b73c7 to edd43aa Compare February 8, 2024 06:30
@fabiobaltieri
Copy link
Member

@soburi give it a rebase, the display test was broken and the format changed

@soburi
Copy link
Member Author

soburi commented Feb 8, 2024

@fabiobaltieri

@soburi give it a rebase, the display test was broken and the format changed

Thank you for the notification.
I'm correcting the points raised in the review now, so I will address it together.

@soburi soburi force-pushed the led-strip-matrix-driver branch 4 times, most recently from 82fbd38 to 7d9f1a6 Compare February 8, 2024 23:19
@soburi soburi changed the title drivers: display: Add LED-Strip matrix display driver. drivers: display: Add LED-Strip matrix display driver Feb 8, 2024
Copy link
Member

@fabiobaltieri fabiobaltieri left a comment

Choose a reason for hiding this comment

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

Cool! Just a nitpicky comments about variable names from me.

drivers/display/display_led_strip_matrix.c Outdated Show resolved Hide resolved
@soburi soburi requested a review from fabiobaltieri February 9, 2024 21:21
@soburi soburi force-pushed the led-strip-matrix-driver branch from 7d9f1a6 to 6a96534 Compare February 9, 2024 21:26
fabiobaltieri
fabiobaltieri previously approved these changes Feb 9, 2024
@soburi
Copy link
Member Author

soburi commented Feb 28, 2024

@kartben
Could you take a look, please?

Copy link
Collaborator

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

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

Hi @soburi,

Thanks for this nice driver. I will definitely use it !

Please find few comments and questions below. I'll try to review the code next week.

dts/bindings/display/led-strip-matrix.yaml Outdated Show resolved Hide resolved
[ 7][ 6][ 5][ 4]
[11][10][ 9][ 8]
[15][14][13][12]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should you also handle the case where the first LED is at the bottom of the display matrix ? start-from-bottom ?

Copy link
Member Author

@soburi soburi Mar 3, 2024

Choose a reason for hiding this comment

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

Added start-from-bottom.


* Modules are arranged circulative from top left to bottom right.
[M0][M1]
[M2][M3]
Copy link
Collaborator

Choose a reason for hiding this comment

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

And what about supporting a serpentine layout of modules ? :)

Is it common to have a large grid/array of LED assembled from several smaller modules ?

Copy link
Member Author

@soburi soburi Mar 3, 2024

Choose a reason for hiding this comment

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

Since I was expecting a module like this that the user could connect with the connector, I didn't give much thought to the arrangement of the modules. However, the serpentine arrangement can have shorter wiring.
The placement can now be specified using the same rules as for LEDs.

tests/drivers/build_all/display/app.overlay Outdated Show resolved Hide resolved
drivers/display/display_led_strip_matrix.c Outdated Show resolved Hide resolved
description: |
Specify the LED strip that is the substance of the matrix.
If more than one element is specified, split the matrix into multiple strips.
The amount of LEDs must equal the [width * height] value.
Copy link
Collaborator

@simonguinot simonguinot Mar 1, 2024

Choose a reason for hiding this comment

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

Maybe it is worth mentioning that the phandles of LED strip controllers must be ordered based on their position in the "flattened" chain of pixels, and that the strip controller must be chained "simply" (i.e. all LEDs of controller 1, all LED of controller 2, etc).

Copy link
Member Author

Choose a reason for hiding this comment

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

Added explanation. Could you check, please?

fabiobaltieri
fabiobaltieri previously approved these changes Mar 4, 2024
Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

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

this is very cool stuff! ❤️


width:
description: |
Specifies the overall `width` of the matrix.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit to be consistent with height:

Suggested change
Specifies the overall `width` of the matrix.
Specifies the overall width of the matrix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed it.

Comment on lines 176 to 177
caps->supported_pixel_formats = PIXEL_FORMAT_ARGB_8888;
caps->current_pixel_format = PIXEL_FORMAT_ARGB_8888;
Copy link
Collaborator

Choose a reason for hiding this comment

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

btw was there a reason for not using PIXEL_FORMAT_RGB_888? It doesn't look like alpha channel can be used in any meaningful way so having 24-bit per colour instead of 32 could save quite a bit of memory.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed to be able to select pixel format on devicetree.

Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

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

on a second thought, adding back a request for change regarding my latest comment about pixel format.

@soburi soburi force-pushed the led-strip-matrix-driver branch 2 times, most recently from 5c635a1 to 7d6239f Compare March 5, 2024 01:17
@soburi soburi requested review from kartben and fabiobaltieri March 5, 2024 02:52
Comment on lines 180 to 181
This property only accept PANEL_PIXEL_FORMAT_RGB_888 and PANEL_PIXEL_FORMAT_RRGB_8888.
If not set this property, the behavior is same as selecting PANEL_PIXEL_FORMAT_RGB_888.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This property only accept PANEL_PIXEL_FORMAT_RGB_888 and PANEL_PIXEL_FORMAT_RRGB_8888.
If not set this property, the behavior is same as selecting PANEL_PIXEL_FORMAT_RGB_888.
This property only accepts PANEL_PIXEL_FORMAT_RGB_888 and PANEL_PIXEL_FORMAT_RRGB_8888.
If this property is not set, the behavior is same as selecting PANEL_PIXEL_FORMAT_RGB_888.

Copy link
Collaborator

Choose a reason for hiding this comment

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

btw why not just use PANEL_PIXEL_FORMAT_RGB_888 (1) as a default value here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't deeply consider it. It's easier to understand if you explicitly set the default value, so I've modified it that way.

Adds a driver for a display of LED strips arranged in a grid.

Signed-off-by: TOKITA Hiroshi <[email protected]>
@soburi soburi force-pushed the led-strip-matrix-driver branch from 7d6239f to 3ad79a5 Compare March 5, 2024 09:53
@soburi soburi requested a review from kartben March 5, 2024 10:39
@nashif nashif merged commit ca520f8 into zephyrproject-rtos:main Mar 5, 2024
21 checks passed
@soburi soburi deleted the led-strip-matrix-driver branch March 5, 2024 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants