4ld and ar um: default pins -1, if set, show in pin dropdown

Audio reactive usermod: add pio.ini build flags defaults (⎌) for mclk, sda and scl (if set)

4ld usermod: 
- if pio.ini build flags not set, make them -1 (undefined is even better but then problems with allocate pins, to be done later)
- pio.ini build flags defaults (⎌) different if spi (clockspi and mosispi instead of scl and sda)
- add pio.ini build flags defaults (⎌) for SPI CS, DC and RESET
This commit is contained in:
Ewoud
2023-01-27 11:09:08 +01:00
parent 3953b7a2a5
commit 6437cc8c7e
4 changed files with 167 additions and 146 deletions

View File

@@ -405,10 +405,10 @@ public:
}
void appendConfigData() {
oappend(SET_F("addHB('BME280/BMP280');"));
oappend(SET_F("addHB('BME280');"));
oappend(SET_F("addInfo('BME280/BMP280:pin[]',0,'','I2C/SPI CLK');"));
oappend(SET_F("dRO('BME280/BMP280:pin[]',0);"));
oappend(SET_F("dRO('BME280/BMP280:pin[]',0);")); // disable read only pins
oappend(SET_F("rOpt('BME280/BMP280:pin[]',0,'use global (")); oappendi(i2c_scl); oappend(")',-1);");
oappend(SET_F("addInfo('BME280/BMP280:pin[]',1,'','I2C/SPI DTA');"));

View File

@@ -2031,53 +2031,53 @@ class AudioReactive : public Usermod {
oappend(SET_F("addInfo('AudioReactive:help',0,'<button onclick=\"location.href=&quot;https://mm.kno.wled.ge/soundreactive/Sound-Settings&quot;\" type=\"button\">?</button>');"));
//WLEDMM: add defaults
#ifdef AUDIOPIN
oappend(SET_F("xOpt('AudioReactive:analogmic:pin',1,' ⎌',")); oappendi(AUDIOPIN); oappend(");");
#endif
#ifdef AUDIOPIN
oappend(SET_F("xOpt('AudioReactive:analogmic:pin',1,' ⎌',")); oappendi(AUDIOPIN); oappend(");");
#endif
oappend(SET_F("aOpt('AudioReactive:analogmic:pin',1);")); //only analog options
oappend(SET_F("dd=addDropdown('AudioReactive','digitalmic:type');"));
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
#if SR_DMTYPE==0
oappend(SET_F("addOption(dd,'Generic Analog (⎌)',0);"));
#else
oappend(SET_F("addOption(dd,'Generic Analog',0);"));
#endif
#endif
#if SR_DMTYPE==1
oappend(SET_F("addOption(dd,'Generic I2S (⎌)',1);"));
#else
oappend(SET_F("addOption(dd,'Generic I2S',1);"));
#endif
#if SR_DMTYPE==2
oappend(SET_F("addOption(dd,'ES7243 (⎌)',2);"));
#else
oappend(SET_F("addOption(dd,'ES7243',2);"));
#endif
#if SR_DMTYPE==3
oappend(SET_F("addOption(dd,'SPH0654 (⎌)',3);"));
#else
oappend(SET_F("addOption(dd,'SPH0654',3);"));
#endif
#if SR_DMTYPE==4
oappend(SET_F("addOption(dd,'Generic I2S with Mclk (⎌)',4);"));
#else
oappend(SET_F("addOption(dd,'Generic I2S with Mclk',4);"));
#endif
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if SR_DMTYPE==5
oappend(SET_F("addOption(dd,'Generic I2S PDM (⎌)',5);"));
#else
oappend(SET_F("addOption(dd,'Generic I2S PDM',5);"));
#endif
#endif
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
#if SR_DMTYPE==0
oappend(SET_F("addOption(dd,'Generic Analog (⎌)',0);"));
#else
oappend(SET_F("addOption(dd,'Generic Analog',0);"));
#endif
#endif
#if SR_DMTYPE==1
oappend(SET_F("addOption(dd,'Generic I2S (⎌)',1);"));
#else
oappend(SET_F("addOption(dd,'Generic I2S',1);"));
#endif
#if SR_DMTYPE==2
oappend(SET_F("addOption(dd,'ES7243 (⎌)',2);"));
#else
oappend(SET_F("addOption(dd,'ES7243',2);"));
#endif
#if SR_DMTYPE==3
oappend(SET_F("addOption(dd,'SPH0654 (⎌)',3);"));
#else
oappend(SET_F("addOption(dd,'SPH0654',3);"));
#endif
#if SR_DMTYPE==4
oappend(SET_F("addOption(dd,'Generic I2S with Mclk (⎌)',4);"));
#else
oappend(SET_F("addOption(dd,'Generic I2S with Mclk',4);"));
#endif
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if SR_DMTYPE==5
oappend(SET_F("addOption(dd,'Generic I2S PDM (⎌)',5);"));
#else
oappend(SET_F("addOption(dd,'Generic I2S PDM',5);"));
#endif
#endif
#ifdef SR_SQUELCH
oappend(SET_F("addInfo('AudioReactive:config:squelch',1,'<i>&#9100; ")); oappendi(SR_SQUELCH); oappend("</i>');"); // 0 is field type, 1 is actual field
#endif
#ifdef SR_GAIN
oappend(SET_F("addInfo('AudioReactive:config:gain',1,'<i>&#9100; ")); oappendi(SR_GAIN); oappend("</i>');"); // 0 is field type, 1 is actual field
#endif
#ifdef SR_SQUELCH
oappend(SET_F("addInfo('AudioReactive:config:squelch',1,'<i>&#9100; ")); oappendi(SR_SQUELCH); oappend("</i>');"); // 0 is field type, 1 is actual field
#endif
#ifdef SR_GAIN
oappend(SET_F("addInfo('AudioReactive:config:gain',1,'<i>&#9100; ")); oappendi(SR_GAIN); oappend("</i>');"); // 0 is field type, 1 is actual field
#endif
oappend(SET_F("dd=addDropdown('AudioReactive','config:AGC');"));
oappend(SET_F("addOption(dd,'Off',0);"));
@@ -2100,92 +2100,107 @@ class AudioReactive : public Usermod {
//WLEDMM add defaults
oappend(SET_F("dd=addDropdown('AudioReactive','frequency:profile');"));
#if SR_FREQ_PROF==0
oappend(SET_F("addOption(dd,'Generic Microphone (⎌)',0);"));
#else
oappend(SET_F("addOption(dd,'Generic Microphone',0);"));
#endif
#if SR_FREQ_PROF==1
oappend(SET_F("addOption(dd,'Generic Line-In (⎌)',1);"));
#else
oappend(SET_F("addOption(dd,'Generic Line-In',1);"));
#endif
#if SR_FREQ_PROF==5
oappend(SET_F("addOption(dd,'ICS-43434 (⎌)',5);"));
#else
oappend(SET_F("addOption(dd,'ICS-43434',5);"));
#endif
#if SR_FREQ_PROF==6
oappend(SET_F("addOption(dd,'ICS-43434 - big speakers (⎌)',6);"));
#else
oappend(SET_F("addOption(dd,'ICS-43434 - big speakers',6);"));
#endif
#if SR_FREQ_PROF==7
oappend(SET_F("addOption(dd,'SPM1423 (⎌)',7);"));
#else
oappend(SET_F("addOption(dd,'SPM1423',7);"));
#endif
#if SR_FREQ_PROF==2
oappend(SET_F("addOption(dd,'IMNP441 (⎌)',2);"));
#else
oappend(SET_F("addOption(dd,'IMNP441',2);"));
#endif
#if SR_FREQ_PROF==3
oappend(SET_F("addOption(dd,'IMNP441 - big speakers (⎌)',3);"));
#else
oappend(SET_F("addOption(dd,'IMNP441 - big speakers',3);"));
#endif
#if SR_FREQ_PROF==4
oappend(SET_F("addOption(dd,'IMNP441 - small speakers (⎌)',4);"));
#else
oappend(SET_F("addOption(dd,'IMNP441 - small speakers',4);"));
#endif
#if SR_FREQ_PROF==10
oappend(SET_F("addOption(dd,'flat - no adjustments (⎌)',10);"));
#else
oappend(SET_F("addOption(dd,'flat - no adjustments',10);"));
#endif
#if SR_FREQ_PROF==8
oappend(SET_F("addOption(dd,'userdefined #1 (⎌)',8);"));
#else
oappend(SET_F("addOption(dd,'userdefined #1',8);"));
#endif
#if SR_FREQ_PROF==9
oappend(SET_F("addOption(dd,'userdefined #2 (⎌)',9);"));
#else
oappend(SET_F("addOption(dd,'userdefined #2',9);"));
#endif
#if SR_FREQ_PROF==0
oappend(SET_F("addOption(dd,'Generic Microphone (⎌)',0);"));
#else
oappend(SET_F("addOption(dd,'Generic Microphone',0);"));
#endif
#if SR_FREQ_PROF==1
oappend(SET_F("addOption(dd,'Generic Line-In (⎌)',1);"));
#else
oappend(SET_F("addOption(dd,'Generic Line-In',1);"));
#endif
#if SR_FREQ_PROF==5
oappend(SET_F("addOption(dd,'ICS-43434 (⎌)',5);"));
#else
oappend(SET_F("addOption(dd,'ICS-43434',5);"));
#endif
#if SR_FREQ_PROF==6
oappend(SET_F("addOption(dd,'ICS-43434 - big speakers (⎌)',6);"));
#else
oappend(SET_F("addOption(dd,'ICS-43434 - big speakers',6);"));
#endif
#if SR_FREQ_PROF==7
oappend(SET_F("addOption(dd,'SPM1423 (⎌)',7);"));
#else
oappend(SET_F("addOption(dd,'SPM1423',7);"));
#endif
#if SR_FREQ_PROF==2
oappend(SET_F("addOption(dd,'IMNP441 (⎌)',2);"));
#else
oappend(SET_F("addOption(dd,'IMNP441',2);"));
#endif
#if SR_FREQ_PROF==3
oappend(SET_F("addOption(dd,'IMNP441 - big speakers (⎌)',3);"));
#else
oappend(SET_F("addOption(dd,'IMNP441 - big speakers',3);"));
#endif
#if SR_FREQ_PROF==4
oappend(SET_F("addOption(dd,'IMNP441 - small speakers (⎌)',4);"));
#else
oappend(SET_F("addOption(dd,'IMNP441 - small speakers',4);"));
#endif
#if SR_FREQ_PROF==10
oappend(SET_F("addOption(dd,'flat - no adjustments (⎌)',10);"));
#else
oappend(SET_F("addOption(dd,'flat - no adjustments',10);"));
#endif
#if SR_FREQ_PROF==8
oappend(SET_F("addOption(dd,'userdefined #1 (⎌)',8);"));
#else
oappend(SET_F("addOption(dd,'userdefined #1',8);"));
#endif
#if SR_FREQ_PROF==9
oappend(SET_F("addOption(dd,'userdefined #2 (⎌)',9);"));
#else
oappend(SET_F("addOption(dd,'userdefined #2',9);"));
#endif
oappend(SET_F("dd=addDropdown('AudioReactive','sync:mode');"));
oappend(SET_F("addOption(dd,'Off',0);"));
oappend(SET_F("addOption(dd,'Send',1);"));
oappend(SET_F("addOption(dd,'Receive',2);"));
oappend(SET_F("addInfo('AudioReactive:digitalmic:type',1,'<i>requires reboot!</i>');")); // 0 is field type, 1 is actual field
oappend(SET_F("addInfo('AudioReactive:digitalmic:pin[]',0,'<i>sd/data/dout</i>','I2S SD');"));
#ifdef I2S_SDPIN
oappend(SET_F("xOpt('AudioReactive:digitalmic:pin[]',0,' ⎌',")); oappendi(I2S_SDPIN); oappend(");");
#endif
#ifdef I2S_SDPIN
oappend(SET_F("xOpt('AudioReactive:digitalmic:pin[]',0,' ⎌',")); oappendi(I2S_SDPIN); oappend(");");
#endif
oappend(SET_F("addInfo('AudioReactive:digitalmic:pin[]',1,'<i>ws/clk/lrck</i>','I2S WS');"));
oappend(SET_F("dRO('AudioReactive:digitalmic:pin[]',1);"));
#ifdef I2S_WSPIN
oappend(SET_F("xOpt('AudioReactive:digitalmic:pin[]',1,' ⎌',")); oappendi(I2S_WSPIN); oappend(");");
#endif
oappend(SET_F("dRO('AudioReactive:digitalmic:pin[]',1);")); // disable read only pins
#ifdef I2S_WSPIN
oappend(SET_F("xOpt('AudioReactive:digitalmic:pin[]',1,' ⎌',")); oappendi(I2S_WSPIN); oappend(");");
#endif
oappend(SET_F("addInfo('AudioReactive:digitalmic:pin[]',2,'<i>sck/bclk</i>','I2S SCK');"));
oappend(SET_F("dRO('AudioReactive:digitalmic:pin[]',2);"));
#ifdef I2S_CKPIN
oappend(SET_F("xOpt('AudioReactive:digitalmic:pin[]',2,' ⎌',")); oappendi(I2S_CKPIN); oappend(");");
#endif
oappend(SET_F("dRO('AudioReactive:digitalmic:pin[]',2);")); // disable read only pins
#ifdef I2S_CKPIN
oappend(SET_F("xOpt('AudioReactive:digitalmic:pin[]',2,' ⎌',")); oappendi(I2S_CKPIN); oappend(");");
#endif
oappend(SET_F("addInfo('AudioReactive:digitalmic:pin[]',3,'<i>master clock</i>','I2S MCLK');"));
oappend(SET_F("dRO('AudioReactive:digitalmic:pin[]',3);"));
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
oappend(SET_F("dOpt('AudioReactive:digitalmic:pin[]',3,2,2);")); //only use -1, 0, 1 or 3
oappend(SET_F("dOpt('AudioReactive:digitalmic:pin[]',3,4,39);")); //only use -1, 0, 1 or 3
#endif
oappend(SET_F("dRO('AudioReactive:digitalmic:pin[]',3);")); // disable read only pins
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
oappend(SET_F("dOpt('AudioReactive:digitalmic:pin[]',3,2,2);")); //only use -1, 0, 1 or 3
oappend(SET_F("dOpt('AudioReactive:digitalmic:pin[]',3,4,39);")); //only use -1, 0, 1 or 3
#endif
#ifdef MCLK_PIN
oappend(SET_F("xOpt('AudioReactive:digitalmic:pin[]',3,' ⎌',")); oappendi(MCLK_PIN); oappend(");");
#endif
oappend(SET_F("addInfo('AudioReactive:digitalmic:pin[]',4,'','I2C SDA');"));
oappend(SET_F("rOpt('AudioReactive:digitalmic:pin[]',4,'use global (")); oappendi(i2c_sda); oappend(")',-1);");
#ifdef ES7243_SDAPIN
oappend(SET_F("xOpt('AudioReactive:digitalmic:pin[]',4,' ⎌',")); oappendi(ES7243_SDAPIN); oappend(");");
#endif
oappend(SET_F("addInfo('AudioReactive:digitalmic:pin[]',5,'','I2C SCL');"));
oappend(SET_F("rOpt('AudioReactive:digitalmic:pin[]',5,'use global (")); oappendi(i2c_scl); oappend(")',-1);");
oappend(SET_F("dRO('AudioReactive:digitalmic:pin[]',5);"));
#ifdef ES7243_SCLPIN
oappend(SET_F("xOpt('AudioReactive:digitalmic:pin[]',5,' ⎌',")); oappendi(ES7243_SCLPIN); oappend(");");
#endif
oappend(SET_F("dRO('AudioReactive:digitalmic:pin[]',5);")); // disable read only pins
}

View File

@@ -31,35 +31,26 @@
//The SCL and SDA pins are defined here.
#ifndef FLD_PIN_SCL
#define FLD_PIN_SCL i2c_scl
#define FLD_PIN_SCL -1
#endif
#ifndef FLD_PIN_SDA
#define FLD_PIN_SDA i2c_sda
#define FLD_PIN_SDA -1
#endif
#ifndef FLD_PIN_CLOCKSPI
#define FLD_PIN_CLOCKSPI spi_sclk
#define FLD_PIN_CLOCKSPI -1
#endif
#ifndef FLD_PIN_MOSISPI //WLEDMM renamed from HW_PIN_DATASPI
#define FLD_PIN_MOSISPI spi_mosi
#ifndef FLD_PIN_MOSISPI //WLEDMM renamed from HW_PIN_DATASPI
#define FLD_PIN_MOSISPI -1
#endif
#ifndef FLD_PIN_CS
#define FLD_PIN_CS spi_cs
#define FLD_PIN_CS -1
#endif
#ifdef ARDUINO_ARCH_ESP32
#ifndef FLD_PIN_DC
#define FLD_PIN_DC 19
#endif
#ifndef FLD_PIN_RESET
#define FLD_PIN_RESET 26
#endif
#else
#ifndef FLD_PIN_DC
#define FLD_PIN_DC 12
#endif
#ifndef FLD_PIN_RESET
#define FLD_PIN_RESET 16
#endif
#ifndef FLD_PIN_DC
#define FLD_PIN_DC -1
#endif
#ifndef FLD_PIN_RESET
#define FLD_PIN_RESET -1
#endif
#ifndef FLD_TYPE
@@ -1064,27 +1055,42 @@ class FourLineDisplayUsermod : public Usermod {
bool isSPI = (type == SSD1306_SPI || type == SSD1306_SPI64);
// WLEDMM add defaults
oappend(SET_F("addInfo('4LineDisplay:pin[]',0,'','I2C/SPI CLK');"));
oappend(SET_F("dRO('4LineDisplay:pin[]',0);"));
#ifdef FLD_PIN_SCL
oappend(SET_F("xOpt('4LineDisplay:pin[]',0,' ⎌',")); oappendi(FLD_PIN_SCL); oappend(");");
#endif
oappend(SET_F("dRO('4LineDisplay:pin[]',0);")); // disable read only pins
if (isSPI) {
oappend(SET_F("rOpt('4LineDisplay:pin[]',0,'use global (")); oappendi(spi_sclk); oappend(")',-1);");
#ifdef FLD_PIN_CLOCKSPI
oappend(SET_F("xOpt('4LineDisplay:pin[]',0,' ⎌',")); oappendi(FLD_PIN_CLOCKSPI); oappend(");");
#endif
} else {
oappend(SET_F("rOpt('4LineDisplay:pin[]',0,'use global (")); oappendi(i2c_scl); oappend(")',-1);");
#ifdef FLD_PIN_SCL
oappend(SET_F("xOpt('4LineDisplay:pin[]',0,' ⎌',")); oappendi(FLD_PIN_SCL); oappend(");");
#endif
}
oappend(SET_F("addInfo('4LineDisplay:pin[]',1,'','I2C/SPI DTA');"));
#ifdef FLD_PIN_SDA
oappend(SET_F("xOpt('4LineDisplay:pin[]',1,' ⎌',")); oappendi(FLD_PIN_SDA); oappend(");");
#endif
if (isSPI) {
oappend(SET_F("rOpt('4LineDisplay:pin[]',1,'use global (")); oappendi(spi_mosi); oappend(")',-1);");
#ifdef FLD_PIN_MOSISPI
oappend(SET_F("xOpt('4LineDisplay:pin[]',1,' ⎌',")); oappendi(FLD_PIN_MOSISPI); oappend(");");
#endif
} else {
oappend(SET_F("rOpt('4LineDisplay:pin[]',1,'use global (")); oappendi(i2c_sda); oappend(")',-1);");
#ifdef FLD_PIN_SDA
oappend(SET_F("xOpt('4LineDisplay:pin[]',1,' ⎌',")); oappendi(FLD_PIN_SDA); oappend(");");
#endif
}
oappend(SET_F("addInfo('4LineDisplay:pin[]',2,'','SPI CS');"));
#ifdef FLD_PIN_CS
oappend(SET_F("xOpt('4LineDisplay:pin[]',2,' ⎌',")); oappendi(FLD_PIN_CS); oappend(");");
#endif
oappend(SET_F("addInfo('4LineDisplay:pin[]',3,'','SPI DC');"));
#ifdef FLD_PIN_DC
oappend(SET_F("xOpt('4LineDisplay:pin[]',3,' ⎌',")); oappendi(FLD_PIN_DC); oappend(");");
#endif
oappend(SET_F("addInfo('4LineDisplay:pin[]',4,'','SPI RST');"));
#ifdef FLD_PIN_RESET
oappend(SET_F("xOpt('4LineDisplay:pin[]',4,' ⎌',")); oappendi(FLD_PIN_RESET); oappend(");");
#endif
//WLEDMM add errorMessage to um settings
if (strcmp(errorMessage, "") != 0) {

View File

@@ -734,7 +734,7 @@ void getSettingsJS(AsyncWebServerRequest* request, byte subPage, char* dest) //W
#endif
oappend(SET_F("addInfo('if:SCL:pin',0,'', 'SCL');"));
oappend(SET_F("xOpt('if:SCL:pin',1,' ⍼',")); oappendi(SCL); oappend(");");
oappend(SET_F("dRO('if:SCL:pin',1);"));
oappend(SET_F("dRO('if:SCL:pin',1);")); // disable read only pins
#ifdef HW_PIN_SCL
oappend(SET_F("xOpt('if:SCL:pin',1,' ⎌',")); oappendi(HW_PIN_SCL); oappend(");");
#endif
@@ -750,7 +750,7 @@ void getSettingsJS(AsyncWebServerRequest* request, byte subPage, char* dest) //W
#endif
oappend(SET_F("addInfo('if:SCLK:pin',0,'', 'SCLK');"));
oappend(SET_F("xOpt('if:SCLK:pin',1,' ⍼',")); oappendi(SCK); oappend(");");
oappend(SET_F("dRO('if:SCLK:pin',1);"));
oappend(SET_F("dRO('if:SCLK:pin',1);")); // disable read only pins
#ifdef HW_PIN_CLOCKSPI
oappend(SET_F("xOpt('if:SCLK:pin',1,' ⎌',")); oappendi(HW_PIN_CLOCKSPI); oappend(");");
#endif