FQ quota and info
This commit is contained in:
parent
606cd18dc4
commit
d2ffb3ca9d
@ -2732,7 +2732,7 @@ uint16_t WS2812FX::candle(bool multi)
|
|||||||
|
|
||||||
//max. flicker range controlled by intensity
|
//max. flicker range controlled by intensity
|
||||||
uint8_t valrange = SEGMENT.intensity;
|
uint8_t valrange = SEGMENT.intensity;
|
||||||
uint8_t rndval = valrange >> 1;
|
uint8_t rndval = valrange >> 1; //max 127
|
||||||
|
|
||||||
//step (how much to move closer to target per frame) coarsely set by speed
|
//step (how much to move closer to target per frame) coarsely set by speed
|
||||||
uint8_t speedFactor = 4;
|
uint8_t speedFactor = 4;
|
||||||
@ -2769,9 +2769,9 @@ uint16_t WS2812FX::candle(bool multi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newTarget) {
|
if (newTarget) {
|
||||||
s_target = random8(rndval) + random8(rndval);
|
s_target = random8(rndval) + random8(rndval); //between 0 and rndval*2 -2 = 252
|
||||||
if (s_target < (rndval >> 1)) s_target = (rndval >> 1) + random8(rndval);
|
if (s_target < (rndval >> 1)) s_target = (rndval >> 1) + random8(rndval);
|
||||||
uint8_t offset = (255 - valrange) >> 1;
|
uint8_t offset = (255 - valrange);
|
||||||
s_target += offset;
|
s_target += offset;
|
||||||
|
|
||||||
uint8_t dif = (s_target > s) ? s_target - s : s - s_target;
|
uint8_t dif = (s_target > s) ? s_target - s : s - s_target;
|
||||||
|
@ -24,15 +24,16 @@ void handleDDPPacket(e131_packet_t* p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t offsetLeds = htonl(p->channelOffset) /3;
|
uint32_t start = htonl(p->channelOffset) /3;
|
||||||
uint16_t packetLeds = htons(p->dataLen) /3;
|
start += DMXAddress /3;
|
||||||
|
uint16_t stop = start + htons(p->dataLen) /3;
|
||||||
uint8_t* data = p->data;
|
uint8_t* data = p->data;
|
||||||
uint16_t c = 0;
|
uint16_t c = 0;
|
||||||
if (p->flags & DDP_TIMECODE_FLAG) c = 4; //packet has timecode flag, we do not support it, but data starts 4 bytes later
|
if (p->flags & DDP_TIMECODE_FLAG) c = 4; //packet has timecode flag, we do not support it, but data starts 4 bytes later
|
||||||
|
|
||||||
realtimeLock(realtimeTimeoutMs, REALTIME_MODE_DDP);
|
realtimeLock(realtimeTimeoutMs, REALTIME_MODE_DDP);
|
||||||
|
|
||||||
for (uint16_t i = offsetLeds; i < offsetLeds + packetLeds; i++) {
|
for (uint16_t i = start; i < stop; i++) {
|
||||||
setRealtimePixel(i, data[c++], data[c++], data[c++], 0);
|
setRealtimePixel(i, data[c++], data[c++], data[c++], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ bool writeObjectToFileUsingId(const char* file, uint16_t id, JsonDocument* conte
|
|||||||
bool writeObjectToFile(const char* file, const char* key, JsonDocument* content);
|
bool writeObjectToFile(const char* file, const char* key, JsonDocument* content);
|
||||||
bool readObjectFromFileUsingId(const char* file, uint16_t id, JsonDocument* dest);
|
bool readObjectFromFileUsingId(const char* file, uint16_t id, JsonDocument* dest);
|
||||||
bool readObjectFromFile(const char* file, const char* key, JsonDocument* dest);
|
bool readObjectFromFile(const char* file, const char* key, JsonDocument* dest);
|
||||||
|
void updateFSInfo();
|
||||||
|
|
||||||
//hue.cpp
|
//hue.cpp
|
||||||
void handleHue();
|
void handleHue();
|
||||||
|
@ -6,8 +6,15 @@
|
|||||||
|
|
||||||
#ifndef WLED_DISABLE_FILESYSTEM
|
#ifndef WLED_DISABLE_FILESYSTEM
|
||||||
|
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
#include "esp_spiffs.h" //FS info bare IDF function until FS wrapper is available for ESP32
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FS_BUFSIZE 256
|
#define FS_BUFSIZE 256
|
||||||
|
|
||||||
|
//allow presets to be added until this percentage of FS space is used
|
||||||
|
#define FS_QUOTA 75
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structural requirements for files managed by writeObjectToFile() and readObjectFromFile() utilities:
|
* Structural requirements for files managed by writeObjectToFile() and readObjectFromFile() utilities:
|
||||||
* 1. File must be a string representation of a valid JSON object
|
* 1. File must be a string representation of a valid JSON object
|
||||||
@ -172,6 +179,14 @@ bool appendObjectToFile(File f, const char* key, JsonDocument* content, uint32_t
|
|||||||
DEBUGFS_PRINTF("Inserted, took %d ms (total %d)", millis() - s1, millis() - s);
|
DEBUGFS_PRINTF("Inserted, took %d ms (total %d)", millis() - s1, millis() - s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//not enough space, append at end
|
||||||
|
|
||||||
|
if ((fsBytesUsed*100)/fsBytesTotal > FS_QUOTA) { //permitted space for presets exceeded
|
||||||
|
errorFlag = ERR_FS_QUOTA;
|
||||||
|
f.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//check if last character in file is '}' (typical)
|
//check if last character in file is '}' (typical)
|
||||||
f.seek(1, SeekEnd);
|
f.seek(1, SeekEnd);
|
||||||
@ -203,13 +218,14 @@ bool appendObjectToFile(File f, const char* key, JsonDocument* content, uint32_t
|
|||||||
|
|
||||||
f.close();
|
f.close();
|
||||||
DEBUGFS_PRINTF("Appended, took %d ms (total %d)", millis() - s1, millis() - s);
|
DEBUGFS_PRINTF("Appended, took %d ms (total %d)", millis() - s1, millis() - s);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool writeObjectToFileUsingId(const char* file, uint16_t id, JsonDocument* content)
|
bool writeObjectToFileUsingId(const char* file, uint16_t id, JsonDocument* content)
|
||||||
{
|
{
|
||||||
char objKey[10];
|
char objKey[10];
|
||||||
sprintf(objKey, "\"%d\":", id);
|
sprintf(objKey, "\"%d\":", id);
|
||||||
writeObjectToFile(file, objKey, content);
|
return writeObjectToFile(file, objKey, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool writeObjectToFile(const char* file, const char* key, JsonDocument* content)
|
bool writeObjectToFile(const char* file, const char* key, JsonDocument* content)
|
||||||
@ -266,7 +282,7 @@ bool readObjectFromFileUsingId(const char* file, uint16_t id, JsonDocument* dest
|
|||||||
{
|
{
|
||||||
char objKey[10];
|
char objKey[10];
|
||||||
sprintf(objKey, "\"%d\":", id);
|
sprintf(objKey, "\"%d\":", id);
|
||||||
readObjectFromFile(file, objKey, dest);
|
return readObjectFromFile(file, objKey, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readObjectFromFile(const char* file, const char* key, JsonDocument* dest)
|
bool readObjectFromFile(const char* file, const char* key, JsonDocument* dest)
|
||||||
@ -291,6 +307,17 @@ bool readObjectFromFile(const char* file, const char* key, JsonDocument* dest)
|
|||||||
DEBUGFS_PRINTF("Read, took %d ms\n", millis() - s);
|
DEBUGFS_PRINTF("Read, took %d ms\n", millis() - s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateFSInfo() {
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
esp_spiffs_info(nullptr, &fsBytesTotal, &fsBytesUsed);
|
||||||
|
#else
|
||||||
|
FSInfo fsi;
|
||||||
|
WLED_FS.info(fsi);
|
||||||
|
fsBytesUsed = fsi.usedBytes;
|
||||||
|
fsBytesTotal = fsi.totalBytes;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined WLED_DISABLE_FILESYSTEM && defined WLED_ENABLE_FS_SERVING
|
#if !defined WLED_DISABLE_FILESYSTEM && defined WLED_ENABLE_FS_SERVING
|
||||||
@ -316,6 +343,7 @@ String getContentType(AsyncWebServerRequest* request, String filename){
|
|||||||
bool handleFileRead(AsyncWebServerRequest* request, String path){
|
bool handleFileRead(AsyncWebServerRequest* request, String path){
|
||||||
DEBUG_PRINTLN("FileRead: " + path);
|
DEBUG_PRINTLN("FileRead: " + path);
|
||||||
if(path.endsWith("/")) path += "index.htm";
|
if(path.endsWith("/")) path += "index.htm";
|
||||||
|
if(path.indexOf("sec") > -1) return false;
|
||||||
String contentType = getContentType(request, path);
|
String contentType = getContentType(request, path);
|
||||||
/*String pathWithGz = path + ".gz";
|
/*String pathWithGz = path + ".gz";
|
||||||
if(WLED_FS.exists(pathWithGz)){
|
if(WLED_FS.exists(pathWithGz)){
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#include "wled.h"
|
#include "wled.h"
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
|
||||||
#include "esp_spiffs.h" //FS info bare IDF function until FS wrapper is available for ESP32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* JSON API (De)serialization
|
* JSON API (De)serialization
|
||||||
*/
|
*/
|
||||||
@ -152,14 +148,6 @@ bool deserializeState(JsonObject root)
|
|||||||
strip.applyToAllSelected = false;
|
strip.applyToAllSelected = false;
|
||||||
bool stateResponse = root[F("v")] | false;
|
bool stateResponse = root[F("v")] | false;
|
||||||
|
|
||||||
//HTTP API commands
|
|
||||||
const char* httpwin = root[F("win")];
|
|
||||||
if (httpwin) {
|
|
||||||
String apireq = "win&";
|
|
||||||
apireq += httpwin;
|
|
||||||
handleSet(nullptr, apireq, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ps = root[F("ps")] | -1;
|
int ps = root[F("ps")] | -1;
|
||||||
if (ps >= 0) applyPreset(ps);
|
if (ps >= 0) applyPreset(ps);
|
||||||
|
|
||||||
@ -263,6 +251,13 @@ bool deserializeState(JsonObject root)
|
|||||||
if (ps > 0) {
|
if (ps > 0) {
|
||||||
deletePreset(ps);
|
deletePreset(ps);
|
||||||
}
|
}
|
||||||
|
//HTTP API commands
|
||||||
|
const char* httpwin = root["win"];
|
||||||
|
if (httpwin) {
|
||||||
|
String apireq = "win&";
|
||||||
|
apireq += httpwin;
|
||||||
|
handleSet(nullptr, apireq, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return stateResponse;
|
return stateResponse;
|
||||||
@ -435,23 +430,13 @@ void serializeInfo(JsonObject root)
|
|||||||
JsonObject wifi_info = root.createNestedObject("wifi");
|
JsonObject wifi_info = root.createNestedObject("wifi");
|
||||||
wifi_info[F("bssid")] = WiFi.BSSIDstr();
|
wifi_info[F("bssid")] = WiFi.BSSIDstr();
|
||||||
int qrssi = WiFi.RSSI();
|
int qrssi = WiFi.RSSI();
|
||||||
|
|
||||||
wifi_info[F("rssi")] = qrssi;
|
wifi_info[F("rssi")] = qrssi;
|
||||||
wifi_info[F("signal")] = getSignalQuality(qrssi);
|
wifi_info[F("signal")] = getSignalQuality(qrssi);
|
||||||
wifi_info[F("channel")] = WiFi.channel();
|
wifi_info[F("channel")] = WiFi.channel();
|
||||||
|
|
||||||
JsonObject fs_info = root.createNestedObject("fs");
|
JsonObject fs_info = root.createNestedObject("fs");
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
fs_info["u"] = fsBytesUsed / 1000;
|
||||||
size_t used, total;
|
fs_info["t"] = fsBytesTotal / 1000;
|
||||||
esp_spiffs_info(nullptr, &total, &used);
|
|
||||||
fs_info["u"] = used;
|
|
||||||
fs_info["t"] = total;
|
|
||||||
#else
|
|
||||||
FSInfo fsi;
|
|
||||||
WLED_FS.info(fsi);
|
|
||||||
fs_info["u"] = fsi.usedBytes;
|
|
||||||
fs_info["t"] = fsi.totalBytes;
|
|
||||||
#endif
|
|
||||||
fs_info[F("pmt")] = presetsModifiedTime;
|
fs_info[F("pmt")] = presetsModifiedTime;
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
@ -188,6 +188,7 @@ void WLED::setup()
|
|||||||
DEBUGFS_PRINTLN(F("FS failed!"));
|
DEBUGFS_PRINTLN(F("FS failed!"));
|
||||||
errorFlag = ERR_FS_BEGIN;
|
errorFlag = ERR_FS_BEGIN;
|
||||||
}
|
}
|
||||||
|
updateFSInfo();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DEBUG_PRINTLN(F("Load EEPROM"));
|
DEBUG_PRINTLN(F("Load EEPROM"));
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2010020
|
#define VERSION 2010030
|
||||||
|
|
||||||
// ESP8266-01 (blue) got too little storage space to work with WLED. 0.10.2 is the last release supporting this unit.
|
// ESP8266-01 (blue) got too little storage space to work with WLED. 0.10.2 is the last release supporting this unit.
|
||||||
|
|
||||||
@ -157,8 +157,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Global Variable definitions
|
// Global Variable definitions
|
||||||
WLED_GLOBAL char versionString[] _INIT("0.10.2");
|
WLED_GLOBAL char versionString[] _INIT("0.11.0p");
|
||||||
#define WLED_CODENAME "Fumikiri"
|
#define WLED_CODENAME "Mirai"
|
||||||
|
|
||||||
// AP and OTA default passwords (for maximum security change them!)
|
// AP and OTA default passwords (for maximum security change them!)
|
||||||
WLED_GLOBAL char apPass[65] _INIT(DEFAULT_AP_PASS);
|
WLED_GLOBAL char apPass[65] _INIT(DEFAULT_AP_PASS);
|
||||||
@ -472,13 +472,16 @@ WLED_GLOBAL uint16_t rolloverMillis _INIT(0);
|
|||||||
WLED_GLOBAL char* obuf;
|
WLED_GLOBAL char* obuf;
|
||||||
WLED_GLOBAL uint16_t olen _INIT(0);
|
WLED_GLOBAL uint16_t olen _INIT(0);
|
||||||
|
|
||||||
|
// General filesystem
|
||||||
|
WLED_GLOBAL size_t fsBytesUsed _INIT(0);
|
||||||
|
WLED_GLOBAL size_t fsBytesTotal _INIT(0);
|
||||||
|
WLED_GLOBAL unsigned long presetsModifiedTime _INIT(0L);
|
||||||
|
|
||||||
// presets
|
// presets
|
||||||
WLED_GLOBAL uint16_t savedPresets _INIT(0);
|
WLED_GLOBAL uint16_t savedPresets _INIT(0);
|
||||||
WLED_GLOBAL int16_t currentPreset _INIT(-1);
|
WLED_GLOBAL int16_t currentPreset _INIT(-1);
|
||||||
WLED_GLOBAL bool isPreset _INIT(false);
|
WLED_GLOBAL bool isPreset _INIT(false);
|
||||||
|
|
||||||
WLED_GLOBAL unsigned long presetsModifiedTime _INIT(0L);
|
|
||||||
|
|
||||||
WLED_GLOBAL byte errorFlag _INIT(0);
|
WLED_GLOBAL byte errorFlag _INIT(0);
|
||||||
|
|
||||||
WLED_GLOBAL String messageHead, messageSub;
|
WLED_GLOBAL String messageHead, messageSub;
|
||||||
|
@ -702,9 +702,10 @@ void savePreset(byte index, bool persist, const char* pname, byte priority, Json
|
|||||||
|
|
||||||
writeObjectToFileUsingId("/presets.json", index, &doc);
|
writeObjectToFileUsingId("/presets.json", index, &doc);
|
||||||
presetsModifiedTime = now(); //unix time
|
presetsModifiedTime = now(); //unix time
|
||||||
|
updateFSInfo();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (index > 16) return;
|
/*if (index > 16) return;
|
||||||
if (index < 1) {saveSettingsToEEPROM();return;}
|
if (index < 1) {saveSettingsToEEPROM();return;}
|
||||||
uint16_t i = 380 + index*20;//min400
|
uint16_t i = 380 + index*20;//min400
|
||||||
|
|
||||||
@ -737,13 +738,14 @@ void savePreset(byte index, bool persist, const char* pname, byte priority, Json
|
|||||||
if (persist) commit();
|
if (persist) commit();
|
||||||
savedToPresets();
|
savedToPresets();
|
||||||
currentPreset = index;
|
currentPreset = index;
|
||||||
isPreset = true;
|
isPreset = true;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void deletePreset(byte index) {
|
void deletePreset(byte index) {
|
||||||
StaticJsonDocument<24> empty;
|
StaticJsonDocument<24> empty;
|
||||||
writeObjectToFileUsingId("/presets.json", index, &empty);
|
writeObjectToFileUsingId("/presets.json", index, &empty);
|
||||||
presetsModifiedTime = now(); //unix time
|
presetsModifiedTime = now(); //unix time
|
||||||
|
updateFSInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user