Refactor global pins settings using dropdowns and add to rotary_encoder

- replace rOption by  xOption (extend option) to show default value (⎌)
- Usermod rotary_encoder: add appendConfigData function and show help and default functions
- Settings.htm: Move Usermods(pins) below the usermods

Settings_um.htm
- remove SDAPin etc
- comment check(0,k) as not used anymore
- add xOption
- add generated global pin fields (using addField) in ldS
- remove hard coded global pin fields

set.cpp: set i2c_sda etc using new generated fields
xml.cpp: set generated fields values using i2c_sda etc and show defaults
This commit is contained in:
Ewoud
2023-01-04 12:17:14 +01:00
parent 0571aa92f2
commit 23663a46f9
9 changed files with 379 additions and 394 deletions

View File

@@ -1972,7 +1972,7 @@ class AudioReactive : public Usermod {
//WLEDMM: add defaults
#ifdef AUDIOPIN
oappend(SET_F("rOption('AudioReactive:analogmic:pin',1,'")); oappendi(AUDIOPIN); oappend(" ⎌',"); oappendi(AUDIOPIN); oappend(");");
oappend(SET_F("xOption('AudioReactive:analogmic:pin',1,' ⎌',")); oappendi(AUDIOPIN); oappend(");");
#endif
oappend(SET_F("dd=addDropdown('AudioReactive','digitalmic:type');"));
@@ -2102,15 +2102,15 @@ class AudioReactive : public Usermod {
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("rOption('AudioReactive:digitalmic:pin[]',0,'")); oappendi(I2S_SDPIN); oappend(" ⎌',"); oappendi(I2S_SDPIN); oappend(");");
oappend(SET_F("xOption('AudioReactive:digitalmic:pin[]',0,' ⎌',")); oappendi(I2S_SDPIN); oappend(");");
#endif
oappend(SET_F("addInfo('AudioReactive:digitalmic:pin[]',1,'<i>ws/clk/lrck</i>','I2S WS');"));
#ifdef I2S_WSPIN
oappend(SET_F("rOption('AudioReactive:digitalmic:pin[]',1,'")); oappendi(I2S_WSPIN); oappend(" ⎌',"); oappendi(I2S_WSPIN); oappend(");");
oappend(SET_F("xOption('AudioReactive:digitalmic:pin[]',1,' ⎌',")); oappendi(I2S_WSPIN); oappend(");");
#endif
oappend(SET_F("addInfo('AudioReactive:digitalmic:pin[]',2,'<i>sck/bclk</i>','I2S SCK');"));
#ifdef I2S_CKPIN
oappend(SET_F("rOption('AudioReactive:digitalmic:pin[]',2,'")); oappendi(I2S_CKPIN); oappend(" ⎌',"); oappendi(I2S_CKPIN); oappend(");");
oappend(SET_F("xOption('AudioReactive:digitalmic:pin[]',2,' ⎌',")); oappendi(I2S_CKPIN); oappend(");");
#endif
oappend(SET_F("addInfo('AudioReactive:digitalmic:pin[]',3,'<i>master clock</i>','I2S MCLK');"));
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)

View File

@@ -1050,12 +1050,12 @@ class FourLineDisplayUsermod : public Usermod {
// WLEDMM add defaults
oappend(SET_F("addInfo('4LineDisplay:pin[]',0,'','I2C/SPI CLK');"));
#ifdef FLD_PIN_SCL
oappend(SET_F("rOption('4LineDisplay:pin[]',0,'")); oappendi(FLD_PIN_SCL); oappend(" ⎌',"); oappendi(FLD_PIN_SCL); oappend(");");
oappend(SET_F("xOption('4LineDisplay:pin[]',0,' ⎌',")); oappendi(FLD_PIN_SCL); oappend(");");
#endif
oappend(SET_F("rOption('4LineDisplay:pin[]',0,'use global (")); oappendi(i2c_scl); oappend(")',-1);");
oappend(SET_F("addInfo('4LineDisplay:pin[]',1,'','I2C/SPI DTA');"));
#ifdef FLD_PIN_SDA
oappend(SET_F("rOption('4LineDisplay:pin[]',1,'")); oappendi(FLD_PIN_SDA); oappend(" ⎌',"); oappendi(FLD_PIN_SDA); oappend(");");
oappend(SET_F("xOption('4LineDisplay:pin[]',1,' ⎌',")); oappendi(FLD_PIN_SDA); oappend(");");
#endif
oappend(SET_F("rOption('4LineDisplay:pin[]',1,'use global (")); oappendi(i2c_sda); oappend(")',-1);");
oappend(SET_F("addInfo('4LineDisplay:pin[]',2,'','SPI CS');"));

View File

@@ -865,6 +865,21 @@ public:
DEBUG_PRINTLN(F("Rotary Encoder config saved."));
}
//WLEDMM: add appendConfigData
void appendConfigData()
{
oappend(SET_F("addInfo('Rotary-Encoder:help',0,'<button onclick=\"location.href=&quot;https://mm.kno.wled.ge/usermods/Rotary-Encoder&quot;\" type=\"button\">?</button>');")); // 0 is field type, 1 is actual field
#ifdef ENCODER_DT_PIN
oappend(SET_F("xOption('Rotary-Encoder:DT-pin',1,' ⎌',")); oappendi(ENCODER_DT_PIN); oappend(");");
#endif
#ifdef ENCODER_CLK_PIN
oappend(SET_F("xOption('Rotary-Encoder:CLK-pin',1,' ⎌',")); oappendi(ENCODER_CLK_PIN); oappend(");");
#endif
#ifdef ENCODER_SW_PIN
oappend(SET_F("xOption('Rotary-Encoder:SW-pin',1,' ⎌',")); oappendi(ENCODER_SW_PIN); oappend(");");
#endif
}
/**
* readFromConfig() is called before setup() to populate properties from values stored in cfg.json
*