POC to use leds array in strip.set/getPixelColor
This commit is contained in:
parent
a70717f2f7
commit
66da57f375
@ -609,6 +609,10 @@ class WS2812FX { // 96 bytes
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// FastLED array, so we can refer to leds[i] instead of getPixel() and setPixel()
|
||||||
|
uint32_t *leds = nullptr ; //See FX_fcn.cpp for init (wip).
|
||||||
|
//Type is uint32_t as with CRGB assigning CRGB to uint32_t in gPC not implemented (yet) in pixeltypes.h,
|
||||||
|
|
||||||
WS2812FX() :
|
WS2812FX() :
|
||||||
gammaCorrectBri(false),
|
gammaCorrectBri(false),
|
||||||
gammaCorrectCol(true),
|
gammaCorrectCol(true),
|
||||||
@ -716,7 +720,8 @@ class WS2812FX { // 96 bytes
|
|||||||
hasRGBWBus(void),
|
hasRGBWBus(void),
|
||||||
hasCCTBus(void),
|
hasCCTBus(void),
|
||||||
// return true if the strip is being sent pixel updates
|
// return true if the strip is being sent pixel updates
|
||||||
isUpdating(void);
|
isUpdating(void),
|
||||||
|
useLedsArray = true;
|
||||||
|
|
||||||
inline bool isServicing(void) { return _isServicing; }
|
inline bool isServicing(void) { return _isServicing; }
|
||||||
inline bool hasWhiteChannel(void) {return _hasWhiteChannel;}
|
inline bool hasWhiteChannel(void) {return _hasWhiteChannel;}
|
||||||
|
@ -116,6 +116,8 @@ void IRAM_ATTR WS2812FX::setPixelColorXY(int x, int y, uint32_t col)
|
|||||||
uint16_t index = y * matrixWidth + x;
|
uint16_t index = y * matrixWidth + x;
|
||||||
if (index >= _length) return;
|
if (index >= _length) return;
|
||||||
if (index < customMappingSize) index = customMappingTable[index];
|
if (index < customMappingSize) index = customMappingTable[index];
|
||||||
|
if (useLedsArray)
|
||||||
|
leds[index] = col;
|
||||||
busses.setPixelColor(index, col);
|
busses.setPixelColor(index, col);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -126,6 +128,9 @@ uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
|
|||||||
uint16_t index = (y * matrixWidth + x);
|
uint16_t index = (y * matrixWidth + x);
|
||||||
if (index >= _length) return 0;
|
if (index >= _length) return 0;
|
||||||
if (index < customMappingSize) index = customMappingTable[index];
|
if (index < customMappingSize) index = customMappingTable[index];
|
||||||
|
if (useLedsArray)
|
||||||
|
return leds[index];
|
||||||
|
else
|
||||||
return busses.getPixelColor(index);
|
return busses.getPixelColor(index);
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -825,6 +825,17 @@ void WS2812FX::service() {
|
|||||||
if (nowUp - _lastShow < MIN_SHOW_DELAY) return;
|
if (nowUp - _lastShow < MIN_SHOW_DELAY) return;
|
||||||
bool doShow = false;
|
bool doShow = false;
|
||||||
|
|
||||||
|
//initialize leds array. Move to better place then service??? TBD: realloc if nr of leds change
|
||||||
|
if (useLedsArray) {
|
||||||
|
// if (leds != nullptr && sizeof(leds) / sizeof(uint32_t) != _length) {
|
||||||
|
// free(leds);
|
||||||
|
// leds = nullptr;
|
||||||
|
// }
|
||||||
|
if (leds == nullptr) {
|
||||||
|
leds = (uint32_t*) malloc(sizeof(uint32_t) * _length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_isServicing = true;
|
_isServicing = true;
|
||||||
_segment_index = 0;
|
_segment_index = 0;
|
||||||
for (segment &seg : _segments) {
|
for (segment &seg : _segments) {
|
||||||
@ -918,17 +929,23 @@ void WS2812FX::setPixelColor(int i, uint32_t col)
|
|||||||
if (indexMir >= seg.stop) indexMir -= len; // wrap
|
if (indexMir >= seg.stop) indexMir -= len; // wrap
|
||||||
if (indexMir < customMappingSize) indexMir = customMappingTable[indexMir];
|
if (indexMir < customMappingSize) indexMir = customMappingTable[indexMir];
|
||||||
|
|
||||||
|
if (useLedsArray)
|
||||||
|
leds[indexMir] = col;
|
||||||
busses.setPixelColor(indexMir, col);
|
busses.setPixelColor(indexMir, col);
|
||||||
}
|
}
|
||||||
indexSet += seg.offset; // offset/phase
|
indexSet += seg.offset; // offset/phase
|
||||||
if (indexSet >= seg.stop) indexSet -= len; // wrap
|
if (indexSet >= seg.stop) indexSet -= len; // wrap
|
||||||
if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet];
|
if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet];
|
||||||
|
|
||||||
|
if (useLedsArray)
|
||||||
|
leds[indexSet] = col;
|
||||||
busses.setPixelColor(indexSet, col);
|
busses.setPixelColor(indexSet, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (i < customMappingSize) i = customMappingTable[i];
|
if (i < customMappingSize) i = customMappingTable[i];
|
||||||
|
if (useLedsArray)
|
||||||
|
leds[i] = col;
|
||||||
busses.setPixelColor(i, col);
|
busses.setPixelColor(i, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -940,6 +957,9 @@ uint32_t WS2812FX::getPixelColor(uint16_t i)
|
|||||||
//if (isMatrix) return getPixelColorXY(i%matrixWidth, i/matrixWidth); // compatibility w/ non-effect fn
|
//if (isMatrix) return getPixelColorXY(i%matrixWidth, i/matrixWidth); // compatibility w/ non-effect fn
|
||||||
//#endif
|
//#endif
|
||||||
if (i < customMappingSize) i = customMappingTable[i];
|
if (i < customMappingSize) i = customMappingTable[i];
|
||||||
|
if (useLedsArray)
|
||||||
|
return leds[i];
|
||||||
|
else
|
||||||
return busses.getPixelColor(i);
|
return busses.getPixelColor(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user