Removed pixel locking
This commit is contained in:
parent
3d359229cf
commit
9bf534288c
14
wled00/FX.h
14
wled00/FX.h
@ -188,6 +188,9 @@
|
|||||||
class WS2812FX {
|
class WS2812FX {
|
||||||
typedef uint16_t (WS2812FX::*mode_ptr)(void);
|
typedef uint16_t (WS2812FX::*mode_ptr)(void);
|
||||||
|
|
||||||
|
// pre show callback
|
||||||
|
typedef void (*show_callback) (void);
|
||||||
|
|
||||||
// segment parameters
|
// segment parameters
|
||||||
public:
|
public:
|
||||||
typedef struct Segment { // 24 bytes
|
typedef struct Segment { // 24 bytes
|
||||||
@ -357,7 +360,6 @@ class WS2812FX {
|
|||||||
ablMilliampsMax = 850;
|
ablMilliampsMax = 850;
|
||||||
currentMilliamps = 0;
|
currentMilliamps = 0;
|
||||||
timebase = 0;
|
timebase = 0;
|
||||||
_locked = nullptr;
|
|
||||||
bus = new NeoPixelWrapper();
|
bus = new NeoPixelWrapper();
|
||||||
resetSegments();
|
resetSegments();
|
||||||
}
|
}
|
||||||
@ -374,13 +376,8 @@ class WS2812FX {
|
|||||||
driverModeCronixie(bool b),
|
driverModeCronixie(bool b),
|
||||||
setCronixieDigits(byte* d),
|
setCronixieDigits(byte* d),
|
||||||
setCronixieBacklight(bool b),
|
setCronixieBacklight(bool b),
|
||||||
setIndividual(uint16_t i, uint32_t col),
|
|
||||||
setRange(uint16_t i, uint16_t i2, uint32_t col),
|
setRange(uint16_t i, uint16_t i2, uint32_t col),
|
||||||
lock(uint16_t i),
|
setShowCallback(show_callback cb),
|
||||||
lockRange(uint16_t i, uint16_t i2),
|
|
||||||
unlock(uint16_t i),
|
|
||||||
unlockRange(uint16_t i, uint16_t i2),
|
|
||||||
unlockAll(void),
|
|
||||||
setTransitionMode(bool t),
|
setTransitionMode(bool t),
|
||||||
trigger(void),
|
trigger(void),
|
||||||
setSegment(uint8_t n, uint16_t start, uint16_t stop),
|
setSegment(uint8_t n, uint16_t start, uint16_t stop),
|
||||||
@ -559,11 +556,12 @@ class WS2812FX {
|
|||||||
_skipFirstMode,
|
_skipFirstMode,
|
||||||
_triggered;
|
_triggered;
|
||||||
|
|
||||||
byte* _locked;
|
|
||||||
byte _cronixieDigits[6];
|
byte _cronixieDigits[6];
|
||||||
|
|
||||||
mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element
|
mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element
|
||||||
|
|
||||||
|
show_callback _callback = nullptr;
|
||||||
|
|
||||||
// mode helper functions
|
// mode helper functions
|
||||||
uint16_t
|
uint16_t
|
||||||
blink(uint32_t, uint32_t, bool strobe, bool),
|
blink(uint32_t, uint32_t, bool strobe, bool),
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst, uint8_t disableNLeds)
|
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst, uint8_t disableNLeds)
|
||||||
{
|
{
|
||||||
if (supportWhite == _rgbwMode && countPixels == _length && _locked != NULL && disableNLeds == _disableNLeds) return;
|
if (supportWhite == _rgbwMode && countPixels == _length && disableNLeds == _disableNLeds) return;
|
||||||
RESET_RUNTIME;
|
RESET_RUNTIME;
|
||||||
_rgbwMode = supportWhite;
|
_rgbwMode = supportWhite;
|
||||||
_skipFirstMode = skipFirst;
|
_skipFirstMode = skipFirst;
|
||||||
@ -59,13 +59,9 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst, uin
|
|||||||
|
|
||||||
bus->Begin((NeoPixelType)ty, _lengthRaw);
|
bus->Begin((NeoPixelType)ty, _lengthRaw);
|
||||||
|
|
||||||
delete[] _locked;
|
|
||||||
_locked = new byte[_length];
|
|
||||||
|
|
||||||
_segments[0].start = 0;
|
_segments[0].start = 0;
|
||||||
_segments[0].stop = _usableCount;
|
_segments[0].stop = _usableCount;
|
||||||
|
|
||||||
unlockAll();
|
|
||||||
setBrightness(_brightness);
|
setBrightness(_brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +103,6 @@ void WS2812FX::setPixelColor(uint16_t n, uint32_t c) {
|
|||||||
void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
|
void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
|
||||||
{
|
{
|
||||||
i = i * (_disableNLeds+1);
|
i = i * (_disableNLeds+1);
|
||||||
if (_locked[i]) return;
|
|
||||||
if (IS_REVERSE) i = SEGMENT.stop -1 -i + SEGMENT.start; //reverse just individual segment
|
if (IS_REVERSE) i = SEGMENT.stop -1 -i + SEGMENT.start; //reverse just individual segment
|
||||||
byte tmpg = g;
|
byte tmpg = g;
|
||||||
switch (colorOrder) //0 = Grb, default
|
switch (colorOrder) //0 = Grb, default
|
||||||
@ -200,6 +195,8 @@ void WS2812FX::setCronixieDigits(byte d[])
|
|||||||
//you can set it to 0 if the ESP is powered by USB and the LEDs by external
|
//you can set it to 0 if the ESP is powered by USB and the LEDs by external
|
||||||
|
|
||||||
void WS2812FX::show(void) {
|
void WS2812FX::show(void) {
|
||||||
|
if (_callback) _callback();
|
||||||
|
|
||||||
//power limit calculation
|
//power limit calculation
|
||||||
//each LED can draw up 195075 "power units" (approx. 53mA)
|
//each LED can draw up 195075 "power units" (approx. 53mA)
|
||||||
//one PU is the power it takes to have 1 channel 1 step brighter per brightness step
|
//one PU is the power it takes to have 1 channel 1 step brighter per brightness step
|
||||||
@ -468,56 +465,20 @@ void WS2812FX::resetSegments() {
|
|||||||
_segment_runtimes[0].reset();
|
_segment_runtimes[0].reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setIndividual(uint16_t i, uint32_t col)
|
|
||||||
{
|
|
||||||
if (i >= 0 && i < _length)
|
|
||||||
{
|
|
||||||
_locked[i] = false;
|
|
||||||
setPixelColor(i, col);
|
|
||||||
_locked[i] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WS2812FX::setRange(uint16_t i, uint16_t i2, uint32_t col)
|
void WS2812FX::setRange(uint16_t i, uint16_t i2, uint32_t col)
|
||||||
{
|
{
|
||||||
if (i2 >= i)
|
if (i2 >= i)
|
||||||
{
|
{
|
||||||
for (uint16_t x = i; x <= i2; x++) setIndividual(x,col);
|
for (uint16_t x = i; x <= i2; x++) setPixelColor(x, col);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
for (uint16_t x = i2; x <= i; x++) setIndividual(x,col);
|
for (uint16_t x = i2; x <= i; x++) setPixelColor(x, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::lock(uint16_t i)
|
void WS2812FX::setShowCallback(show_callback cb)
|
||||||
{
|
{
|
||||||
if (i < _length) _locked[i] = true;
|
_callback = cb;
|
||||||
}
|
|
||||||
|
|
||||||
void WS2812FX::lockRange(uint16_t i, uint16_t i2)
|
|
||||||
{
|
|
||||||
for (uint16_t x = i; x < i2; x++)
|
|
||||||
{
|
|
||||||
if (x < _length) _locked[i] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WS2812FX::unlock(uint16_t i)
|
|
||||||
{
|
|
||||||
if (i < _length) _locked[i] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WS2812FX::unlockRange(uint16_t i, uint16_t i2)
|
|
||||||
{
|
|
||||||
for (uint16_t x = i; x < i2; x++)
|
|
||||||
{
|
|
||||||
if (x < _length) _locked[x] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WS2812FX::unlockAll()
|
|
||||||
{
|
|
||||||
for (int i=0; i < _length; i++) _locked[i] = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setTransitionMode(bool t)
|
void WS2812FX::setTransitionMode(bool t)
|
||||||
|
@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
|
|
||||||
//version code in format yymmddb (b = daily build)
|
//version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2001021
|
#define VERSION 2001022
|
||||||
char versionString[] = "0.9.0-b2";
|
char versionString[] = "0.9.0-b2";
|
||||||
|
|
||||||
|
|
||||||
@ -424,6 +424,7 @@ AsyncMqttClient* mqtt = NULL;
|
|||||||
void colorFromUint32(uint32_t,bool=false);
|
void colorFromUint32(uint32_t,bool=false);
|
||||||
void serveMessage(AsyncWebServerRequest*,uint16_t,String,String,byte);
|
void serveMessage(AsyncWebServerRequest*,uint16_t,String,String,byte);
|
||||||
void handleE131Packet(e131_packet_t*, IPAddress);
|
void handleE131Packet(e131_packet_t*, IPAddress);
|
||||||
|
void handleOverlayDraw();
|
||||||
|
|
||||||
#define E131_MAX_UNIVERSE_COUNT 9
|
#define E131_MAX_UNIVERSE_COUNT 9
|
||||||
|
|
||||||
|
@ -200,7 +200,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
|
|
||||||
if (request->hasArg("OL")){
|
if (request->hasArg("OL")){
|
||||||
overlayDefault = request->arg("OL").toInt();
|
overlayDefault = request->arg("OL").toInt();
|
||||||
if (overlayCurrent != overlayDefault) strip.unlockAll();
|
|
||||||
overlayCurrent = overlayDefault;
|
overlayCurrent = overlayDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,29 +458,6 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
|
|||||||
pos = req.indexOf("OL=");
|
pos = req.indexOf("OL=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
overlayCurrent = getNumVal(&req, pos);
|
overlayCurrent = getNumVal(&req, pos);
|
||||||
strip.unlockAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
//(un)lock pixel (ranges)
|
|
||||||
pos = req.indexOf("&L=");
|
|
||||||
if (pos > 0) {
|
|
||||||
uint16_t index = getNumVal(&req, pos);
|
|
||||||
pos = req.indexOf("L2=");
|
|
||||||
bool unlock = req.indexOf("UL") > 0;
|
|
||||||
if (pos > 0) {
|
|
||||||
uint16_t index2 = getNumVal(&req, pos);
|
|
||||||
if (unlock) {
|
|
||||||
strip.unlockRange(index, index2);
|
|
||||||
} else {
|
|
||||||
strip.lockRange(index, index2);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (unlock) {
|
|
||||||
strip.unlock(index);
|
|
||||||
} else {
|
|
||||||
strip.lock(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//apply macro
|
//apply macro
|
||||||
|
@ -96,6 +96,7 @@ void wledInit()
|
|||||||
void beginStrip()
|
void beginStrip()
|
||||||
{
|
{
|
||||||
// Initialize NeoPixel Strip and button
|
// Initialize NeoPixel Strip and button
|
||||||
|
strip.setShowCallback(handleOverlayDraw);
|
||||||
|
|
||||||
#ifdef BTNPIN
|
#ifdef BTNPIN
|
||||||
pinMode(BTNPIN, INPUT_PULLUP);
|
pinMode(BTNPIN, INPUT_PULLUP);
|
||||||
|
@ -79,7 +79,6 @@ void arlsLock(uint32_t timeoutMs)
|
|||||||
{
|
{
|
||||||
strip.setPixelColor(i,0,0,0,0);
|
strip.setPixelColor(i,0,0,0,0);
|
||||||
}
|
}
|
||||||
strip.unlockAll();
|
|
||||||
realtimeActive = true;
|
realtimeActive = true;
|
||||||
}
|
}
|
||||||
realtimeTimeout = millis() + timeoutMs;
|
realtimeTimeout = millis() + timeoutMs;
|
||||||
@ -127,7 +126,6 @@ void handleNotifications()
|
|||||||
//unlock strip when realtime UDP times out
|
//unlock strip when realtime UDP times out
|
||||||
if (realtimeActive && millis() > realtimeTimeout)
|
if (realtimeActive && millis() > realtimeTimeout)
|
||||||
{
|
{
|
||||||
//strip.unlockAll();
|
|
||||||
strip.setBrightness(bri);
|
strip.setBrightness(bri);
|
||||||
realtimeActive = false;
|
realtimeActive = false;
|
||||||
//strip.setMode(effectCurrent);
|
//strip.setMode(effectCurrent);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Used to draw clock overlays over the strip
|
* Used to draw clock overlays over the strip
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void initCronixie()
|
void initCronixie()
|
||||||
{
|
{
|
||||||
if (overlayCurrent == 3 && !cronixieInit)
|
if (overlayCurrent == 3 && !cronixieInit)
|
||||||
@ -24,14 +25,8 @@ void handleOverlays()
|
|||||||
initCronixie();
|
initCronixie();
|
||||||
updateLocalTime();
|
updateLocalTime();
|
||||||
checkTimers();
|
checkTimers();
|
||||||
switch (overlayCurrent)
|
checkCountdown();
|
||||||
{
|
if (overlayCurrent == 3) _overlayCronixie();//Diamex cronixie clock kit
|
||||||
case 0: break;//no overlay
|
|
||||||
case 1: _overlayAnalogClock(); break;//2 analog clock
|
|
||||||
case 2: break;//nixie 1-digit, removed
|
|
||||||
case 3: _overlayCronixie();//Diamex cronixie clock kit
|
|
||||||
}
|
|
||||||
if (!countdownMode || overlayCurrent < 3) checkCountdown(); //countdown macro activation must work
|
|
||||||
overlayRefreshedTime = millis();
|
overlayRefreshedTime = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,7 +35,6 @@ void handleOverlays()
|
|||||||
void _overlayAnalogClock()
|
void _overlayAnalogClock()
|
||||||
{
|
{
|
||||||
int overlaySize = overlayMax - overlayMin +1;
|
int overlaySize = overlayMax - overlayMin +1;
|
||||||
strip.unlockAll();
|
|
||||||
if (countdownMode)
|
if (countdownMode)
|
||||||
{
|
{
|
||||||
_overlayAnalogCountdown(); return;
|
_overlayAnalogCountdown(); return;
|
||||||
@ -73,23 +67,19 @@ void _overlayAnalogClock()
|
|||||||
{
|
{
|
||||||
pix = analogClock12pixel + round((overlaySize / 12.0) *i);
|
pix = analogClock12pixel + round((overlaySize / 12.0) *i);
|
||||||
if (pix > overlayMax) pix -= overlaySize;
|
if (pix > overlayMax) pix -= overlaySize;
|
||||||
strip.setIndividual(pix, 0x00FFAA);
|
strip.setPixelColor(pix, 0x00FFAA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!analogClockSecondsTrail) strip.setIndividual(secondPixel, 0xFF0000);
|
if (!analogClockSecondsTrail) strip.setPixelColor(secondPixel, 0xFF0000);
|
||||||
strip.setIndividual(minutePixel, 0x00FF00);
|
strip.setPixelColor(minutePixel, 0x00FF00);
|
||||||
strip.setIndividual(hourPixel, 0x0000FF);
|
strip.setPixelColor(hourPixel, 0x0000FF);
|
||||||
overlayRefreshMs = 998;
|
overlayRefreshMs = 998;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _overlayAnalogCountdown()
|
void _overlayAnalogCountdown()
|
||||||
{
|
{
|
||||||
strip.unlockAll();
|
if (now() < countdownTime)
|
||||||
if (now() >= countdownTime)
|
|
||||||
{
|
|
||||||
checkCountdown();
|
|
||||||
} else
|
|
||||||
{
|
{
|
||||||
long diff = countdownTime - now();
|
long diff = countdownTime - now();
|
||||||
double pval = 60;
|
double pval = 60;
|
||||||
@ -127,3 +117,9 @@ void _overlayAnalogCountdown()
|
|||||||
}
|
}
|
||||||
overlayRefreshMs = 998;
|
overlayRefreshMs = 998;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void handleOverlayDraw() {
|
||||||
|
if (overlayCurrent != 1) return; //only analog clock
|
||||||
|
_overlayAnalogClock();
|
||||||
|
}
|
||||||
|
@ -145,7 +145,6 @@ void setCronixie()
|
|||||||
|
|
||||||
void _overlayCronixie()
|
void _overlayCronixie()
|
||||||
{
|
{
|
||||||
if (countdownMode) checkCountdown();
|
|
||||||
#ifndef WLED_DISABLE_CRONIXIE
|
#ifndef WLED_DISABLE_CRONIXIE
|
||||||
byte h = hour(local);
|
byte h = hour(local);
|
||||||
byte h0 = h;
|
byte h0 = h;
|
||||||
|
Loading…
Reference in New Issue
Block a user