ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
light_partition.cpp
Go to the documentation of this file.
1#include "light_partition.h"
2#include "esphome/core/log.h"
3
5
6ESPHOME_LOG_TAG(TAG, "partition.light");
7
9 uint32_t lo = 0;
10 uint32_t hi = this->segments_.size() - 1;
11 while (lo < hi) {
12 uint32_t mid = (lo + hi) / 2;
13 int32_t begin = this->segments_[mid].get_dst_offset();
14 int32_t end = begin + this->segments_[mid].get_size();
15 if (index < begin) {
16 hi = mid - 1;
17 } else if (index >= end) {
18 lo = mid + 1;
19 } else {
20 lo = hi = mid;
21 }
22 }
23 auto &seg = this->segments_[lo];
24 // offset within the segment
25 int32_t seg_off = index - seg.get_dst_offset();
26 // offset within the src
27 int32_t src_off;
28 if (seg.is_reversed()) {
29 src_off = seg.get_src_offset() + seg.get_size() - seg_off - 1;
30 } else {
31 src_off = seg.get_src_offset() + seg_off;
32 }
33 return (*seg.get_src())[src_off];
34}
35
36} // namespace esphome::partition
Gets or sets the color or effect data at a specific index within an color accessor.
light::ESPColorView get_color_view_(int32_t index) const
std::vector< AddressableSegment > segments_
ESPHOME_LOG_TAG(TAG, "partition.light")
static void uint32_t