Merge branch 'MoonModules:mdev' into audio-palette-updates

This commit is contained in:
netmindz
2023-01-20 20:21:58 +00:00
committed by GitHub
16 changed files with 1004 additions and 758 deletions

View File

@@ -5892,15 +5892,21 @@ uint16_t mode_2Dscrollingtext(void) {
SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color
SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color
}
}
}
for (int i = 0; i < numberOfLetters; i++) {
if (int(cols) - int(SEGENV.aux0) + letterWidth*(i+1) < 0) continue; // don't draw characters off-screen
SEGMENT.drawCharacter(text[i], int(cols) - int(SEGENV.aux0) + letterWidth*i, yoffset, letterWidth, letterHeight, SEGMENT.color_from_palette(SEGENV.aux1, false, PALETTE_SOLID_WRAP, 0));
uint32_t col1 = SEGMENT.color_from_palette(SEGENV.aux1, false, PALETTE_SOLID_WRAP, 0);
uint32_t col2 = BLACK;
if (SEGMENT.check1 && SEGMENT.palette == 0) {
col1 = SEGCOLOR(0);
col2 = SEGCOLOR(2);
}
SEGMENT.drawCharacter(text[i], int(cols) - int(SEGENV.aux0) + letterWidth*i, yoffset, letterWidth, letterHeight, col1, col2);
}
return FRAMETIME;
}
static const char _data_FX_MODE_2DSCROLLTEXT[] PROGMEM = "Scrolling Text@!,Y Offset,Trail,Font size,,,Overlay;!,!;!;2;ix=128,c1=0,rev=0,mi=0,rY=0,mY=0";
static const char _data_FX_MODE_2DSCROLLTEXT[] PROGMEM = "Scrolling Text@!,Y Offset,Trail,Font size,,Gradient,Overlay;!,!,Gradient;!;2;ix=128,c1=0,rev=0,mi=0,rY=0,mY=0";
////////////////////////////
@@ -7138,6 +7144,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
band = constrain(band, 0, 15);
uint16_t colorIndex = band * 17;
uint16_t barHeight = map(fftResult[band], 0, 255, 0, rows); // do not subtract -1 from rows here
if (barHeight > rows) barHeight = rows; // WLEDMM map() can "overshoot" due to rounding errors
if (barHeight > previousBarHeight[x]) previousBarHeight[x] = barHeight; //drive the peak up
uint32_t ledColor = BLACK;
@@ -7148,7 +7155,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
ledColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_SOLID_WRAP, 0);
SEGMENT.setPixelColorXY(x, rows-1 - y, ledColor);
}
if (previousBarHeight[x] > 0)
if ((previousBarHeight[x] > 0) && (previousBarHeight[x] < rows)) // WLEDMM avoid "overshooting" into other segments
SEGMENT.setPixelColorXY(x, rows - previousBarHeight[x], (SEGCOLOR(2) != BLACK) ? SEGCOLOR(2) : ledColor);
if (rippleTime && previousBarHeight[x]>0) previousBarHeight[x]--; //delay/ripple effect

View File

@@ -602,8 +602,8 @@ typedef struct Segment {
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c) { drawLine(x0, y0, x1, y1, RGBW32(c.r,c.g,c.b,0)); } // automatic inline
void drawArc(uint16_t x0, uint16_t y0, uint16_t radius, uint32_t color, uint32_t fillColor = 0);
void drawArc(uint16_t x0, uint16_t y0, uint16_t radius, CRGB color, CRGB fillColor = BLACK) { drawArc(x0, y0, radius, RGBW32(color.r,color.g,color.b,0), RGBW32(fillColor.r,fillColor.g,fillColor.b,0)); } // automatic inline
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color);
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0)); } // automatic inline
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color, uint32_t col2 = 0);
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c, CRGB c2) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0), RGBW32(c2.r,c2.g,c2.b,0)); } // automatic inline
void wu_pixel(uint32_t x, uint32_t y, CRGB c);
void blur1d(fract8 blur_amount); // blur all rows in 1 dimension
void blur2d(fract8 blur_amount) { blur(blur_amount); }

