Add WLED support (#1092)

A component to support [WLED](https://github.com/Aircoookie/WLED/wiki/UDP-Realtime-Control).
This allows to control addressable LEDs over WiFi/UDP, by pushing data right into LEDs.

The most useful to use [Prismatik](https://github.com/psieg/Lightpack) to create
an immersive effect on PC.

It supports all WLED protocols:
- WARLS
- DRGB
- DRGBW
- DNRGB
- WLED Notifier

Co-authored-by: Guillermo Ruffino <glm.net@gmail.com>
This commit is contained in:
Kamil Trzciński
2020-06-13 01:50:09 +02:00
committed by GitHub
parent d1b051a6bd
commit 0c0dec2534
5 changed files with 308 additions and 0 deletions
@@ -0,0 +1,41 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/light/addressable_light_effect.h"
#include <vector>
#include <memory>
class UDP;
namespace esphome {
namespace wled {
class WLEDLightEffect : public light::AddressableLightEffect {
public:
WLEDLightEffect(const std::string &name);
public:
void start() override;
void stop() override;
void apply(light::AddressableLight &it, const light::ESPColor &current_color) override;
void set_port(uint16_t port) { this->port_ = port; }
protected:
void blank_all_leds_(light::AddressableLight &it);
bool parse_frame_(light::AddressableLight &it, const uint8_t *payload, uint16_t size);
bool parse_notifier_frame_(light::AddressableLight &it, const uint8_t *payload, uint16_t size);
bool parse_warls_frame_(light::AddressableLight &it, const uint8_t *payload, uint16_t size);
bool parse_drgb_frame_(light::AddressableLight &it, const uint8_t *payload, uint16_t size);
bool parse_drgbw_frame_(light::AddressableLight &it, const uint8_t *payload, uint16_t size);
bool parse_dnrgb_frame_(light::AddressableLight &it, const uint8_t *payload, uint16_t size);
protected:
uint16_t port_{0};
std::unique_ptr<UDP> udp_;
uint32_t blank_at_{0};
uint32_t dropped_{0};
};
} // namespace wled
} // namespace esphome