-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add instantly option to deepSleep #5052
Conversation
cores/esp8266/Esp.h
Outdated
@@ -92,7 +92,7 @@ class EspClass { | |||
void wdtDisable(); | |||
void wdtFeed(); | |||
|
|||
void deepSleep(uint64_t time_us, RFMode mode = RF_DEFAULT); | |||
void deepSleep(uint64_t time_us, RFMode mode = RF_DEFAULT, bool instantly = false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding new function, deepSleepInstant
. This way, only one of system_deep_sleep_instant
/system_deep_sleep
will be linked into the final application, depending on what the user needs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done.
together with the request for a safe max option like requested in #4969 I opt for something like proposed here #4936 (comment) |
Doesn't that still have the issue that @igrr just mentioned of linking in a bit more than necessary. Also |
yes but then why not also seperate ESP.deepSleep() and ESP.setWakeUp() I don't mind having 2 additional bool arguments,
no hard feelings for obscure flags in arguments, just wanted to keep it max compat. |
Dear @5chufti, if a user encounters the following piece of code ESP.deepSleep(duration, RF_DEFAULT, true); they will need to go find the function declaration to figure out what "true" means. Compare this to ESP.deepSleepInstant(duration, RF_DEFAULT); where the method name conveys this information. Admittedly, the core has accumulated numerous APIs with optional boolean arguments, most via simple backwards-compatible enhancements like this one (in the original form of this PR). WiFi class is a good example. It doesn't mean though that the problem should be ignored. With regards to pulling in SDK functions — this is not academic hair splitting. Let me give you an extreme example. In the first version of HTTP Client library, there was code like this: // parse URL string, get host, port, protocol, URI
if (protocol == "https") {
client = new WiFiClientSecure(host, port);
} else {
client = new WiFiClient(host, port);
} This is an example of bad design. User usually only needs A or B, but the code includes functionality for both A and B at link time. In this specific case, it pulled in lots of SSL-related code, greatly increasing the binary size. It's going to be less extreme with system_deep_sleep, but still, this is a thing to consider. |
sorry, but here the user has to look up/find the useable definitions that are not even the same as in SDK !
and an explanation for the two boolean parameters.
There is no problem defining INSTANT or MAX_SAFE as true, to have it most simple.... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use another meaningful name like deepSleepCpuOnly
(or worse: deepSleepLeavingWiFiInItsState
) ?
WiFi is turned off as well, just not gracefully. |
OK, I was mistaken by "false friend" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind the code addition, or the doc entry. However, the deepSleepMax() discussion needs to continue, and the doc entries will likely need to updated accordingly. But that's to happen elsewhere, so approving.
As mentioned in #3408 (comment) here's an update to add an 'instantly' option to the deepSleep function.