Skip to content

Commit

Permalink
Complete usermod conversion
Browse files Browse the repository at this point in the history
This is largely a search-and-replace operation; no optimization done.
  • Loading branch information
willmmiles committed Sep 7, 2024
1 parent e2b1d6b commit 89dcfc5
Show file tree
Hide file tree
Showing 17 changed files with 192 additions and 192 deletions.
10 changes: 5 additions & 5 deletions usermods/Animated_Staircase/Animated_Staircase.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,11 @@ class Animated_Staircase : public Usermod {
}
}

void appendConfigData() {
//oappend(SET_F("dd=addDropdown('staircase','selectfield');"));
//oappend(SET_F("addOption(dd,'1st value',0);"));
//oappend(SET_F("addOption(dd,'2nd value',1);"));
//oappend(SET_F("addInfo('staircase:selectfield',1,'additional info');")); // 0 is field type, 1 is actual field
void appendConfigData(Print& dest) {
//dest.print(F("dd=addDropdown('staircase','selectfield');"));
//dest.print(F("addOption(dd,'1st value',0);"));
//dest.print(F("addOption(dd,'2nd value',1);"));
//dest.print(F("addInfo('staircase:selectfield',1,'additional info');")); // 0 is field type, 1 is actual field
}


Expand Down
46 changes: 23 additions & 23 deletions usermods/BME68X_v2/usermod_bme68x.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class UsermodBME68X : public Usermod {
void loop(); // Loop of the user module called by wled main in loop
void setup(); // Setup of the user module called by wled main
void addToConfig(JsonObject& root); // Extends the settings/user module settings page to include the user module requirements. The settings are written from the wled core to the configuration file.
void appendConfigData(); // Adds extra info to the config page of weld
void appendConfigData(Print& dest); // Adds extra info to the config page of weld
bool readFromConfig(JsonObject& root); // Reads config values
void addToJsonInfo(JsonObject& root); // Adds user module info to the weld info page

Expand Down Expand Up @@ -756,33 +756,33 @@ void UsermodBME68X::addToConfig(JsonObject& root) {

/**
* @brief Called by WLED: Add dropdown and additional infos / structure
* @see Usermod::appendConfigData()
* @see UsermodManager::appendConfigData()
* @see Usermod::appendConfigData(Print& dest)
* @see UsermodManager::appendConfigData(Print& dest)
*/
void UsermodBME68X::appendConfigData() {
// snprintf_P(charbuffer, 127, PSTR("addInfo('%s:%s',1,'read interval [seconds]');"), UMOD_NAME, _nameInterval); oappend(charbuffer);
// snprintf_P(charbuffer, 127, PSTR("addInfo('%s:%s',1,'only if value changes');"), UMOD_NAME, _namePublishChange); oappend(charbuffer);
// snprintf_P(charbuffer, 127, PSTR("addInfo('%s:%s',1,'maximum age of a message in seconds');"), UMOD_NAME, _nameMaxAge); oappend(charbuffer);
// snprintf_P(charbuffer, 127, PSTR("addInfo('%s:%s',1,'Gas related values are only published after the gas sensor has been calibrated');"), UMOD_NAME, _namePubAfterCalib); oappend(charbuffer);
// snprintf_P(charbuffer, 127, PSTR("addInfo('%s:%s',1,'*) Set to minus to deactivate (all sensors)');"), UMOD_NAME, _nameTemp); oappend(charbuffer);
void UsermodBME68X::appendConfigData(Print& dest) {
// snprintf_P(charbuffer, 127, PSTR("addInfo('%s:%s',1,'read interval [seconds]');"), UMOD_NAME, _nameInterval); dest.print(charbuffer);
// snprintf_P(charbuffer, 127, PSTR("addInfo('%s:%s',1,'only if value changes');"), UMOD_NAME, _namePublishChange); dest.print(charbuffer);
// snprintf_P(charbuffer, 127, PSTR("addInfo('%s:%s',1,'maximum age of a message in seconds');"), UMOD_NAME, _nameMaxAge); dest.print(charbuffer);
// snprintf_P(charbuffer, 127, PSTR("addInfo('%s:%s',1,'Gas related values are only published after the gas sensor has been calibrated');"), UMOD_NAME, _namePubAfterCalib); dest.print(charbuffer);
// snprintf_P(charbuffer, 127, PSTR("addInfo('%s:%s',1,'*) Set to minus to deactivate (all sensors)');"), UMOD_NAME, _nameTemp); dest.print(charbuffer);

/* Dropdown for Celsius/Fahrenheit*/
oappend(SET_F("dd=addDropdown('"));
oappend(UMOD_NAME);
oappend(SET_F("','"));
oappend(_nameTempScale);
oappend(SET_F("');"));
oappend(SET_F("addOption(dd,'Celsius',0);"));
oappend(SET_F("addOption(dd,'Fahrenheit',1);"));
dest.print(F("dd=addDropdown('"));
dest.print(UMOD_NAME);
dest.print(F("','"));
dest.print(_nameTempScale);
dest.print(F("');"));
dest.print(F("addOption(dd,'Celsius',0);"));
dest.print(F("addOption(dd,'Fahrenheit',1);"));

/* i²C Address*/
oappend(SET_F("dd=addDropdown('"));
oappend(UMOD_NAME);
oappend(SET_F("','"));
oappend(_nameI2CAdr);
oappend(SET_F("');"));
oappend(SET_F("addOption(dd,'0x76',0x76);"));
oappend(SET_F("addOption(dd,'0x77',0x77);"));
dest.print(F("dd=addDropdown('"));
dest.print(UMOD_NAME);
dest.print(F("','"));
dest.print(_nameI2CAdr);
dest.print(F("');"));
dest.print(F("addOption(dd,'0x76',0x76);"));
dest.print(F("addOption(dd,'0x77',0x77);"));
}

/**
Expand Down
42 changes: 21 additions & 21 deletions usermods/Battery/usermod_v2_Battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,32 +475,32 @@ class UsermodBattery : public Usermod
DEBUG_PRINTLN(F("Battery config saved."));
}

void appendConfigData()
void appendConfigData(Print& dest)
{
// Total: 462 Bytes
oappend(SET_F("td=addDropdown('Battery','type');")); // 34 Bytes
oappend(SET_F("addOption(td,'Unkown','0');")); // 28 Bytes
oappend(SET_F("addOption(td,'LiPo','1');")); // 26 Bytes
oappend(SET_F("addOption(td,'LiOn','2');")); // 26 Bytes
oappend(SET_F("addInfo('Battery:type',1,'<small style=\"color:orange\">requires reboot</small>');")); // 81 Bytes
oappend(SET_F("addInfo('Battery:min-voltage',1,'v');")); // 38 Bytes
oappend(SET_F("addInfo('Battery:max-voltage',1,'v');")); // 38 Bytes
oappend(SET_F("addInfo('Battery:interval',1,'ms');")); // 36 Bytes
oappend(SET_F("addInfo('Battery:HA-discovery',1,'');")); // 38 Bytes
oappend(SET_F("addInfo('Battery:auto-off:threshold',1,'%');")); // 45 Bytes
oappend(SET_F("addInfo('Battery:indicator:threshold',1,'%');")); // 46 Bytes
oappend(SET_F("addInfo('Battery:indicator:duration',1,'s');")); // 45 Bytes
dest.print(F("td=addDropdown('Battery','type');")); // 34 Bytes
dest.print(F("addOption(td,'Unkown','0');")); // 28 Bytes
dest.print(F("addOption(td,'LiPo','1');")); // 26 Bytes
dest.print(F("addOption(td,'LiOn','2');")); // 26 Bytes
dest.print(F("addInfo('Battery:type',1,'<small style=\"color:orange\">requires reboot</small>');")); // 81 Bytes
dest.print(F("addInfo('Battery:min-voltage',1,'v');")); // 38 Bytes
dest.print(F("addInfo('Battery:max-voltage',1,'v');")); // 38 Bytes
dest.print(F("addInfo('Battery:interval',1,'ms');")); // 36 Bytes
dest.print(F("addInfo('Battery:HA-discovery',1,'');")); // 38 Bytes
dest.print(F("addInfo('Battery:auto-off:threshold',1,'%');")); // 45 Bytes
dest.print(F("addInfo('Battery:indicator:threshold',1,'%');")); // 46 Bytes
dest.print(F("addInfo('Battery:indicator:duration',1,'s');")); // 45 Bytes

// this option list would exeed the oappend() buffer
// this option list would exeed the dest.print() buffer
// a list of all presets to select one from
// oappend(SET_F("bd=addDropdown('Battery:low-power-indicator', 'preset');"));
// the loop generates: oappend(SET_F("addOption(bd, 'preset name', preset id);"));
// dest.print(F("bd=addDropdown('Battery:low-power-indicator', 'preset');"));
// the loop generates: dest.print(F("addOption(bd, 'preset name', preset id);"));
// for(int8_t i=1; i < 42; i++) {
// oappend(SET_F("addOption(bd, 'Preset#"));
// oappendi(i);
// oappend(SET_F("',"));
// oappendi(i);
// oappend(SET_F(");"));
// dest.print(F("addOption(bd, 'Preset#"));
// dest.print(i);
// dest.print(F("',"));
// dest.print(i);
// dest.print(F(");"));
// }
}

Expand Down
16 changes: 8 additions & 8 deletions usermods/EXAMPLE_v2/usermod_v2_example.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,17 @@ class MyExampleUsermod : public Usermod {


/*
* appendConfigData() is called when user enters usermod settings page
* appendConfigData(Print& dest) is called when user enters usermod settings page
* it may add additional metadata for certain entry fields (adding drop down is possible)
* be careful not to add too much as oappend() buffer is limited to 3k
* be careful not to add too much as dest.print() buffer is limited to 3k
*/
void appendConfigData() override
void appendConfigData(Print& dest) override
{
oappend(SET_F("addInfo('")); oappend(String(FPSTR(_name)).c_str()); oappend(SET_F(":great")); oappend(SET_F("',1,'<i>(this is a great config value)</i>');"));
oappend(SET_F("addInfo('")); oappend(String(FPSTR(_name)).c_str()); oappend(SET_F(":testString")); oappend(SET_F("',1,'enter any string you want');"));
oappend(SET_F("dd=addDropdown('")); oappend(String(FPSTR(_name)).c_str()); oappend(SET_F("','testInt');"));
oappend(SET_F("addOption(dd,'Nothing',0);"));
oappend(SET_F("addOption(dd,'Everything',42);"));
dest.print(F("addInfo('")); dest.print(String(FPSTR(_name)).c_str()); dest.print(F(":great")); dest.print(F("',1,'<i>(this is a great config value)</i>');"));
dest.print(F("addInfo('")); dest.print(String(FPSTR(_name)).c_str()); dest.print(F(":testString")); dest.print(F("',1,'enter any string you want');"));
dest.print(F("dd=addDropdown('")); dest.print(String(FPSTR(_name)).c_str()); dest.print(F("','testInt');"));
dest.print(F("addOption(dd,'Nothing',0);"));
dest.print(F("addOption(dd,'Everything',42);"));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ class InternalTemperatureUsermod : public Usermod
}

// Append useful info to the usermod settings gui
void appendConfigData()
void appendConfigData(Print& dest)
{
// Display 'ms' next to the 'Loop Interval' setting
oappend(SET_F("addInfo('Internal Temperature:Loop Interval', 1, 'ms');"));
dest.print(F("addInfo('Internal Temperature:Loop Interval', 1, 'ms');"));
// Display '°C' next to the 'Activation Threshold' setting
oappend(SET_F("addInfo('Internal Temperature:Activation Threshold', 1, '°C');"));
dest.print(F("addInfo('Internal Temperature:Activation Threshold', 1, '°C');"));
// Display '0 = Disabled' next to the 'Preset To Activate' setting
oappend(SET_F("addInfo('Internal Temperature:Preset To Activate', 1, '0 = unused');"));
dest.print(F("addInfo('Internal Temperature:Preset To Activate', 1, '0 = unused');"));
}

bool readFromConfig(JsonObject &root)
Expand Down
10 changes: 5 additions & 5 deletions usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class PIRsensorSwitch : public Usermod
/**
* provide UI information and allow extending UI options
*/
void appendConfigData() override;
void appendConfigData(Print& dest) override;

/**
* restore the changeable values
Expand Down Expand Up @@ -509,14 +509,14 @@ void PIRsensorSwitch::addToConfig(JsonObject &root)
DEBUG_PRINTLN(F("PIR config saved."));
}

void PIRsensorSwitch::appendConfigData()
void PIRsensorSwitch::appendConfigData(Print& dest)
{
oappend(SET_F("addInfo('PIRsensorSwitch:HA-discovery',1,'HA=Home Assistant');")); // 0 is field type, 1 is actual field
oappend(SET_F("addInfo('PIRsensorSwitch:override',1,'Cancel timer on change');")); // 0 is field type, 1 is actual field
dest.print(F("addInfo('PIRsensorSwitch:HA-discovery',1,'HA=Home Assistant');")); // 0 is field type, 1 is actual field
dest.print(F("addInfo('PIRsensorSwitch:override',1,'Cancel timer on change');")); // 0 is field type, 1 is actual field
for (int i = 0; i < PIR_SENSOR_MAX_SENSORS; i++) {
char str[128];
sprintf_P(str, PSTR("addInfo('PIRsensorSwitch:pin[]',%d,'','#%d');"), i, i);
oappend(str);
dest.print(str);
}
}

Expand Down
10 changes: 5 additions & 5 deletions usermods/ST7789_display/ST7789_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,11 @@ class St7789DisplayUsermod : public Usermod {
}


void appendConfigData() override {
oappend(SET_F("addInfo('ST7789:pin[]',0,'','SPI CS');"));
oappend(SET_F("addInfo('ST7789:pin[]',1,'','SPI DC');"));
oappend(SET_F("addInfo('ST7789:pin[]',2,'','SPI RST');"));
oappend(SET_F("addInfo('ST7789:pin[]',2,'','SPI BL');"));
void appendConfigData(Print& dest) override {
dest.print(F("addInfo('ST7789:pin[]',0,'','SPI CS');"));
dest.print(F("addInfo('ST7789:pin[]',1,'','SPI DC');"));
dest.print(F("addInfo('ST7789:pin[]',2,'','SPI RST');"));
dest.print(F("addInfo('ST7789:pin[]',2,'','SPI BL');"));
}

/*
Expand Down
12 changes: 6 additions & 6 deletions usermods/Temperature/usermod_temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class UsermodTemperature : public Usermod {
void addToConfig(JsonObject &root) override;
bool readFromConfig(JsonObject &root) override;

void appendConfigData() override;
void appendConfigData(Print& dest) override;
};

//Dallas sensor quick (& dirty) reading. Credit to - Author: Peter Scargill, August 17th, 2013
Expand Down Expand Up @@ -425,11 +425,11 @@ bool UsermodTemperature::readFromConfig(JsonObject &root) {
return !top[FPSTR(_domoticzIDX)].isNull();
}

void UsermodTemperature::appendConfigData() {
oappend(SET_F("addInfo('")); oappend(String(FPSTR(_name)).c_str()); oappend(SET_F(":")); oappend(String(FPSTR(_parasite)).c_str());
oappend(SET_F("',1,'<i>(if no Vcc connected)</i>');")); // 0 is field type, 1 is actual field
oappend(SET_F("addInfo('")); oappend(String(FPSTR(_name)).c_str()); oappend(SET_F(":")); oappend(String(FPSTR(_parasitePin)).c_str());
oappend(SET_F("',1,'<i>(for external MOSFET)</i>');")); // 0 is field type, 1 is actual field
void UsermodTemperature::appendConfigData(Print& dest) {
dest.print(F("addInfo('")); dest.print(String(FPSTR(_name)).c_str()); dest.print(F(":")); dest.print(String(FPSTR(_parasite)).c_str());
dest.print(F("',1,'<i>(if no Vcc connected)</i>');")); // 0 is field type, 1 is actual field
dest.print(F("addInfo('")); dest.print(String(FPSTR(_name)).c_str()); dest.print(F(":")); dest.print(String(FPSTR(_parasitePin)).c_str());
dest.print(F("',1,'<i>(for external MOSFET)</i>');")); // 0 is field type, 1 is actual field
}

float UsermodTemperature::getTemperature() {
Expand Down
72 changes: 36 additions & 36 deletions usermods/audioreactive/audio_reactive.h
Original file line number Diff line number Diff line change
Expand Up @@ -1888,54 +1888,54 @@ class AudioReactive : public Usermod {
void appendConfigData(Print& dest) override
{
#ifdef ARDUINO_ARCH_ESP32
dest.print(SET_F("dd=addDropdown('AudioReactive','digitalmic:type');"));
dest.print(F("dd=addDropdown('AudioReactive','digitalmic:type');"));
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
dest.print(SET_F("addOption(dd,'Generic Analog',0);"));
dest.print(F("addOption(dd,'Generic Analog',0);"));
#endif
dest.print(SET_F("addOption(dd,'Generic I2S',1);"));
dest.print(SET_F("addOption(dd,'ES7243',2);"));
dest.print(SET_F("addOption(dd,'SPH0654',3);"));
dest.print(SET_F("addOption(dd,'Generic I2S with Mclk',4);"));
dest.print(F("addOption(dd,'Generic I2S',1);"));
dest.print(F("addOption(dd,'ES7243',2);"));
dest.print(F("addOption(dd,'SPH0654',3);"));
dest.print(F("addOption(dd,'Generic I2S with Mclk',4);"));
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
dest.print(SET_F("addOption(dd,'Generic I2S PDM',5);"));
dest.print(F("addOption(dd,'Generic I2S PDM',5);"));
#endif
dest.print(SET_F("addOption(dd,'ES8388',6);"));
dest.print(F("addOption(dd,'ES8388',6);"));

dest.print(SET_F("dd=addDropdown('AudioReactive','config:AGC');"));
dest.print(SET_F("addOption(dd,'Off',0);"));
dest.print(SET_F("addOption(dd,'Normal',1);"));
dest.print(SET_F("addOption(dd,'Vivid',2);"));
dest.print(SET_F("addOption(dd,'Lazy',3);"));

dest.print(SET_F("dd=addDropdown('AudioReactive','dynamics:limiter');"));
dest.print(SET_F("addOption(dd,'Off',0);"));
dest.print(SET_F("addOption(dd,'On',1);"));
dest.print(SET_F("addInfo('AudioReactive:dynamics:limiter',0,' On ');")); // 0 is field type, 1 is actual field
dest.print(SET_F("addInfo('AudioReactive:dynamics:rise',1,'ms <i>(&#x266A; effects only)</i>');"));
dest.print(SET_F("addInfo('AudioReactive:dynamics:fall',1,'ms <i>(&#x266A; effects only)</i>');"));

dest.print(SET_F("dd=addDropdown('AudioReactive','frequency:scale');"));
dest.print(SET_F("addOption(dd,'None',0);"));
dest.print(SET_F("addOption(dd,'Linear (Amplitude)',2);"));
dest.print(SET_F("addOption(dd,'Square Root (Energy)',3);"));
dest.print(SET_F("addOption(dd,'Logarithmic (Loudness)',1);"));
dest.print(F("dd=addDropdown('AudioReactive','config:AGC');"));
dest.print(F("addOption(dd,'Off',0);"));
dest.print(F("addOption(dd,'Normal',1);"));
dest.print(F("addOption(dd,'Vivid',2);"));
dest.print(F("addOption(dd,'Lazy',3);"));

dest.print(F("dd=addDropdown('AudioReactive','dynamics:limiter');"));
dest.print(F("addOption(dd,'Off',0);"));
dest.print(F("addOption(dd,'On',1);"));
dest.print(F("addInfo('AudioReactive:dynamics:limiter',0,' On ');")); // 0 is field type, 1 is actual field
dest.print(F("addInfo('AudioReactive:dynamics:rise',1,'ms <i>(&#x266A; effects only)</i>');"));
dest.print(F("addInfo('AudioReactive:dynamics:fall',1,'ms <i>(&#x266A; effects only)</i>');"));

dest.print(F("dd=addDropdown('AudioReactive','frequency:scale');"));
dest.print(F("addOption(dd,'None',0);"));
dest.print(F("addOption(dd,'Linear (Amplitude)',2);"));
dest.print(F("addOption(dd,'Square Root (Energy)',3);"));
dest.print(F("addOption(dd,'Logarithmic (Loudness)',1);"));
#endif

dest.print(SET_F("dd=addDropdown('AudioReactive','sync:mode');"));
dest.print(SET_F("addOption(dd,'Off',0);"));
dest.print(F("dd=addDropdown('AudioReactive','sync:mode');"));
dest.print(F("addOption(dd,'Off',0);"));
#ifdef ARDUINO_ARCH_ESP32
dest.print(SET_F("addOption(dd,'Send',1);"));
dest.print(F("addOption(dd,'Send',1);"));
#endif
dest.print(SET_F("addOption(dd,'Receive',2);"));
dest.print(F("addOption(dd,'Receive',2);"));
#ifdef ARDUINO_ARCH_ESP32
dest.print(SET_F("addInfo('AudioReactive:digitalmic:type',1,'<i>requires reboot!</i>');")); // 0 is field type, 1 is actual field
dest.print(SET_F("addInfo('AudioReactive:digitalmic:pin[]',0,'<i>sd/data/dout</i>','I2S SD');"));
dest.print(SET_F("addInfo('AudioReactive:digitalmic:pin[]',1,'<i>ws/clk/lrck</i>','I2S WS');"));
dest.print(SET_F("addInfo('AudioReactive:digitalmic:pin[]',2,'<i>sck/bclk</i>','I2S SCK');"));
dest.print(F("addInfo('AudioReactive:digitalmic:type',1,'<i>requires reboot!</i>');")); // 0 is field type, 1 is actual field
dest.print(F("addInfo('AudioReactive:digitalmic:pin[]',0,'<i>sd/data/dout</i>','I2S SD');"));
dest.print(F("addInfo('AudioReactive:digitalmic:pin[]',1,'<i>ws/clk/lrck</i>','I2S WS');"));
dest.print(F("addInfo('AudioReactive:digitalmic:pin[]',2,'<i>sck/bclk</i>','I2S SCK');"));
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
dest.print(SET_F("addInfo('AudioReactive:digitalmic:pin[]',3,'<i>only use -1, 0, 1 or 3</i>','I2S MCLK');"));
dest.print(F("addInfo('AudioReactive:digitalmic:pin[]',3,'<i>only use -1, 0, 1 or 3</i>','I2S MCLK');"));
#else
dest.print(SET_F("addInfo('AudioReactive:digitalmic:pin[]',3,'<i>master clock</i>','I2S MCLK');"));
dest.print(F("addInfo('AudioReactive:digitalmic:pin[]',3,'<i>master clock</i>','I2S MCLK');"));
#endif
#endif
}
Expand Down
Loading

0 comments on commit 89dcfc5

Please sign in to comment.