View File

@@ -531,13 +531,16 @@ void Segment::drawArc(uint16_t x0, uint16_t y0, uint16_t radius, uint32_t color,
// draws a raster font character on canvas
// only supports: 4x6=24, 5x8=40, 5x12=60, 6x8=48 and 7x9=63 fonts ATM
void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color) {
void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color, uint32_t col2) {
if (chr < 32 || chr > 126) return; // only ASCII 32-126 supported
chr -= 32; // align with font table entries
const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight();
const int font = w*h;
CRGB col = CRGB(color);
CRGBPalette16 grad = CRGBPalette16(col, col2 ? CRGB(col2) : col);
//if (w<5 || w>6 || h!=8) return;
for (int i = 0; i<h; i++) { // character height
int16_t y0 = y + i;
@@ -552,10 +555,11 @@ void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w,
case 60: bits = pgm_read_byte_near(&console_font_5x12[(chr * h) + i]); break; // 5x12 font
default: return;
}
col = ColorFromPalette(grad, (i+1)*255/h, 255, NOBLEND);
for (int j = 0; j<w; j++) { // character width
int16_t x0 = x + (w-1) - j;
if ((x0 >= 0 || x0 < cols) && ((bits>>(j+(8-w))) & 0x01)) { // bit set & drawing on-screen
addPixelColorXY(x0, y0, color);
addPixelColorXY(x0, y0, col);
}
}
}

View File

