Reduction of buffer size.

Caching tweak.
This commit is contained in:
Blaz Kristan 2021-03-20 23:04:24 +01:00
parent adfb24ce02
commit be2ffc31b2
7 changed files with 1744 additions and 1742 deletions

View File

@ -60,7 +60,7 @@
/* How many color transitions can run at once */ /* How many color transitions can run at once */
#define MAX_NUM_TRANSITIONS 8 #define MAX_NUM_TRANSITIONS 8
/* How much data bytes all segments combined may allocate */ /* How much data bytes all segments combined may allocate */
#define MAX_SEGMENT_DATA 4096 #define MAX_SEGMENT_DATA 3072
#else #else
#define MAX_NUM_SEGMENTS 18 #define MAX_NUM_SEGMENTS 18
#define MAX_NUM_TRANSITIONS 18 #define MAX_NUM_TRANSITIONS 18

View File

@ -452,10 +452,10 @@ img {
width: 24px; width: 24px;
position: relative; position: relative;
display: inline-block; display: inline-block;
border-radius: 5px; border-radius: 10px;
background: var(--c-3); background: var(--c-3);
color: white; color: var(--c-f);
padding: 2px 5px; padding: 4px 4px 2px;
font-size: 14px; font-size: 14px;
right: 5px; right: 5px;
transition: visibility 0.25s ease, opacity 0.25s ease; transition: visibility 0.25s ease, opacity 0.25s ease;

View File

@ -1018,10 +1018,6 @@ function requestJson(command, rinfo = true, verbose = true, callback = null)
{ {
d.getElementById('connind').style.backgroundColor = "#a90"; d.getElementById('connind').style.backgroundColor = "#a90";
lastUpdate = new Date(); lastUpdate = new Date();
/*
if (refreshTimer) clearTimeout(refreshTimer);
refreshTimer = setTimeout(function(){requestJson({'v':true},false);},15000);
*/
if (!jsonTimeout) jsonTimeout = setTimeout(showErrorToast, 3000); if (!jsonTimeout) jsonTimeout = setTimeout(showErrorToast, 3000);
var req = null; var req = null;
var e1 = d.getElementById('fxlist'); var e1 = d.getElementById('fxlist');
@ -1058,7 +1054,7 @@ function requestJson(command, rinfo = true, verbose = true, callback = null)
if (callback) callback(); if (callback) callback();
return; return;
} }
var s = json.state; var s = json.state ? json.state : json;
if (!command || rinfo) { if (!command || rinfo) {
if (!rinfo) { if (!rinfo) {
pmt = json.info.fs.pmt; pmt = json.info.fs.pmt;
@ -1121,7 +1117,7 @@ function togglePower()
isOn = !isOn; isOn = !isOn;
var obj = {"on": isOn}; var obj = {"on": isOn};
obj.transition = parseInt(d.getElementById('cyctt').value*10); obj.transition = parseInt(d.getElementById('cyctt').value*10);
requestJson(obj); requestJson(obj, false);
} }
function toggleNl() function toggleNl()
@ -1130,7 +1126,7 @@ function toggleNl()
if (nlA) showToast(`Timer active. Your light will turn ${nlTar > 0 ? "on":"off"} ${nlFade ? "over":"after"} ${nlDur} minutes.`); if (nlA) showToast(`Timer active. Your light will turn ${nlTar > 0 ? "on":"off"} ${nlFade ? "over":"after"} ${nlDur} minutes.`);
else showToast('Timer deactivated.'); else showToast('Timer deactivated.');
var obj = {"nl": {"on": nlA}}; var obj = {"nl": {"on": nlA}};
requestJson(obj); requestJson(obj, false);
} }
function toggleSync() function toggleSync()
@ -1140,7 +1136,7 @@ function toggleSync()
else showToast('This light and other lights in the network will no longer sync.'); else showToast('This light and other lights in the network will no longer sync.');
var obj = {"udpn": {"send": syncSend}}; var obj = {"udpn": {"send": syncSend}};
if (syncTglRecv) obj.udpn.recv = syncSend; if (syncTglRecv) obj.udpn.recv = syncSend;
requestJson(obj); requestJson(obj, false);
} }
function toggleLiveview() function toggleLiveview()
@ -1270,7 +1266,7 @@ function selSegEx(s)
{ {
var obj = {"seg":[]}; var obj = {"seg":[]};
for (let i=0; i<=lSeg; i++) obj.seg.push({"sel":(i==s)?true:false}); for (let i=0; i<=lSeg; i++) obj.seg.push({"sel":(i==s)?true:false});
requestJson(obj); requestJson(obj, false);
} }
function selSeg(s) function selSeg(s)
@ -1293,7 +1289,7 @@ function setSeg(s)
obj.seg.grp = grp; obj.seg.grp = grp;
obj.seg.spc = spc; obj.seg.spc = spc;
} }
requestJson(obj); requestJson(obj, false);
} }
function delSeg(s) function delSeg(s)
@ -1325,13 +1321,13 @@ function setMi(s)
function setSegPwr(s) function setSegPwr(s)
{ {
var obj = {"seg": {"id": s, "on": !powered[s]}}; var obj = {"seg": {"id": s, "on": !powered[s]}};
requestJson(obj); requestJson(obj, false);
} }
function setSegBri(s) function setSegBri(s)
{ {
var obj = {"seg": {"id": s, "bri": parseInt(d.getElementById(`seg${s}bri`).value)}}; var obj = {"seg": {"id": s, "bri": parseInt(d.getElementById(`seg${s}bri`).value)}};
requestJson(obj); requestJson(obj, false);
} }
function setX(ind = null) function setX(ind = null)
@ -1362,14 +1358,14 @@ function setPalette(paletteId = null)
d.querySelector(`#selectPalette .lstI[data-id="${paletteId}"]`).classList.add('selected'); d.querySelector(`#selectPalette .lstI[data-id="${paletteId}"]`).classList.add('selected');
var obj = {"seg": {"pal": paletteId}}; var obj = {"seg": {"pal": paletteId}};
requestJson(obj); requestJson(obj, false);
} }
function setBri() function setBri()
{ {
var obj = {"bri": parseInt(d.getElementById('sliderBri').value)}; var obj = {"bri": parseInt(d.getElementById('sliderBri').value)};
obj.transition = parseInt(d.getElementById('cyctt').value*10); obj.transition = parseInt(d.getElementById('cyctt').value*10);
requestJson(obj); requestJson(obj, false);
} }
function setSpeed() function setSpeed()
@ -1387,7 +1383,7 @@ function setIntensity()
function setLor(i) function setLor(i)
{ {
var obj = {"lor": i}; var obj = {"lor": i};
requestJson(obj); requestJson(obj, false);
} }
function toggleCY() function toggleCY()
@ -1399,14 +1395,14 @@ function toggleCY()
obj.transition = parseInt(d.getElementById('cyctt').value*10); obj.transition = parseInt(d.getElementById('cyctt').value*10);
} }
requestJson(obj); requestJson(obj, false);
} }
function setPreset(i) function setPreset(i)
{ {
var obj = {"ps": i}; var obj = {"ps": i};
showToast("Loading preset " + pName(i) +" (" + i + ")"); showToast("Loading preset " + pName(i) +" (" + i + ")");
requestJson(obj); requestJson(obj, false);
} }
function saveP(i) function saveP(i)
@ -1443,7 +1439,7 @@ function saveP(i)
if (pQN.length > 0) obj.ql = pQN; if (pQN.length > 0) obj.ql = pQN;
showToast("Saving " + pN +" (" + pI + ")"); showToast("Saving " + pN +" (" + pI + ")");
requestJson(obj); requestJson(obj, false);
if (obj.o) { if (obj.o) {
pJson[pI] = obj; pJson[pI] = obj;
delete pJson[pI].psave; delete pJson[pI].psave;
@ -1462,7 +1458,7 @@ function saveP(i)
function delP(i) function delP(i)
{ {
var obj = {"pdel": i}; var obj = {"pdel": i};
requestJson(obj); requestJson(obj, false);
delete pJson[i]; delete pJson[i];
populatePresets(); populatePresets();
} }
@ -1567,7 +1563,7 @@ function setColor(sr)
updateHex(); updateHex();
updateRgb(); updateRgb();
obj.transition = parseInt(d.getElementById('cyctt').value*10); obj.transition = parseInt(d.getElementById('cyctt').value*10);
requestJson(obj); requestJson(obj, false);
} }
var hc = 0; var hc = 0;
@ -1602,7 +1598,7 @@ function rSegs()
bt.innerHTML = "Reset segments"; bt.innerHTML = "Reset segments";
var obj = {"seg":[{"start":0,"stop":ledCount,"sel":true}]}; var obj = {"seg":[{"start":0,"stop":ledCount,"sel":true}]};
for (let i=1; i<=lSeg; i++) obj.seg.push({"stop":0}); for (let i=1; i<=lSeg; i++) obj.seg.push({"stop":0});
requestJson(obj); requestJson(obj, false);
} }
function loadPalettesData() function loadPalettesData()

