Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ extern JsonDocument settings;

extern String fileToCopy;

extern bool onlyBins;
extern bool onlyBins;

extern bool noDotFiles;

extern int rotation;

Expand Down
5 changes: 3 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ int prog_handler; // 0 - Flash, 1 - SPIFFS
int currentIndex;
int rotation = ROTATION;
bool sdcardMounted;
bool onlyBins;
bool returnToMenu;
bool onlyBins;
bool noDotFiles;
bool returnToMenu;
bool update;
bool askSpiffs;

Expand Down
20 changes: 11 additions & 9 deletions src/sd_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,17 @@ void readFs(String &folder, std::vector<Option> &opt) {

uint16_t color = FGCOLOR - 0x1111;

if (!isDir) {
int dotIndex = nameOnly.lastIndexOf(".");
String ext = dotIndex >= 0 ? nameOnly.substring(dotIndex + 1) : "";
ext.toUpperCase();
if (onlyBins && !ext.equals("BIN")) { continue; }
color = FGCOLOR;
} else {
nameOnly = "/" + nameOnly; // add / before folder name
}
if (noDotFiles && nameOnly.startsWith(".")) { continue; }

if (!isDir) {
int dotIndex = nameOnly.lastIndexOf(".");
String ext = dotIndex >= 0 ? nameOnly.substring(dotIndex + 1) : "";
ext.toUpperCase();
if (onlyBins && !ext.equals("BIN")) { continue; }
color = FGCOLOR;
} else {
nameOnly = "/" + nameOnly; // add / before folder name
}
opt.push_back({nameOnly, [fullPath]() { fileToUse = fullPath; }, color});
}
root.close();
Expand Down
105 changes: 72 additions & 33 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,28 @@ void settings_menu() {
} },
#endif
};
if (sdcardMounted) {
if (onlyBins)
options.push_back({"All Files", [=]() {
gsetOnlyBins(true, false);
saveConfigs();
}});
else
options.push_back({"Only Bins", [=]() {
gsetOnlyBins(true, true);
saveConfigs();
}});
}
if (sdcardMounted) {
if (onlyBins)
options.push_back({"All Files", [=]() {
gsetOnlyBins(true, false);
saveConfigs();
}});
else
options.push_back({"Only Bins", [=]() {
gsetOnlyBins(true, true);
saveConfigs();
}});
if (noDotFiles)
options.push_back({"Show Dotfiles", [=]() {
gsetNoDotFiles(true, false);
saveConfigs();
}});
else
options.push_back({"Hide Dotfiles", [=]() {
gsetNoDotFiles(true, true);
saveConfigs();
}});
}