@@ -9,6 +9,10 @@
var d=document,laprev=55,maxB=1,maxV=0,maxM=4000,maxPB=4096,maxL=1333,maxLbquot=0; //maximum bytes for LED allocation: 4kB for 8266, 32kB for 32
var customStarts=false,startsDirty=[],maxCOOverrides=5;
var loc = false, locip;
d.um_p = [];
d.rsvd = [];
d.ro_gpio = [];
d.max_gpio = 39;
function H(){window.open("https://mm.kno.wled.ge/features/settings/#led-settings");}
function B(){window.open("/settings","_self");}
function gId(n){return d.getElementById(n);}
@@ -24,10 +28,6 @@
// success event
scE.addEventListener("load", () => {
//console.log("File loaded");
d.um_p = [];
d.rsvd = [];
d.ro_pins = [];
d.max_gpio = 39;
GetV();checkSi();setABL();
if (d.um_p[0]==-1) d.um_p.shift();
});
@@ -67,7 +67,7 @@
for (k=0;k<d.rsvd.length;k++) p.push(d.rsvd[k]); // fill with reservations
for (k=0;k<d.um_p.length;k++) p.push(d.um_p[k]); // fill with usermod pins
if (p.some((e)=>e==parseInt(LCs[i].value,10))) {alert(`Sorry, pins ${JSON.stringify(p)} can't be used.`);LCs[i].value="";LCs[i].focus();return false;}
else if (!(nm == "IR" || nm=="BT") && d.ro_pins.some((e)=>e==parseInt(LCs[i].value,10))) {alert(`Sorry, pins ${JSON.stringify(d.ro_gpio)} are input only.`);LCs[i].value="";LCs[i].focus();return false;}
else if (!(nm == "IR" || nm=="BT") && d.ro_gpio.some((e)=>e==parseInt(LCs[i].value,10))) {alert(`Sorry, pins ${JSON.stringify(d.ro_gpio)} are input only.`);LCs[i].value="";LCs[i].focus();return false;}
for (j=i+1; j<LCs.length; j++)
{
var n2 = LCs[j].name.substring(0,2);

View File

@@ -10,7 +10,7 @@
d.max_gpio = 39;
d.um_p = [];
d.rsvd = [];
d.ro_pins = [];
d.ro_gpio = [];
var umCfg = {};
var pins = [], pinO = [], owner;
var loc = false, locip;
@@ -102,8 +102,8 @@
break;
case "number":
c = `value="${o}"`;
if (f.substr(-3)==="pin") { //WLEDMM: this will not be used as pins are now dropdowns
c += ` max="${d.max_gpio}" min="-1" class="s"`;
if (f.substr(-3)==="pin") { //WLEDMM: this will not be used and should never happen as pins are now dropdowns
c += ` max="50" min="-1" class="s"`; //WLEDMM: hardcoded to 50 as d.max_gpio is not calculated yet here (done in appendGPIOinfo)
t = "int";
} else {
c += ' step="any" class="xxl"';
@@ -121,7 +121,7 @@
if (f.includes("pin")) {
var n = this.name.replace("[]","").substr(-3);
urows += `<select name="${k}:${f}${a?"[]":""}">`;
for (var j=-1; j<=d.max_gpio; j++) { // all possible pins
for (var j=-1; j<=50; j++) { // all possible pins WLEDMM: hardcoded to 50 as d.max_gpio is not calculated yet here (done in appendGPIOinfo)
let foundPin = -1;
for (var i=0; i<pins.length; i++) { // check if pin is reserved
if (pins[i] == j) foundPin = i;
@@ -233,7 +233,7 @@
//WLEDMM read only pins 🟠, reserved pins 🟣 and disabled, and remove pins > max_gpio
function pinDropdownsPost() {
// console.log('pinDropdownsPost', d.max_gpio, d.ro_pins, d.ro_gpio, d.rsvd);
// console.log('pinDropdownsPost', d.max_gpio, d.ro_gpio, d.rsvd);
var elements = gId("form_s").elements;
for (var i = 0, select; select = elements[i++];) {
@@ -244,14 +244,15 @@
// console.log("pinDropdownsPost option", c, c.value, d.ro_gpio.includes(c.value));
for (let j=0; j<d.ro_gpio.length; j++) if (d.ro_gpio[j] == c.value) c.text += " read only 🟠"; //if (d.ro_gpio.includes(c.value)) not working ???
for (let j=0; j<d.rsvd.length; j++) if (d.rsvd[j] == c.value) {c.text += " reserved 🟣"; c.disabled=true;} //now always disabled as post is done last if (d.rsvd.includes(c.value))
//remove pins >= max_gpio
//remove pins > max_gpio
if (c.value > d.max_gpio) {
select.removeChild(c);
i--; //decrease i by one because the index has been adjusted
}
//https://www.javascripttutorial.net/javascript-dom/javascript-add-remove-options/
//https://www.javascripttutorial.net/javascript-dom/javascript-remove-items-from-a-select-conditionally/
if (c.text.length <= 2) c.text += " 🟢";
if (c.text.length <= 4) c.text += " 🟢"; //2 digit number space and ⍼/⎌. If no reserved/read only/other um, then pin can be freely used (green)
for (let jj=0; jj<d.dt_pins.length; jj++) if (d.dt_pins[jj] == c.value) c.text += ((jj<9)?` D${jj}`:((jj==9)?` RX`:` TX`)); //WLEDMM: Add D0-D8, RX/TX to name
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -597,6 +597,86 @@ bool PinManagerClass::joinWire(int8_t pinSDA, int8_t pinSCL) {
return(true);
}
// WLEDMM more additions
// returns true if gpio supports touch functions
bool PinManagerClass::isPinTouch(int gpio) {
#if defined(ARDUINO_ARCH_ESP32)
if (digitalPinToTouchChannel(gpio) >= 0) return true;
#endif
return false; // fall-through case
}
// returns true if gpio supports analogRead
bool PinManagerClass::isPinAnalog(int gpio) {
#if !defined(ARDUINO_ARCH_ESP32)
if (gpio == A0) return true; // for 8266
#else // for ESP32 variants
if (digitalPinToAnalogChannel(gpio) >= 0) return true;
#endif
return false; // fall-through case
}
// returns true if gpio supports analogRead, and it belongs to ADC unit 1
bool PinManagerClass::isPinADC1(int gpio) {
if ((gpio < 0) || !isPinAnalog(gpio)) return false;
#if !defined(ARDUINO_ARCH_ESP32)
if (gpio == A0) return true; // for 8266
#else // for ESP32 variants
#ifdef SOC_ADC_CHANNEL_NUM
if (digitalPinToAnalogChannel(gpio) < SOC_ADC_CHANNEL_NUM(0)) return true; // ADC1 on ESP32-S3, ESP32-S2, ESP32-C3
#else
if (digitalPinToAnalogChannel(gpio) < 8) return true; // ADC1 on classic ESP32
#endif
#endif
return false; // fall-through case
}
// returns true if gpio supports analogRead, and it belongs to ADC unit 2
bool PinManagerClass::isPinADC2(int gpio) {
if ((gpio < 0) || !isPinAnalog(gpio)) return false; // catch errors
#if !defined(ARDUINO_ARCH_ESP32)
return false; // for 8266 - no ADC2
#else // for ESP32 variants
if (isPinADC1(gpio) == false) return true; // analog but not ADC1 --> must be ADC2
#endif
return false; // fall-through case
}
// returns GPIO number for ADC unit x, channel y. 255 = no such pin
// see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/gpio.html#gpio-summary
uint8_t PinManagerClass::getADCPin(AdcIdentifier adcUnit, uint8_t adcPort)
{
#if !defined(ARDUINO_ARCH_ESP32)
if ((adcUnit == ADC1) && (adcPort == 0)) return A0; // for 8266
else return(PM_NO_PIN);
#else // for ESP32 variants
if ((adcUnit != ADC1) && (adcUnit != ADC2)) return(PM_NO_PIN); // catch errors
#if defined(SOC_ADC_MAX_CHANNEL_NUM) // for ESP32-S3, ESP32-S2, ESP32-C3
int8_t analogChannel = (adcUnit == ADC1) ? adcPort : (SOC_ADC_MAX_CHANNEL_NUM + adcPort);
if (adcPort >= SOC_ADC_MAX_CHANNEL_NUM) analogChannel = 255;
#else // for classic ESP32
int8_t analogChannel = (adcUnit == ADC1) ? adcPort : (10 + adcPort);
if (adcPort >= 10) analogChannel = 255;
#endif
//int analogPin = analogChannelToDigitalPin(analogChannel);
int analogPin = analogInputToDigitalPin(analogChannel);
if (analogPin >= 0) return(analogPin);
else return(PM_NO_PIN);
#endif
return(PM_NO_PIN); // fall-through case
}
// WLEDMM end
/* see https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/gpio.html
* The ESP32-S3 chip features 45 physical GPIO pins (GPIO0 ~ GPIO21 and GPIO26 ~ GPIO48). Each pin can be used as a general-purpose I/O
* Strapping pins: GPIO0, GPIO3, GPIO45 and GPIO46 are strapping pins. For more infomation, please refer to ESP32-S3 datasheet.

View File

@@ -67,7 +67,7 @@ static_assert(0u == static_cast<uint8_t>(PinOwner::None), "PinOwner::None must b
class PinManagerClass {
private:
#ifdef ESP8266
#define WLED_NUM_PINS 17
#define WLED_NUM_PINS 18 // WLEDMM include A0 = gpio17
uint8_t pinAlloc[3] = {0x00, 0x00, 0x00}; //24bit, 1 bit per pin, we use first 17bits
PinOwner ownerTag[WLED_NUM_PINS] = { PinOwner::None };
PinOwner ownerConflict[WLED_NUM_PINS] = { PinOwner::None }; // WLEDMM: record pin alloc conflicts
@@ -124,10 +124,22 @@ class PinManagerClass {
bool isPinOk(byte gpio, bool output = true);
PinOwner getPinOwner(byte gpio);
// WLEDMM begin
String getOwnerText(PinOwner tag); // WLEDMM - return PIN owner tag as text
String getPinOwnerText(int gpio); // WLEDMM - return PIN owner as text
String getPinSpecialText(int gpio); // WLEDMM - return PIN special comments (if any)
String getPinConflicts(int gpio); // WLEDMM - return PIN alloc conflicts (if any)
bool isPinTouch(int gpio); // true if gpio supports touch functions
bool isPinAnalog(int gpio); // true if gpio supports analogRead
bool isPinADC1(int gpio); // true if gpio supports analogRead, and it belongs to ADC unit 1
bool isPinADC2(int gpio); // true if gpio supports analogRead, and it belongs to ADC unit 2
#define PM_NO_PIN 255
typedef enum { ADC_none = 0, ADC1 = 1, ADC2 = 2 } AdcIdentifier;
uint8_t getADCPin(AdcIdentifier adcUnit, uint8_t adcPort); // get GPIO number for ADC unit x, channel y. 255 = no such pin
// WLEDMM end
#ifdef ARDUINO_ARCH_ESP32
byte allocateLedc(byte channels);
void deallocateLedc(byte pos, byte channels);

View File

@@ -575,6 +575,27 @@ void WLED::setup()
USER_FLUSH(); // avoid lost lines (Serial buffer overflow)
}
}
#if 0 // for testing
USER_PRINTLN(F("\n"));
USER_PRINTF("ADC1-0 = %d, ADC1-3 = %d, ADC1-7 = %d, ADC2-0 = %d, ADC2-1 = %d, ADC2-8 = %d, ADC2-10 = %d\n",
pinManager.getADCPin(PinManagerClass::ADC1, 0), pinManager.getADCPin(PinManagerClass::ADC1, 3), pinManager.getADCPin(PinManagerClass::ADC1, 7),
pinManager.getADCPin(PinManagerClass::ADC2, 0), pinManager.getADCPin(PinManagerClass::ADC2, 1), pinManager.getADCPin(PinManagerClass::ADC2, 8),
pinManager.getADCPin(PinManagerClass::ADC2, 10)
);
USER_PRINTLN();
for(int p=0; p<12; p++) {
if(pinManager.getADCPin(PinManagerClass::ADC1, p) < 255)
USER_PRINTF("ADC1-%d = %d, ", p, pinManager.getADCPin(PinManagerClass::ADC1, p));
}
USER_PRINTLN();
for(int p=0; p<12; p++) {
if(pinManager.getADCPin(PinManagerClass::ADC2, p) < 255)
USER_PRINTF("ADC2-%d = %d, ", p, pinManager.getADCPin(PinManagerClass::ADC2, p));
}
USER_PRINTLN(F("\n"));
#endif
USER_PRINTLN(F("WLED initialization done.\n"));
delay(50);
// repeat Ada prompt
@@ -784,8 +805,10 @@ void WLED::initConnection()
WiFi.begin(clientSSID, clientPass);
#ifdef ARDUINO_ARCH_ESP32
// WLEDMM - if your board has issues connecting to WiFi, try uncommenting this
// WiFi.setTxPower(WIFI_POWER_5dBm); // required for ESP32-C3FH4-RGB
#ifdef WLEDMM_WIFI_POWERON_HACK
// WLEDMM - if your board has issues connecting to WiFi, try this
WiFi.setTxPower(WIFI_POWER_5dBm); // required for ESP32-C3FH4-RGB
#endif
WiFi.setSleep(!noWifiSleep);
WiFi.setHostname(hostname);
#else

View File

@@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2301170
#define VERSION 2301202
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG

View File

@@ -273,6 +273,14 @@ void appendGPIOinfo() {
oappendi(16);
#endif
oappend(SET_F(";"));
char dt_pins[30];
#if defined(ESP8266) && !defined(ARDUINO_ESP8266_ESP01)
sprintf(dt_pins, "d.dt_pins=[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d];", D0, D1, D2, D3, D4, D5, D6, D7, D8, hardwareRX, hardwareTX);
#else
sprintf(dt_pins, "d.dt_pins=[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d];", 99, 99, 99, 99, 99, 99, 99, 99, 99, hardwareRX, hardwareTX);
#endif
oappend(dt_pins);
}
//get values for settings form in javascript
@@ -748,7 +756,7 @@ void getSettingsJS(AsyncWebServerRequest* request, byte subPage, char* dest) //W
if (usermod) usermod->appendConfigData();
}
// oappend(SET_F("console.log('getSettingsJS fix ro pins', d.max_gpio, d.ro_pins, d.ro_gpio);"));
// oappend(SET_F("console.log('getSettingsJS fix ro pins', d.max_gpio, d.ro_gpio);"));
oappend(SET_F("pinDropdownsPost();"));
}