Fix tube flicker and review fixes
- The bit-banged WS2812 update disables interrupts (about 30 us per pixel), which made the lit tube stay on longer and flash. neoShow() now only sends when the pixels changed (fixed colour was resent every second) and waits for the dark gap between tubes; the bit-bang strip has no headroom pixels. This also fixed digits that seemed to hang. - 4 WS2812 on this board, one per tube (not 8) - Saving the firmware URL in the web UI no longer starts an HTTP update; never update from an empty URL - Restart once after the first switch from AP mode to WiFi, so ArduinoOTA and MQTT start on the real network - Optional web UI password (WEB_USER/WEB_PASSWORD in secrets.h); /getConfiguration returns the stored WiFi and MQTT passwords - Cathode protect: random mode now starts at a random tube (the +-1 start digits were swapped and then overwritten) - Apply the unused gamma table to wheel colours - LOOP_DIAG (off by default): main-loop stalls in /getCurrentInfos, which now also reports uptime and free heap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e5d1757035
commit
5fbae6247c
7 files changed
+189
-80
No files matched your search
@@ -99,26 +99,47 @@ inline byte tubeForPixel(int i) {
|
||||
//(DMA-fed) instead of RMT; this is more tolerant of interrupts/WiFi jitter
|
||||
//than NeoEsp32Rmt7Ws2812xMethod, which can glitch the strict WS2812 bit
|
||||
//timing (~1.25us/bit) if an ISR delays the RMT hardware mid-frame.
|
||||
NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp32I2s1800KbpsMethod> strip(PixelCount+4,PixelPin); //NeoEsp32I2s1800KbpsMethod is used here because it is more reliable than NeoEsp32Rmt7Ws2812xMethod!
|
||||
#define NEO_STRIP_LEN (PixelCount+4)
|
||||
NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp32I2s1800KbpsMethod> strip(NEO_STRIP_LEN,PixelPin); //NeoEsp32I2s1800KbpsMethod is used here because it is more reliable than NeoEsp32Rmt7Ws2812xMethod!
|
||||
#elif NEOPIXEL_PIN == 3 //default (see clocks.h)
|
||||
byte PixelPin = 3; // on 8266 it MUST use GPIO3 (RX pin)
|
||||
//8266 has no I2S/RMT WS2812 helper here; Neo800KbpsMethod bit-bangs the
|
||||
//protocol with cycle-counted delays, which is why GPIO3/RX is mandated -
|
||||
//it's one of the few pins whose timing isn't disturbed by the UART/boot ROM.
|
||||
NeoPixelBrightnessBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount+4);
|
||||
#define NEO_STRIP_LEN (PixelCount+4)
|
||||
NeoPixelBrightnessBus<NeoGrbFeature, Neo800KbpsMethod> strip(NEO_STRIP_LEN);
|
||||
#else
|
||||
//Any other 8266 pin: cycle-counted bit-bang. Interrupts are off while Show()
|
||||
//runs (about 30 us per pixel), which briefly delays the multiplex ISR.
|
||||
//runs (about 30 us per pixel), which delays the multiplex ISR - see neoShow().
|
||||
//No headroom pixels here: every loop stops at PixelCount-1, and each extra
|
||||
//pixel makes the interrupt-free time longer.
|
||||
byte PixelPin = NEOPIXEL_PIN;
|
||||
NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> strip(PixelCount+4, PixelPin);
|
||||
#define NEO_STRIP_LEN PixelCount
|
||||
NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> strip(NEO_STRIP_LEN, PixelPin);
|
||||
#endif
|
||||
|
||||
//Gamma-correction lookup table object - NOTE: currently declared but never
|
||||
//applied (colorGamma.Correct(...) is not called anywhere in this file), so
|
||||
//colors are sent to the strip linearly, not perceptually corrected. Possible
|
||||
//leftover from an earlier version / an intended-but-unfinished improvement.
|
||||
//Gamma-correction lookup table, applied in Wheel() so hues look even (without it,
|
||||
//mixed colours such as yellow or cyan look washed out).
|
||||
// FIXED: was declared but never used.
|
||||
NeoGamma<NeoGammaTableMethod> colorGamma;
|
||||
|
||||
//Sends the strip, but only if its buffer changed since the last send: the effects call this on
|
||||
//every tick (fixed colour once a second) although the colours often stay the same. With the
|
||||
//nixie595 driver it also waits for a dark gap between tubes first, see displayWaitBlank().
|
||||
void neoShow() {
|
||||
static uint8_t lastFrame[NEO_STRIP_LEN * 3];
|
||||
static boolean sent = false;
|
||||
size_t n = min(strip.PixelsSize(), sizeof(lastFrame));
|
||||
|
||||
if (sent && (memcmp(lastFrame, strip.Pixels(), n) == 0)) return;
|
||||
memcpy(lastFrame, strip.Pixels(), n);
|
||||
sent = true;
|
||||
#ifdef NIXIE595_MULTIPLEX
|
||||
displayWaitBlank();
|
||||
#endif
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
void setupNeopixel() {
|
||||
DPRINTLN("Setup NeoPixel LEDS");
|
||||
regPin(PixelPin,"NEOPIXEL_PIN");
|
||||
@@ -129,7 +150,7 @@ void setupNeopixel() {
|
||||
//does not. A driver may have claimed the pin since (nixie595.ino: SPI.begin() makes GPIO12 MISO).
|
||||
pinMode(PixelPin, OUTPUT);
|
||||
strip.Begin(); //initialize the underlying I2S/RMT/bit-bang driver and GPIO
|
||||
strip.Show(); //push the (still all-black, default-constructed) buffer out so the strip starts dark, not showing stale/garbage pixel data
|
||||
neoShow(); //push the (still all-black, default-constructed) buffer out so the strip starts dark, not showing stale/garbage pixel data
|
||||
strip.SetBrightness(neoBrightness);
|
||||
fixColor(prm.rgbFixColor); //apply the persisted fixed color immediately so the backlight is correct even before the first doAnimationMakuna() tick
|
||||
}
|
||||
@@ -143,6 +164,11 @@ void setupNeopixel() {
|
||||
//sentinel value that instead returns solid white, since a pure hue rotation
|
||||
//can never itself produce white (R=G=B).
|
||||
RgbColor Wheel(byte WheelPos) {
|
||||
return colorGamma.Correct(WheelRaw(WheelPos));
|
||||
}
|
||||
|
||||
//The uncorrected wheel colour (also used by mqtt.ino to report the colour to Home Assistant).
|
||||
RgbColor WheelRaw(byte WheelPos) {
|
||||
|
||||
if (WheelPos == WHITE_INDEX)
|
||||
return white;
|
||||
@@ -180,7 +206,7 @@ void alarmLight() {
|
||||
else
|
||||
strip.SetPixelColor(i,black);
|
||||
}
|
||||
strip.Show();
|
||||
neoShow();
|
||||
}
|
||||
|
||||
//Called once from the core's alarmSound() when the alarm's ring period times
|
||||
@@ -193,7 +219,7 @@ void darkenNeopixels() {
|
||||
for (int i=0;i<PixelCount;i++) {
|
||||
strip.SetPixelColor(i,black);
|
||||
}
|
||||
strip.Show();
|
||||
neoShow();
|
||||
}
|
||||
|
||||
//"Flow" rainbow: each physical pixel gets a color offset by its own index i
|
||||
@@ -219,7 +245,7 @@ void rainbow() {
|
||||
}
|
||||
if (prm.rgbDir) { j++; }
|
||||
else { j--; }
|
||||
strip.Show();
|
||||
neoShow();
|
||||
}
|
||||
|
||||
//"Rainbow Stepper": unlike rainbow() which shifts every pixel together every
|
||||
@@ -261,7 +287,7 @@ void rainbow2() { //Rainbow Stepper
|
||||
if (prm.rgbDir)i++;
|
||||
else i--;
|
||||
|
||||
strip.Show();
|
||||
neoShow();
|
||||
}
|
||||
|
||||
//All tubes show the same solid color (c), while the overall strip brightness
|
||||
@@ -304,7 +330,7 @@ void effect1() { //color dimmer
|
||||
c = random(0,256); //hit the dim floor -> pick a new random hue and start brightening back up
|
||||
dir = -1;
|
||||
}
|
||||
strip.Show();
|
||||
neoShow();
|
||||
}
|
||||
|
||||
|
||||
@@ -327,7 +353,7 @@ void effect2() { //random color picker
|
||||
else
|
||||
strip.SetPixelColor(i, Wheel(c));
|
||||
}
|
||||
strip.Show();
|
||||
neoShow();
|
||||
}
|
||||
|
||||
//Distance between two positions on the 0..255 color wheel, accounting for
|
||||
@@ -468,7 +494,7 @@ void effect3(boolean enableRandom,boolean eachPixelRandom) {
|
||||
for (int j=0;j<maxDigits;j++)
|
||||
setPixels(j, Wheel(actColor[j]));
|
||||
|
||||
strip.Show();
|
||||
neoShow();
|
||||
//DPRINT("Pix:"); DPRINT(i); DPRINT(" Old:"); DPRINT(oldColor[i]); DPRINT(" ActCol:"); DPRINT(actColor[i]); DPRINT(" New:"); DPRINT(newColor[i]); DPRINT(" Step:"); DPRINTLN(step);
|
||||
}
|
||||
|
||||
@@ -520,7 +546,7 @@ void effect4() { //every pixel is random changer
|
||||
}
|
||||
//DPRINT("Pix:"); DPRINT(i); DPRINT(" ActCol:"); DPRINTLN(actColor);
|
||||
} //end for t
|
||||
strip.Show();
|
||||
neoShow();
|
||||
}
|
||||
|
||||
//Sets the color of every physical pixel that belongs to logical tube `tubeNo`
|
||||
@@ -548,7 +574,7 @@ void fixColor(int col) {
|
||||
else
|
||||
strip.SetPixelColor(i,Wheel(col));
|
||||
}
|
||||
strip.Show();
|
||||
neoShow();
|
||||
}
|
||||
|
||||
//Knight Rider "KITT" scanner: a single lit tube (using the fixed
|
||||
@@ -573,7 +599,7 @@ void kitt() {
|
||||
}
|
||||
|
||||
setPixels(counter,Wheel(prm.rgbFixColor));
|
||||
strip.Show();
|
||||
neoShow();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user