ws2812使用esphome代码实现流水灯
各位大佬,用esphome 源码实现ws2812流水灯效果,有好的办法吗?light:- platform: neopixelbus name: "NeoPixel Light" id: ceshi type: GRB variant: WS2812 pin: GPIO3 num_leds: 16 internal: true- platform: partition name: "Partition Light 1" id: ceshi1 flash_transition_length: 0ms default_transition_length: 0ms on_turn_on: - light.turn_on: ceshi2 - light.turn_on: ceshi3 - light.turn_on: ceshi4 - light.turn_on: ceshi5 - light.turn_on: ceshi6 - light.turn_on: ceshi7 - light.turn_on: ceshi8 - light.turn_on: ceshi9 - light.turn_on: ceshi10 - light.turn_on: ceshi11 - light.turn_on: ceshi12 - light.turn_on: ceshi13 - light.turn_on: ceshi14 - light.turn_on: ceshi15 - light.turn_on: ceshi16 on_turn_off: - light.turn_off: ceshi2 - light.turn_off: ceshi3 - light.turn_off: ceshi4 - light.turn_off: ceshi5 - light.turn_off: ceshi6 - light.turn_off: ceshi7 - light.turn_off: ceshi8 - light.turn_off: ceshi9 - light.turn_off: ceshi10 - light.turn_off: ceshi11 - light.turn_off: ceshi12 - light.turn_off: ceshi13 - light.turn_off: ceshi14 - light.turn_off: ceshi15 - light.turn_off: ceshi16 segments: # Use first 10 LEDs from the light with ID light1 - id: ceshi from: 0 to: 0- platform: partition name: "Partition Light 2" id: ceshi2 flash_transition_length: 500ms default_transition_length: 500ms internal: true segments: # Use LEDs 11-20 from the light with ID light1 - id: ceshi from: 1 to: 1- platform: partition name: "Partition Light 3" id: ceshi3 flash_transition_length: 1s default_transition_length: 1s internal: true segments: # Use LEDs 11-20 from the light with ID light1 - id: ceshi from: 2 to: 2- platform: partition name: "Partition Light 4" id: ceshi4 flash_transition_length: 1500ms default_transition_length: 1500ms internal: true segments: # Use LEDs 11-20 from the light with ID light1 - id: ceshi from: 3 to: 3- platform: partition name: "Partition Light 5" id: ceshi5 flash_transition_length: 2s default_transition_length: 2s internal: true segments: # Use LEDs 11-20 from the light with ID light1 - id: ceshi from: 4 to: 4- platform: partition name: "Partition Light 6" id: ceshi6 flash_transition_length: 2500ms default_transition_length: 2500ms internal: true segments: # Use LEDs 11-20 from the li
这种方式确实效率不高 有能力的可以用组件(components)的方式实现灯效(light:effects),yaml配置就可以很简洁 谢谢,我去了解一下 你这个排版我是没勇气看下去了,你口中的流水灯就是逐个点亮,逐个熄灭吗?那我随便敲了几行代码,没有实际跑过,权当给你参考。
下面只是点亮效果,关闭效果自己照着写吧。
light:
- platform: fastled_clockless
chipset: WS2812B
pin: GPIO3
num_leds: 360
rgb_order: GRB
name: "FastLED WS2811 Light"
effects:
- addressable_lambda:
name: "Turn ON"
update_interval: 500ms
lambda: |-
static uint8_t count = 0;
if(count > it.size()-1)
return;
it = Color::WHITE;
count ++;
你用neopixelbus也可以,实现代码一样,按照neopixelbus配置一下参数就行。 感谢dianxin11 为啥不写arduino呢:D 如果是为了实现特效的话,可以用neopixel或者直接刷wled,流动效果更好看,很多特效可以选择 https://www.esphome.io/components/light/#light-effects
这边不是有灯光效果的菜单吗
例如:
light:
- platform: ...
# ...
effects:
- addressable_rainbow:
- addressable_rainbow:
name: Rainbow Effect With Custom Values
speed: 10
width: 50 用esp32/esp8266配合WLED效果很好,功能很强大。
页:
[1]