Fastled Wipe In and Wipe Out effect

Hi,

I have been playing around with a Wipe In / Wipe Out effect, but somehow the Wipe Out effect takes 3-4 seconds before actually executing. The Wipe In is instant.

I have tried several Wipe Out effects I could find, but they all have the same issue.

light:
  - platform: fastled_clockless
    chipset: WS2812
    id: fastled1
    pin: 5
    num_leds: 239
    rgb_order: BRG
    name: "$long_devicename - boven"
    effects:
      - addressable_lambda:
          name: "Wipe Out"
          update_interval: 1ms
          lambda: |-
            static int x = 0;
            if (initial_run) {
              x = it.size();
            }
            if (x > 0) {
              x -= 1; 
              it[x] = ESPColor(0,0,0);
            }
      - addressable_lambda:
          name: "Wipe In"
          update_interval: 1ms
          lambda: |-
            if (initial_run) {
            it.all() = ESPColor::BLACK;
            return;
            }
            for (int i = it.size() - 1; i > 0; i--) {
                it[i] = it[i - 1].get();
            }
            for (int i = it.size() - 1; i > 0; i--) {
                it[i] = it[i - 1].get();
            }
            it[0] = current_color;

I See the ‘Wipe Out’ in the logs instantly after selecting it

[17:50:17][D][light:035]: 'Kantoor led wand - boven' Setting:
[17:50:17][D][light:108]:   Effect: 'Wipe Out'

but the effect takes a good 3-4 seconds after that, before actually executing:
Does anyone have a solution for this?

Your Wipe Out effect will only set led Led colors if initial_run is true. Otherwise x is 0.
Try removing the if (initial_run) statement and change static int x = 0 to static x = it.size()

Like this?

    effects:
      - addressable_lambda:
          name: "Wipe Out"
          update_interval: 1ms
          lambda: |-
            static x = it.size()
            if (x > 0) {
              x -= 1; 
              it[x] = ESPColor(0,0,0);
            }

Then I get:

Compiling /data/esp32-et-al01-kantoor/.pioenvs/esp32-et-al01-kantoor/src/main.cpp.o
/config/esphome/esp32-et-al01-kantoor.yaml: In lambda function:
/config/esphome/esp32-et-al01-kantoor.yaml:68:14: error: 'x' does not name a type
             static x = it.size()
              ^
*** [/data/esp32-et-al01-kantoor/.pioenvs/esp32-et-al01-kantoor/src/main.cpp.o] Error 1
========================== [FAILED] Took 3.15 seconds ==========================

That should be: static int x = it.size();

That one compiles, but the Wipe out effect does not work at all. The Wipe In does.

Config:

  - platform: fastled_clockless
    chipset: WS2812
    id: fastled1
    pin: 5
    num_leds: 239
    rgb_order: BRG
    name: "$long_devicename - boven"
    effects:
      - addressable_lambda:
          name: "Wipe Out"
          update_interval: 1ms
          lambda: |-
            static int x = it.size();
            if (x > 0) {
              x -= 1; 
              it[x] = ESPColor(0,0,0);
            }
      - addressable_lambda:
          name: "Wipe In"
          update_interval: 1ms
          lambda: |-
            if (initial_run) {
            it.all() = ESPColor::BLACK;
            return;
            }
            for (int i = it.size() - 1; i > 0; i--) {
                it[i] = it[i - 1].get();
            }
            for (int i = it.size() - 1; i > 0; i--) {
                it[i] = it[i - 1].get();
            }
            it[0] = current_color;

Does this mean that if your LED’s are lid up and you call the Wipe Out effect the LED remains on and with same color?

Yes, that is what happens.

Did you see the warning here:

You could try NeoPixelBus Light

Yes I did, but that only involves the ESP8266 and I am using ESP32.
I tried Neopixelbus light anyway, but the same result.

Full config:

substitutions:
  devicename: esp32-et-al01-kantoor
  long_devicename: Kantoor led wand

esphome:
  name: $devicename
  comment: $long_devicename

esp32:
  board: mhetesp32minikit
  framework:
    type: arduino

wifi:
  ssid: !secret esphome_wifi_ssid
  password: !secret esphome_wifi_password
  power_save_mode: high
  ap:
    ssid: $devicename
    password: !secret esphome_ap_password

captive_portal:

logger:

api:
  password: !secret esphome_api_password

ota:
  password: !secret esphome_ota_password
  
web_server:
  port: 80

output:
  - platform: ledc
    pin: 26
    frequency: 25000Hz
    id: chan1
    max_power: 90%
  - platform: ledc
    pin: 18
    frequency: 25000Hz
    id: chan2
    max_power: 90%

light:
  - platform: cwww
    name: "$long_devicename - onder"
    cold_white: chan1
    warm_white: chan2
    cold_white_color_temperature: 6536 K
    warm_white_color_temperature: 2000 K
    constant_brightness: true

#  - platform: fastled_clockless
#    chipset: WS2812
#    id: fastled1
#    pin: 5
#    num_leds: 239
#    rgb_order: BRG
  - platform: neopixelbus
    type: GRB
    variant: WS2812
    pin: 5
    num_leds: 239
    name: "$long_devicename - boven"
    effects:
      - addressable_lambda:
          name: "Wipe Out"
          update_interval: 1ms
          lambda: |-
            static int x = it.size();
            if (x > 0) {
              x -= 1; 
              it[x] = ESPColor(0,0,0);
            }
      - addressable_lambda:
          name: "Wipe In"
          update_interval: 1ms
          lambda: |-
            if (initial_run) {
            it.all() = ESPColor::BLACK;
            return;
            }
            for (int i = it.size() - 1; i > 0; i--) {
                it[i] = it[i - 1].get();
            }
            for (int i = it.size() - 1; i > 0; i--) {
                it[i] = it[i - 1].get();
            }
            it[0] = current_color;

Sorry but I can’t tell you what’s wrong or causing this.
Here is some of things that I would do as debugging steps.

  1. Create a new effect (Wipe Out 2) and reuse the code from the “Wipe Out”
  2. Instead of ESPColor(0,0,0) try something else like ESPColor(x,x,x) to see if this has any effect
  3. Reuse the code you have in your Wipe In effect but change the sequence so it gives you the Wipe Out effect.

Hi, thanks. How do I do just that (change the sequence)?

Hi!

Would it be possible to combine the wipe-in and wipe-out effects into one singe effect?

      - addressable_lambda:
          name: "Wipe In"
          update_interval: 70ms
          lambda: |-
            static int x = 0;
            if (initial_run) {
              x = 0;
              it.all() = ESPColor(0,0,0);
            }
            if (x < it.size()) {
              it[x] = current_color;
              x += 1;
            }

      - addressable_lambda:
          name: "Wipe Out"
          update_interval: 70ms
          lambda: |-
            static int x = 0;
            if (initial_run) {
              x = it.size();
            }
            if (x > 0) {
              x -= 1; 
              it[x] = ESPColor(0,0,0);
            }

I currently rely on a script with a loop to turn on wipe-in followed by wipe-out indefinetely, but it has some disadvantages.