Generate presets !
Fix 1d/2d default in customeffect, games and weather index.htm: add buttons and text area for genPresets index.js: add genPresets, uploadFileWithText and savePresetsGen fx,cpp: set fire 2012 default palette 0 (fire colors) Bonus: battery USERMOD_BATTERY_MEASUREMENT_PIN default -1
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc.html
|
||||
#ifndef USERMOD_BATTERY_MEASUREMENT_PIN
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#define USERMOD_BATTERY_MEASUREMENT_PIN 35
|
||||
#define USERMOD_BATTERY_MEASUREMENT_PIN -1 //WLEDMM instead of 35
|
||||
#else //ESP8266 boards
|
||||
#define USERMOD_BATTERY_MEASUREMENT_PIN A0
|
||||
#endif
|
||||
|
||||
@@ -99,7 +99,7 @@ uint16_t mode_customEffect(void) {
|
||||
return FRAMETIME;
|
||||
}
|
||||
|
||||
static const char _data_FX_MODE_CUSTOMEFFECT[] PROGMEM = "⚙️ Custom Effect@Speed,Intensity,Custom 1, Custom 2, Custom 3;!;!;1d;mp12=0";
|
||||
static const char _data_FX_MODE_CUSTOMEFFECT[] PROGMEM = "⚙️ Custom Effect@Speed,Intensity,Custom 1, Custom 2, Custom 3;!;!;1;mp12=0";
|
||||
|
||||
class CustomEffectsUserMod : public Usermod {
|
||||
private:
|
||||
|
||||
@@ -172,7 +172,7 @@ uint16_t mode_pongGame(void) {
|
||||
return FRAMETIME;
|
||||
}
|
||||
|
||||
static const char _data_FX_MODE_PONGGAME[] PROGMEM = "🎮 Pong@!;!;!;2d";
|
||||
static const char _data_FX_MODE_PONGGAME[] PROGMEM = "🎮 Pong@!;!;!;2";
|
||||
|
||||
//https://howtomechatronics.com/tutorials/arduino/arduino-and-mpu6050-accelerometer-and-gyroscope-tutorial/
|
||||
|
||||
@@ -318,7 +318,7 @@ uint16_t mode_3DIMUCube(void) {
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_3DIMUCube[] PROGMEM = "🎮 3DIMUCube@,Perspective;!;!;,pal=1,2d"; //random cycle
|
||||
static const char _data_FX_MODE_3DIMUCube[] PROGMEM = "🎮 3DIMUCube@,Perspective;!;!;2;pal=1"; //random cycle
|
||||
|
||||
class GamesUsermod : public Usermod {
|
||||
private:
|
||||
|
||||
@@ -14,7 +14,7 @@ uint16_t mode_2DWeather(void) {
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_2DWEATHER[] PROGMEM = "Weather@;!;!;pal=54,2d"; //temperature palette
|
||||
static const char _data_FX_MODE_2DWEATHER[] PROGMEM = "Weather@;!;!;2;pal=54"; //temperature palette
|
||||
```
|
||||
* then activated in the usermod setup function
|
||||
```c++
|
||||
|
||||
@@ -94,7 +94,7 @@ uint16_t mode_2DWeather(void) {
|
||||
return FRAMETIME;
|
||||
}
|
||||
|
||||
static const char _data_FX_MODE_2DWEATHER[] PROGMEM = "Weather@;!;!;pal=54,2d"; //temperature palette
|
||||
static const char _data_FX_MODE_2DWEATHER[] PROGMEM = "Weather@;!;!;2;pal=54"; //temperature palette
|
||||
|
||||
//utility function, move somewhere else???
|
||||
void epochToString(time_t time, char *timeString) {
|
||||
|
||||
@@ -2017,7 +2017,7 @@ uint16_t mode_fire_2012()
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate;;!;1.5d;sx=120,ix=64,m12=1"; // bars WLEDMM 1.5d
|
||||
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate;;!;1.5d;pal=0,sx=120,ix=64,m12=1"; // bars WLEDMM 1.5d, pal = 0
|
||||
|
||||
|
||||
// ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
|
||||
|
||||
@@ -353,6 +353,9 @@
|
||||
<button class="btn infobtn" onclick="toggleNodes()">Instance List</button>
|
||||
<button class="btn infobtn" onclick="window.open('/update','_self');">Update WLED</button>
|
||||
<button class="btn infobtn" id="resetbtn" onclick="cnfReset()">Reboot WLED</button>
|
||||
<button class="btn infobtn" id="genPresets" onclick="genPresets()">Generate presets</button>
|
||||
<button class="btn infobtn" id="savePresetsGen" onclick="savePresetsGen()" hidden="true">Save generated presets</button>
|
||||
<textarea id="presetsGen" hidden="true"></textarea><br>
|
||||
</div>
|
||||
<br>
|
||||
<span class="h">Made with <span id="heart">❤︎</span> by Aircoookie and the <a href="https://wled.discourse.group/" target="_blank">WLED community</a></span>
|
||||
|
||||
@@ -2548,6 +2548,113 @@ function rSegs()
|
||||
requestJson(obj);
|
||||
}
|
||||
|
||||
//WLEDMM generate presets.json file
|
||||
function genPresets()
|
||||
{
|
||||
var result = '{"0":{}';
|
||||
|
||||
var effects = eJson;
|
||||
var seq = 30;
|
||||
var playlistPS = JSON.parse("{}");
|
||||
var playlistSep = JSON.parse("{}");
|
||||
var playlistDur = JSON.parse("{}");
|
||||
var playlistTrans = JSON.parse("{}");
|
||||
function addToPlaylist(m) {
|
||||
if (!playlistPS[m]) playlistPS[m] = "";
|
||||
if (!playlistDur[m]) playlistDur[m] = "";
|
||||
if (!playlistTrans[m]) playlistTrans[m] = "";
|
||||
if (!playlistSep[m]) playlistSep[m] = "";
|
||||
playlistPS[m] += playlistSep[m] + `${seq}`;
|
||||
playlistDur[m] += playlistSep[m] + "100";
|
||||
playlistTrans[m] += playlistSep[m] + "7";
|
||||
playlistSep[m] = ",";
|
||||
}
|
||||
for (let ef of effects) {
|
||||
let id = ef.id;
|
||||
let nm = ef.name+" ";
|
||||
let fd = "";
|
||||
if (ef.name.indexOf("RSVD") < 0) {
|
||||
if (Array.isArray(fxdata) && fxdata.length>id) {
|
||||
fd = fxdata[id];
|
||||
let eP = (fd == '')?[]:fd.split(";"); // effect parameters
|
||||
let m = (eP.length<4 || eP[3]==='')?'1':eP[3]; // flags
|
||||
// console.log(ef, eP);
|
||||
//transform key values in json format
|
||||
var defaultString = "";
|
||||
if (eP.length>4) {
|
||||
let defaults = (eP[4] == '')?[]:eP[4].split(",");
|
||||
for (let i=0; i<defaults.length;i++) {
|
||||
let keyValue = (defaults[i] == '')?[]:defaults[i].split("=");
|
||||
defaultString += `,"${keyValue[0]}":${keyValue[1]}`;
|
||||
}
|
||||
}
|
||||
if (!defaultString.includes("sx")) defaultString += ',"sx":128'; //Speed
|
||||
if (!defaultString.includes("ix")) defaultString += ',"ix":128'; //Intensity
|
||||
if (!defaultString.includes("c1")) defaultString += ',"c1":128'; //Custom 1
|
||||
if (!defaultString.includes("c2")) defaultString += ',"c2":128'; //Custom 2
|
||||
if (!defaultString.includes("c3")) defaultString += ',"c3":16'; //Custom 3
|
||||
if (!defaultString.includes("o1")) defaultString += ',"o1":0'; //Check 1
|
||||
if (!defaultString.includes("o2")) defaultString += ',"o2":0'; //Check 2
|
||||
if (!defaultString.includes("o3")) defaultString += ',"o3":0'; //Check 3
|
||||
if (!defaultString.includes("pal")) defaultString += ',"pal":1'; //Random palette
|
||||
if (!defaultString.includes("m12")) {
|
||||
if (m.includes("1") && !m.includes("1.5")) defaultString += ',"rev":true,"mi":true,"rY":true,"mY":true,"m12":2'; //Arc expansion
|
||||
else defaultString += ',"rev":false,"mi":false,"rY":false,"mY":false,"m12":0'; //pixels expansion
|
||||
}
|
||||
result += `\n,"${seq}":{"n":"${ef.name}","mainseg":0,"seg":[{"id":0,"fx":${id}${defaultString}}]}`; //,"ql":"${seq}"
|
||||
addToPlaylist(m);
|
||||
addToPlaylist("All");
|
||||
if (m.includes("1")) addToPlaylist("All1");
|
||||
if (m.includes("2")) addToPlaylist("All2");
|
||||
seq++;
|
||||
} //fxData is array
|
||||
} //not RSVD
|
||||
} //all effects
|
||||
|
||||
seq=10; //Playlist start here
|
||||
// console.log(playlistPS, playlistDur, playlistTrans);
|
||||
for (const m in playlistPS) {
|
||||
let playListString = `\n,"${seq}":{"n":"${m}D Playlist","ql":"${seq}","on":true,"playlist":{"ps":[${playlistPS[m]}],"dur":[${playlistDur[m]}],"transition":[${playlistTrans[m]}],"repeat":0,"end":0,"r":1}}`;
|
||||
// console.log(playListString);
|
||||
result += playListString;
|
||||
seq++;
|
||||
}
|
||||
|
||||
result += "}";
|
||||
|
||||
//assign result and show text and save button
|
||||
gId("genPresets").hidden = true;
|
||||
gId("savePresetsGen").hidden = false;
|
||||
gId("presetsGen").hidden = false;
|
||||
gId("presetsGen").value = result;
|
||||
// console.log(result);
|
||||
|
||||
}
|
||||
|
||||
//WLEDMM: utility function to save file to FS
|
||||
function uploadFileWithText(name, text)
|
||||
{
|
||||
var req = new XMLHttpRequest();
|
||||
req.addEventListener('load', function(){showToast(this.responseText,this.status >= 400)});
|
||||
req.addEventListener('error', function(e){showToast(e.stack,true);});
|
||||
req.open("POST", "/upload");
|
||||
var formData = new FormData();
|
||||
|
||||
var blob = new Blob([text], {type : 'application/text'});
|
||||
var fileOfBlob = new File([blob], name);
|
||||
formData.append("upload", fileOfBlob);
|
||||
|
||||
req.send(formData);
|
||||
}
|
||||
|
||||
//WLEDMM: save the presets.json to FS
|
||||
function savePresetsGen()
|
||||
{
|
||||
if (!confirm('Are you sure to (over)write presets.json?')) return;
|
||||
|
||||
uploadFileWithText("/presets.json", gId("presetsGen").value);
|
||||
}
|
||||
|
||||
function loadPalettesData(callback = null)
|
||||
{
|
||||
if (palettesData) return;
|
||||
|
||||
4049
wled00/html_ui.h
4049
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user