Skip to content
Open
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
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@
"*.tpp": "cpp",
"condition_variable": "cpp",
"mutex": "cpp",
"thread": "cpp"
"thread": "cpp",
"csignal": "cpp"
},
"files.trimTrailingWhitespace": true,
"editor.trimAutoWhitespace": true,
"files.insertFinalNewline": true,
"editor.autoIndent": "none",

"githubPullRequests.ignoredPullRequestBranches": [
"main"
Expand Down
12 changes: 12 additions & 0 deletions src/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ JsonDocument BruceConfig::toJson() const {

setting["rot"] = rotation;
setting["dimmerSet"] = dimmerSet;
setting["smoothSleep"] = smoothSleep;
setting["bright"] = bright;
setting["tmz"] = tmz;
setting["soundEnabled"] = soundEnabled;
Expand Down Expand Up @@ -160,6 +161,12 @@ void BruceConfig::fromFile(bool checkFS) {
count++;
log_e("Fail");
}
if (!setting["smoothSleep"].isNull()) {
smoothSleep = setting["smoothSleep"].as<bool>();
} else {
count++;
log_e("Fail");
}
if (!setting["bright"].isNull()) {
bright = setting["bright"].as<int>();
} else {
Expand Down Expand Up @@ -491,6 +498,11 @@ void BruceConfig::setDimmer(int value) {
saveFile();
}

void BruceConfig::setSmoothSleep(int value) {
smoothSleep = value;
saveFile();
}

void BruceConfig::validateDimmerValue() {
if (dimmerSet < 0) dimmerSet = 10;
if (dimmerSet > 60) dimmerSet = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class BruceConfig : public BruceTheme {
int wifiAtStartup = 0;
int instantBoot = 0;

bool smoothSleep = true;

// Led
int ledBright = 75;
uint32_t ledColor = 0;
Expand Down Expand Up @@ -124,6 +126,7 @@ class BruceConfig : public BruceTheme {
void setRotation(int value);
void validateRotationValue();
void setDimmer(int value);
void setSmoothSleep(int value);
void validateDimmerValue();
void setBright(uint8_t value);
void validateBrightValue();
Expand Down
20 changes: 15 additions & 5 deletions src/core/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "core/wifi/webInterface.h" // for server
#include "core/wifi/wg.h" //for isConnectedWireguard to print wireguard lock
#include "mykeyboard.h"
#include "powerSave.h"
#include "settings.h" //for timeStr
#include "utils.h"
#include <JPEGDecoder.h>
Expand Down Expand Up @@ -105,18 +106,27 @@ void turnOffDisplay() { setBrightness(0, false); }

bool wakeUpScreen() {
previousMillis = millis();

// 1) Waking from full‐off (screen‐off + dimmer irrelevant)
if (isScreenOff) {
// tell sleepModeOff we were fully off
sleepModeOff(bruceConfig.smoothSleep);

// now clear both flags for next idle cycle
isScreenOff = false;
dimmer = false;
getBrightness();
vTaskDelay(pdMS_TO_TICKS(200));
return true;
} else if (dimmer) {
}
// 2) Waking from dim (dimmer==true, but screen still on)
else if (dimmer) {
// tell sleepModeOff we were only dimmed
sleepModeOff(bruceConfig.smoothSleep);

// now clear dimmer for next cycle
dimmer = false;
getBrightness();
vTaskDelay(pdMS_TO_TICKS(200));
return true;
}

return false;
}

Expand Down
110 changes: 88 additions & 22 deletions src/core/menu_items/ConfigMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,31 @@
#include "core/led_control.h"
#endif

void ConfigMenu::optionsMenu() {

void displayMenu() {
options = {
{"Brightness", setBrightnessMenu},
{"Dim Time", setDimmerTimeMenu},
{"Smooth Sleep", setSmoothSleepMenu},
{"Orientation", lambdaHelper(gsetRotation, true)},
};
addOptionToMainMenu();

loopOptions(options, MENU_TYPE_SUBMENU, "Display");
}

void userinterfaceMenu() {
options = {
{"UI Color", setUIColor},
{"UI Theme", setTheme},
{String("InstaBoot: " + String(bruceConfig.instantBoot ? "ON" : "OFF")),
[=]() {
bruceConfig.instantBoot = !bruceConfig.instantBoot;
bruceConfig.saveFile();
}},
#ifdef HAS_RGB_LED
};
addOptionToMainMenu();

loopOptions(options, MENU_TYPE_SUBMENU, "User Interface");
}

void ledMenu() {
options = {
{"LED Color",
[=]() {
beginLed();
Expand All @@ -37,24 +49,78 @@ void ConfigMenu::optionsMenu() {
beginLed();
setLedBrightnessConfig();
}},
{"Led Blink On/Off", setLedBlinkConfig},
#endif
{"Sound On/Off", setSoundConfig},
{"Led Blink On/Off", setLedBlinkConfig },
};
addOptionToMainMenu();

loopOptions(options, MENU_TYPE_SUBMENU, "LED(s)");
}

void audioMenu() {
options = {
{"Sound On/Off", setSoundConfig },
#if defined(HAS_NS4168_SPKR)
{"Sound Volume", setSoundVolume},
{"Sound Volume", setSoundVolume },
#endif
{"Startup WiFi", setWifiStartupConfig},
{"Startup App", setStartupApp},
{"Hide/Show Apps", []() { mainMenu.hideAppsMenu(); }},
{"Network Creds", setNetworkCredsMenu},
{"Clock", setClock},
};
addOptionToMainMenu();

loopOptions(options, MENU_TYPE_SUBMENU, "Audio");
}

void appsMenu() {
options = {
{"Startup App", setStartupApp },
{"Hide/Show Apps", []() { mainMenu.hideAppsMenu(); }},
};
addOptionToMainMenu();

loopOptions(options, MENU_TYPE_SUBMENU, "Applications");
}

void networkMenu() {
options = {
{"Startup WiFi", setWifiStartupConfig },
{"Network Creds", setNetworkCredsMenu },
};
addOptionToMainMenu();

loopOptions(options, MENU_TYPE_SUBMENU, "Network");
}

void deviceMenu() {
options = {
{String("InstaBoot: " + String(bruceConfig.instantBoot ? "ON" : "OFF")),
[=]() {
bruceConfig.instantBoot = !bruceConfig.instantBoot;
bruceConfig.saveFile();
}},
{"Turn-off", powerOff},
{"Deep Sleep", goToDeepSleep},
{"Sleep", setSleepMode},
{"Factory Reset", [=]() { bruceConfig.factoryReset(); }},
{"Restart", [=]() { ESP.restart(); }},
{"Factory Reset", [=]() { bruceConfig.factoryReset(); }},
{"Restart", [=]() { ESP.restart(); }},
};
addOptionToMainMenu();

loopOptions(options, MENU_TYPE_SUBMENU, "Device");
}


options.push_back({"Turn-off", powerOff});
options.push_back({"Deep Sleep", goToDeepSleep});

void ConfigMenu::optionsMenu() {
options = {
{"Device", deviceMenu},
{"Display", displayMenu },
{"User Interface", userinterfaceMenu },
#ifdef HAS_RGB_LED
{"LED(s)", ledMenu },
#endif
{"Audio", audioMenu },
{"Applications", appsMenu },
{"Network", networkMenu },
{"Clock", setClock },
};

if (bruceConfig.devMode) options.push_back({"Dev Mode", [=]() { devMenu(); }});

Expand All @@ -66,11 +132,11 @@ void ConfigMenu::optionsMenu() {

void ConfigMenu::devMenu() {
options = {
{"I2C Finder", find_i2c_addresses },
{"I2C Finder", find_i2c_addresses },
{"CC1101 Pins", [=]() { setSPIPinsMenu(bruceConfigPins.CC1101_bus); }},
{"NRF24 Pins", [=]() { setSPIPinsMenu(bruceConfigPins.NRF24_bus); } },
{"SDCard Pins", [=]() { setSPIPinsMenu(bruceConfigPins.SDCARD_bus); }},
{"Back", [=]() { optionsMenu(); } },
{"Back", [=]() { optionsMenu(); } },
};

loopOptions(options, MENU_TYPE_SUBMENU, "Dev Mode");
Expand Down
Loading