diff --git a/tools/cdata.js b/tools/cdata.js
index 97000436..57427880 100644
--- a/tools/cdata.js
+++ b/tools/cdata.js
@@ -222,6 +222,7 @@ writeHtmlGzipped("wled00/data/index.htm", "wled00/html_ui.h", 'index');
writeHtmlGzipped("wled00/data/simple.htm", "wled00/html_simple.h", 'simple');
writeHtmlGzipped("wled00/data/pixart/pixart.htm", "wled00/html_pixart.h", 'pixart');
writeHtmlGzipped("wled00/data/cpal/cpal.htm", "wled00/html_cpal.h", 'cpal');
+//writeHtmlGzipped("wled00/data/pxmagic.htm", "wled00/html_pxmagic.h", 'pxmagic');
/*
writeChunks(
"wled00/data",
diff --git a/wled00/bus_wrapper.h b/wled00/bus_wrapper.h
index c5c81298..79ded7ba 100644
--- a/wled00/bus_wrapper.h
+++ b/wled00/bus_wrapper.h
@@ -122,6 +122,9 @@
#define I_SS_LPO_3 48
+// In the following NeoGammaNullMethod can be replaced with NeoGammaWLEDMethod to perform Gamma correction implicitly
+// unfortunately that may apply Gamma correction to pre-calculated palettes which is undesired
+
/*** ESP8266 Neopixel methods ***/
#ifdef ESP8266
//RGB
diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp
index d65fce9d..0bdf5032 100644
--- a/wled00/cfg.cpp
+++ b/wled00/cfg.cpp
@@ -338,7 +338,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
if (light_gc_col > 1.0f) gammaCorrectCol = true;
else gammaCorrectCol = false;
if (gammaCorrectVal > 1.0f && gammaCorrectVal <= 3) {
- if (gammaCorrectVal != 2.8f) calcGammaTable(gammaCorrectVal);
+ if (gammaCorrectVal != 2.8f) NeoGammaWLEDMethod::calcGammaTable(gammaCorrectVal);
} else {
gammaCorrectVal = 1.0f; // no gamma correction
gammaCorrectBri = false;
diff --git a/wled00/colors.cpp b/wled00/colors.cpp
index 9874c314..8c4baabb 100644
--- a/wled00/colors.cpp
+++ b/wled00/colors.cpp
@@ -302,7 +302,7 @@ uint16_t approximateKelvinFromRGB(uint32_t rgb) {
}
//gamma 2.8 lookup table used for color correction
-static byte gammaT[] = {
+uint8_t NeoGammaWLEDMethod::gammaT[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
@@ -320,27 +320,22 @@ static byte gammaT[] = {
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
-uint8_t gamma8_cal(uint8_t b, float gamma)
-{
- return (int)(powf((float)b / 255.0f, gamma) * 255.0f + 0.5f);
-}
-
// re-calculates & fills gamma table
-void calcGammaTable(float gamma)
+void NeoGammaWLEDMethod::calcGammaTable(float gamma)
{
- for (uint16_t i = 0; i < 256; i++) {
- gammaT[i] = gamma8_cal(i, gamma);
+ for (size_t i = 0; i < 256; i++) {
+ gammaT[i] = (int)(powf((float)i / 255.0f, gamma) * 255.0f + 0.5f);
}
}
-// used for individual channel or brightness gamma correction
-uint8_t gamma8(uint8_t b)
+uint8_t NeoGammaWLEDMethod::Correct(uint8_t value)
{
- return gammaT[b];
+ if (!gammaCorrectCol) return value;
+ return gammaT[value];
}
// used for color gamma correction
-uint32_t gamma32(uint32_t color)
+uint32_t NeoGammaWLEDMethod::Correct32(uint32_t color)
{
if (!gammaCorrectCol) return color;
uint8_t w = W(color);
diff --git a/wled00/data/pxmagic.htm b/wled00/data/pxmagic.htm
new file mode 100644
index 00000000..56aa0001
--- /dev/null
+++ b/wled00/data/pxmagic.htm
@@ -0,0 +1,1064 @@
+
+
+
+
+
+
+
+
+ Pixel Magic Tool - @ajotanc
+
+
+
+
+
+
+
+
+
diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm
index 3d25b316..8d579437 100644
--- a/wled00/data/settings_leds.htm
+++ b/wled00/data/settings_leds.htm
@@ -10,7 +10,7 @@
d.um_p = [];
d.rsvd = [];
d.ro_gpio = [];
- d.max_gpio = 39;
+ d.max_gpio = 50;
var customStarts=false,startsDirty=[],maxCOOverrides=5;
var loc = false, locip, locproto = "http:";
function H(){window.open("https://kno.wled.ge/features/settings/#led-settings");}
@@ -28,6 +28,7 @@
scE.addEventListener("load", () => {
GetV();checkSi();setABL();
if (d.um_p[0]==-1) d.um_p.shift();
+ pinDropdowns();
});
// error event
scE.addEventListener("error", (ev) => {
@@ -546,7 +547,63 @@ Length: {fields.push(e.name);}) // buttons
+ for (let i of d.Sf.elements) {
+ if (i.type === "number" && fields.includes(i.name)) { //select all pin select elements
+ let v = parseInt(i.value);
+ let sel = addDropdown(i.name,0);
+ for (var j = -1; j <= d.max_gpio; j++) {
+ if (d.rsvd.includes(j)) continue;
+ let foundPin = d.um_p.indexOf(j);
+ let txt = (j === -1) ? "unused" : `${j}`;
+ if (foundPin >= 0 && j !== v) txt += ` used`; // already reserved pin
+ if (d.ro_gpio.includes(j)) txt += " (R/O)";
+ let opt = addOption(sel, txt, j);
+ if (j === v) opt.selected = true; // this is "our" pin
+ else if (d.um_p.includes(j)) opt.disabled = true; // someone else's pin
+ }
+ }
+ }
+ }
+ // https://stackoverflow.com/questions/39729741/javascript-change-input-text-to-select-option
+ function addDropdown(field) {
+ let sel = d.createElement('select');
+ sel.classList.add("pin");
+ let inp = d.getElementsByName(field)[0];
+ if (inp && inp.tagName === "INPUT" && (inp.type === "text" || inp.type === "number")) { // may also use nodeName
+ let v = inp.value;
+ let n = inp.name;
+ // copy the existing input element's attributes to the new select element
+ for (var i = 0; i < inp.attributes.length; ++ i) {
+ var att = inp.attributes[i];
+ // type and value don't apply, so skip them
+ // ** you might also want to skip style, or others -- modify as needed **
+ if (att.name != 'type' && att.name != 'value' && att.name != 'class' && att.name != 'style') {
+ sel.setAttribute(att.name, att.value);
+ }
+ }
+ sel.setAttribute("data-val", v);
+ // finally, replace the old input element with the new select element
+ inp.parentElement.replaceChild(sel, inp);
+ return sel;
+ }
+ return null;
+ }
+ function addOption(sel,txt,val) {
+ if (sel===null) return; // select object missing
+ let opt = d.createElement("option");
+ opt.value = val;
+ opt.text = txt;
+ sel.appendChild(opt);
+ for (let i=0; iUsermod Settings