if (askSpiffs)
options.push_back({"Avoid Spiffs", [=]() {
Expand Down Expand Up @@ -243,11 +253,30 @@ void getBrightness() {
#endif
}

/*********************************************************************
** Function: gsetOnlyBins
** get onlyBins from EEPROM
**********************************************************************/
bool gsetOnlyBins(bool set, bool value) {
/*********************************************************************
** Function: gsetNoDotFiles
** get/set noDotFiles global
**********************************************************************/
bool gsetNoDotFiles(bool set, bool value) {
bool result = false;

if (noDotFiles > 1) { set = true; }

if (noDotFiles == 0) result = false;
else result = true;

if (set) {
result = value;
noDotFiles = value; // update the global variable
}
return result;
}

/*********************************************************************
** Function: gsetOnlyBins
** get onlyBins from EEPROM
**********************************************************************/
bool gsetOnlyBins(bool set, bool value) {
bool result = false;

if (onlyBins > 1) { set = true; }
Expand Down Expand Up @@ -472,7 +501,7 @@ bool config_exists() {
;
if (conf) {
conf.printf(
"[{\"%s\":%d,\"dimmerSet\":10,\"onlyBins\":1,\"bright\":100,\"askSpiffs\":1,\"wui_usr\":"
"[{\"%s\":%d,\"dimmerSet\":10,\"onlyBins\":1,\"noDotFiles\":1,\"bright\":100,\"askSpiffs\":1,\"wui_usr\":"
"\"admin\",\"wui_pwd\":\"launcher\",\"dwn_path\":\"/downloads/"
"\",\"FGCOLOR\":2016,\"BGCOLOR\":0,\"ALCOLOR\":63488,\"even\":13029,\"odd\":12485,\",\"dev\":"
"0,\"wifi\":[{\"ssid\":\"myNetSSID\",\"pwd\":\"myNetPassword\"}], \"favorite\":[]}]",
Expand All @@ -497,8 +526,9 @@ bool saveIntoNVS() {

err |= nvsHandle->set_item("dimtime", dimmerSet);
err |= nvsHandle->set_item("bright", bright);
err |= nvsHandle->set_item("onlyBins", onlyBins);
err |= nvsHandle->set_item("askSpiffs", askSpiffs);
err |= nvsHandle->set_item("onlyBins", onlyBins);
err |= nvsHandle->set_item("noDotFiles", noDotFiles);
err |= nvsHandle->set_item("askSpiffs", askSpiffs);
err |= nvsHandle->set_item("rotation", rotation);
err |= nvsHandle->set_item("FGCOLOR", FGCOLOR);
err |= nvsHandle->set_item("BGCOLOR", BGCOLOR);
Expand Down Expand Up @@ -591,8 +621,9 @@ void defaultValues() {
// rotation = ROTATION;
dimmerSet = 20;
bright = 100;
onlyBins = true;
askSpiffs = true;
onlyBins = true;
noDotFiles = true;
askSpiffs = true;
#if defined(E_PAPER_DISPLAY) && defined(USE_M5GFX)
FGCOLOR = 0x0000;
BGCOLOR = 0xFFFF;
Expand Down Expand Up @@ -635,8 +666,9 @@ bool getFromNVS() {
}
err = nvsHandle->get_item("dimtime", dimmerSet);
err |= nvsHandle->get_item("bright", bright);
err |= nvsHandle->get_item("onlyBins", onlyBins);
err |= nvsHandle->get_item("askSpiffs", askSpiffs);
err |= nvsHandle->get_item("onlyBins", onlyBins);
err |= nvsHandle->get_item("noDotFiles", noDotFiles);
err |= nvsHandle->get_item("askSpiffs", askSpiffs);
err |= nvsHandle->get_item("rotation", rotation);
err |= nvsHandle->get_item("FGCOLOR", FGCOLOR);
err |= nvsHandle->get_item("BGCOLOR", BGCOLOR);
Expand Down Expand Up @@ -766,13 +798,19 @@ void getConfigs() {

int count = 0;
JsonObject setting = settings[0];
if (setting["onlyBins"].is<bool>()) {
onlyBins = gsetOnlyBins(setting["onlyBins"].as<bool>());
} else {
count++;
log_i("Fail");
}
if (setting["askSpiffs"].is<bool>()) {
if (setting["onlyBins"].is<bool>()) {
onlyBins = gsetOnlyBins(setting["onlyBins"].as<bool>());
} else {
count++;
log_i("Fail");
}
if (setting["noDotFiles"].is<bool>()) {
noDotFiles = gsetNoDotFiles(setting["noDotFiles"].as<bool>());
} else {
count++;
log_i("Fail");
}
if (setting["askSpiffs"].is<bool>()) {
askSpiffs = gsetAskSpiffs(setting["askSpiffs"].as<bool>());
} else {
count++;
Expand Down Expand Up @@ -938,8 +976,9 @@ void saveConfigs() {
}
}
// Update JSON document with current configuration
setting["onlyBins"] = onlyBins;
setting["askSpiffs"] = askSpiffs;
setting["onlyBins"] = onlyBins;
setting["noDotFiles"] = noDotFiles;
setting["askSpiffs"] = askSpiffs;
setting["bright"] = bright;
setting["dimmerSet"] = dimmerSet;
setting[get_efuse_mac_as_string()] = rotation;
Expand Down
8 changes: 5 additions & 3 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ config.conf JSON structure

[
{
"rot": 1,
"onlyBins":1,
"rot": 1,
"onlyBins":1,
"noDotFiles":1,
"bright":100,
"askSpiffs":1,
"wui_usr":"admin",
Expand All @@ -35,7 +36,8 @@ void _setBrightness(uint8_t brightval) __attribute__((weak));
void setBrightnessMenu();
void setBrightness(int bright, bool save = true);
void getBrightness();
bool gsetOnlyBins(bool set = false, bool value = true);
bool gsetOnlyBins(bool set = false, bool value = true);
bool gsetNoDotFiles(bool set = false, bool value = true);
bool gsetAskSpiffs(bool set = false, bool value = true);
int gsetRotation(bool set = false);
void getConfigs();
Expand Down
Loading