File diff suppressed because it is too large Load Diff

View File

@ -332,6 +332,8 @@ void WLED::setup()
errorFlag = ERR_FS_BEGIN; errorFlag = ERR_FS_BEGIN;
} else deEEP(); } else deEEP();
updateFSInfo(); updateFSInfo();
DEBUG_PRINTLN(F("Reading config"));
deserializeConfig(); deserializeConfig();
#if STATUSLED #if STATUSLED
@ -348,7 +350,10 @@ void WLED::setup()
//DEBUG_PRINTLN(F("Load EEPROM")); //DEBUG_PRINTLN(F("Load EEPROM"));
//loadSettingsFromEEPROM(); //loadSettingsFromEEPROM();
DEBUG_PRINTLN(F("Initializing strip"));
beginStrip(); beginStrip();
DEBUG_PRINTLN(F("Usermods setup"));
userSetup(); userSetup();
usermods.setup(); usermods.setup();
if (strcmp(clientSSID, DEFAULT_CLIENT_SSID) == 0) if (strcmp(clientSSID, DEFAULT_CLIENT_SSID) == 0)

View File

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

View File

@ -247,7 +247,7 @@ bool handleIfNoneMatchCacheHeader(AsyncWebServerRequest* request)
void setStaticContentCacheHeaders(AsyncWebServerResponse *response) void setStaticContentCacheHeaders(AsyncWebServerResponse *response)
{ {
response->addHeader(F("Cache-Control"),"max-age=86400"); // max 1 day for caching response->addHeader(F("Cache-Control"),"max-age=2592000");
response->addHeader(F("ETag"), String(VERSION)); response->addHeader(F("ETag"), String(VERSION));
} }
@ -260,8 +260,9 @@ void serveIndex(AsyncWebServerRequest* request)
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", PAGE_index, PAGE_index_L); AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", PAGE_index, PAGE_index_L);
response->addHeader(F("Content-Encoding"),"gzip"); response->addHeader(F("Content-Encoding"),"gzip");
#ifndef WLED_DEBUG
setStaticContentCacheHeaders(response); setStaticContentCacheHeaders(response);
#endif
request->send(response); request->send(response);
} }