From f90c2b1122ead7c8dcb4c9cbf98abf2544b77ee0 Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Thu, 14 Mar 2024 10:02:15 +0900 Subject: [PATCH] boards: seagate: legend: Cleanup `led-strip` alias The led-strip alias can be determined in the base dts file. Remove from overlay files and aggregate to the base dts file. Signed-off-by: TOKITA Hiroshi --- boards/seagate/legend/legend.dts | 1 + .../legend/legend_stm32f070xb_25hdd.overlay | 1 - .../legend/legend_stm32f070xb_25ssd.overlay | 4 --- .../legend/legend_stm32f070xb_35.overlay | 1 - samples/drivers/led_strip/src/main.c | 26 ++++++++----------- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/boards/seagate/legend/legend.dts b/boards/seagate/legend/legend.dts index 521b85e092..245d2c8de7 100644 --- a/boards/seagate/legend/legend.dts +++ b/boards/seagate/legend/legend.dts @@ -22,6 +22,7 @@ aliases { watchdog0 = &iwdg; spi-flash0 = &spi_nor; + led-strip = &led_strip_spi; }; board_id: brd-id { diff --git a/boards/seagate/legend/legend_stm32f070xb_25hdd.overlay b/boards/seagate/legend/legend_stm32f070xb_25hdd.overlay index f4ab4af03e..48a6616e85 100644 --- a/boards/seagate/legend/legend_stm32f070xb_25hdd.overlay +++ b/boards/seagate/legend/legend_stm32f070xb_25hdd.overlay @@ -10,7 +10,6 @@ aliases { pwm-led0 = &pwm_led0; - led-strip = &led_strip_spi; }; led_pwm: pwmleds { diff --git a/boards/seagate/legend/legend_stm32f070xb_25ssd.overlay b/boards/seagate/legend/legend_stm32f070xb_25ssd.overlay index 2f0f4d19ba..e8c26ef09b 100644 --- a/boards/seagate/legend/legend_stm32f070xb_25ssd.overlay +++ b/boards/seagate/legend/legend_stm32f070xb_25ssd.overlay @@ -7,10 +7,6 @@ / { model = "Seagate Legend 2.5 SSD board"; compatible = "legend25_ssd", "seagate,legend25_ssd"; - - aliases { - led-strip = &led_strip_spi; - }; }; &clk_hse { diff --git a/boards/seagate/legend/legend_stm32f070xb_35.overlay b/boards/seagate/legend/legend_stm32f070xb_35.overlay index 3568bf7c31..c3af3d922e 100644 --- a/boards/seagate/legend/legend_stm32f070xb_35.overlay +++ b/boards/seagate/legend/legend_stm32f070xb_35.overlay @@ -10,7 +10,6 @@ aliases { pwm-led0 = &pwm_led0; - led-strip = &led_strip_spi; }; led_pwm: pwmleds { diff --git a/samples/drivers/led_strip/src/main.c b/samples/drivers/led_strip/src/main.c index 77c80e7096..d6dafcd68e 100644 --- a/samples/drivers/led_strip/src/main.c +++ b/samples/drivers/led_strip/src/main.c @@ -45,7 +45,7 @@ static const struct device *const strip = DEVICE_DT_GET(STRIP_NODE); int main(void) { - size_t cursor = 0, color = 0; + size_t color = 0; int rc; if (device_is_ready(strip)) { @@ -57,24 +57,20 @@ int main(void) LOG_INF("Displaying pattern on strip"); while (1) { - memset(&pixels, 0x00, sizeof(pixels)); - memcpy(&pixels[cursor], &colors[color], sizeof(struct led_rgb)); - rc = led_strip_update_rgb(strip, pixels, STRIP_NUM_PIXELS); + for (size_t cursor = 0; cursor < ARRAY_SIZE(pixels); cursor++) { + memset(&pixels, 0x00, sizeof(pixels)); + memcpy(&pixels[cursor], &colors[color], sizeof(struct led_rgb)); - if (rc) { - LOG_ERR("couldn't update strip: %d", rc); - } - - cursor++; - if (cursor >= STRIP_NUM_PIXELS) { - cursor = 0; - color++; - if (color == ARRAY_SIZE(colors)) { - color = 0; + rc = led_strip_update_rgb(strip, pixels, STRIP_NUM_PIXELS); + if (rc) { + LOG_ERR("couldn't update strip: %d", rc); } + + k_sleep(DELAY_TIME); } - k_sleep(DELAY_TIME); + color = (color + 1) % ARRAY_SIZE(colors); } + return 0; }