1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-01 15:41:52 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Jesse Hills
385d5c018b Update __init__.py 2024-06-06 18:37:35 +12:00
Jesse Hills
460ce5991c Update e131_addressable_light_effect.cpp 2024-06-06 18:31:35 +12:00
Jesse Hills
03b2d3f9d3 Update e131_addressable_light_effect.h 2024-06-06 18:30:09 +12:00
3 changed files with 6 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ CHANNELS = {
CONF_UNIVERSE = "universe"
CONF_E131_ID = "e131_id"
CONF_CHANNEL_OFFSET = "channel_offset"
CONFIG_SCHEMA = cv.Schema(
{
@@ -46,6 +47,7 @@ async def to_code(config):
cv.GenerateID(CONF_E131_ID): cv.use_id(E131Component),
cv.Required(CONF_UNIVERSE): cv.int_range(min=1, max=512),
cv.Optional(CONF_CHANNELS, default="RGB"): cv.one_of(*CHANNELS, upper=True),
cv.Optional(CONF_CHANNEL_OFFSET, default=0): cv.int_range(min=0, max=512),
},
)
async def e131_light_effect_to_code(config, effect_id):
@@ -54,5 +56,6 @@ async def e131_light_effect_to_code(config, effect_id):
effect = cg.new_Pvariable(effect_id, config[CONF_NAME])
cg.add(effect.set_first_universe(config[CONF_UNIVERSE]))
cg.add(effect.set_channels(CHANNELS[config[CONF_CHANNELS]]))
cg.add(effect.set_channel_offset(config[CONF_CHANNEL_OFFSET]))
cg.add(effect.set_e131(parent))
return effect

View File

@@ -55,7 +55,7 @@ bool E131AddressableLightEffect::process_(int universe, const E131Packet &packet
// limit amount of lights per universe and received
int output_end =
std::min(it->size(), std::min(output_offset + get_lights_per_universe(), output_offset + packet.count - 1));
auto *input_data = packet.values + 1;
auto *input_data = packet.values + 1 + (this->channel_offset_ * this->channels_);
ESP_LOGV(TAG, "Applying data for '%s' on %d universe, for %" PRId32 "-%d.", get_name().c_str(), universe,
output_offset, output_end);

View File

@@ -27,6 +27,7 @@ class E131AddressableLightEffect : public light::AddressableLightEffect {
void set_first_universe(int universe) { this->first_universe_ = universe; }
void set_channels(E131LightChannels channels) { this->channels_ = channels; }
void set_channel_offset(int offset) { this->channel_offset_ = offset; }
void set_e131(E131Component *e131) { this->e131_ = e131; }
protected:
@@ -34,6 +35,7 @@ class E131AddressableLightEffect : public light::AddressableLightEffect {
int first_universe_{0};
int last_universe_{0};
int channel_offset_{0};
E131LightChannels channels_{E131_RGB};
E131Component *e131_{nullptr};