-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.patch
More file actions
127 lines (114 loc) · 10.2 KB
/
diff.patch
File metadata and controls
127 lines (114 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
commit cb313b85456e4f759615ad3457bbba6872d744a4
Author: effelle <effelle@gmail.com>
Date: Sun Feb 22 16:31:54 2026 -0300
fix(cfx): implement true symmetrical mirror bounds handling and fix missing mirror pointer state during outro engine execution
diff --git a/components/cfx_effect/CFXRunner.cpp b/components/cfx_effect/CFXRunner.cpp
index 668ef9a..89273dd 100644
--- a/components/cfx_effect/CFXRunner.cpp
+++ b/components/cfx_effect/CFXRunner.cpp
@@ -143,13 +143,27 @@ void Segment::setPixelColor(int n, uint32_t c) {
if (n < 0 || n >= length())
return;
- // Map usage to global buffer - apply mirror (inversion) if enabled
- int global_index = mirror ? (stop - 1 - n) : (start + n);
-
- if (instance && instance->target_light && global_index >= 0 &&
- global_index < instance->target_light->size()) {
+ if (instance && instance->target_light) {
esphome::Color esphome_color(CFX_R(c), CFX_G(c), CFX_B(c), CFX_W(c));
- (*instance->target_light)[global_index] = esphome_color;
+ int light_size = instance->target_light->size();
+
+ // Map usage to global buffer - apply true symmetrical mirror if enabled
+ if (mirror) {
+ int left_index = start + n;
+ int right_index = stop - 1 - n;
+
+ if (left_index >= 0 && left_index < light_size) {
+ (*instance->target_light)[left_index] = esphome_color;
+ }
+ if (right_index >= 0 && right_index < light_size) {
+ (*instance->target_light)[right_index] = esphome_color;
+ }
+ } else {
+ int global_index = start + n;
+ if (global_index >= 0 && global_index < light_size) {
+ (*instance->target_light)[global_index] = esphome_color;
+ }
+ }
}
}
@@ -157,8 +171,7 @@ uint32_t Segment::getPixelColor(int n) {
if (n < 0 || n >= length())
return 0;
- // Apply mirror (inversion) if enabled
- int global_index = mirror ? (stop - 1 - n) : (start + n);
+ int global_index = start + n; // Always read from left side
if (instance && instance->target_light && global_index >= 0 &&
global_index < instance->target_light->size()) {
@@ -172,7 +185,7 @@ void Segment::fill(uint32_t c) {
if (!instance || !instance->target_light)
return;
- int len = length();
+ int len = physicalLength();
int light_size = instance->target_light->size();
int global_start = start;
@@ -207,7 +220,7 @@ void Segment::fadeToBlackBy(uint8_t fadeBy) {
uint8_t newRetention = instance->getFadeFactor(retention);
uint8_t effectiveFade = 255 - newRetention;
- int len = length();
+ int len = physicalLength();
int light_size = instance->target_light->size();
int global_start = start;
esphome::light::AddressableLight &light = *instance->target_light;
@@ -240,7 +253,7 @@ void Segment::blur(uint8_t blur_amount) {
// WLED approach: blur1d modifies in-place but effectively propagates.
// Let's stick to simple in-place for now (WLED compat).
- int len = length();
+ int len = physicalLength();
int light_size = instance->target_light->size();
int global_start = start;
esphome::light::AddressableLight &light = *instance->target_light;
@@ -285,7 +298,7 @@ void Segment::blur(uint8_t blur_amount) {
void Segment::subtractive_fade_val(uint8_t fade_amt) {
if (!instance || !instance->target_light)
return;
- int len = length();
+ int len = physicalLength();
int light_size = instance->target_light->size();
int global_start = start;
esphome::light::AddressableLight &light = *instance->target_light;
diff --git a/components/cfx_effect/CFXRunner.h b/components/cfx_effect/CFXRunner.h
index 91c80f6..811b92f 100644
--- a/components/cfx_effect/CFXRunner.h
+++ b/components/cfx_effect/CFXRunner.h
@@ -237,9 +237,12 @@ public:
colors[2] = 0x0;
}
- uint16_t length() const { return stop - start; }
+ uint16_t physicalLength() const { return stop - start; }
+ uint16_t length() const {
+ return mirror ? physicalLength() / 2 : physicalLength();
+ }
uint16_t virtualLength() const { return length(); }
- bool isActive() const { return on && length() > 0; }
+ bool isActive() const { return on && physicalLength() > 0; }
bool allocateData(size_t len) {
if (data && _dataLen == len)
diff --git a/components/cfx_effect/cfx_addressable_light_effect.cpp b/components/cfx_effect/cfx_addressable_light_effect.cpp
index 0a66708..5948f4f 100644
--- a/components/cfx_effect/cfx_addressable_light_effect.cpp
+++ b/components/cfx_effect/cfx_addressable_light_effect.cpp
@@ -1415,12 +1415,7 @@ bool CFXAddressableLightEffect::run_outro_frame(light::AddressableLight &it,
// Control State for Mirror (affects wipe direction)
switch_::Switch *mirror_sw = this->mirror_;
if (mirror_sw == nullptr && this->controller_ != nullptr)
- mirror_sw = this->controller_->get_outro_effect()
- ? this->controller_->get_mirror()
- : nullptr;
-
- if (mirror_sw == nullptr)
- mirror_sw = this->mirror_;
+ mirror_sw = this->controller_->get_mirror();
bool reverse = false;
if (mirror_sw != nullptr && mirror_sw->state)