Update node.dsleep() to support longer deep sleep duration. (#2358)
* Update node.dsleep() to support longer deep sleep duration. * Updated documentation for node.dsleepMax()
This commit is contained in:
parent
5e1ca234cc
commit
6069ebdc90
|
@ -38,10 +38,15 @@ static int node_restart( lua_State* L )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dsleepMax( lua_State *L ) {
|
||||||
|
lua_pushnumber(L, (uint64_t)system_rtc_clock_cali_proc()*(0x80000000-1)/(0x1000));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Lua: dsleep( us, option )
|
// Lua: dsleep( us, option )
|
||||||
static int node_deepsleep( lua_State* L )
|
static int node_deepsleep( lua_State* L )
|
||||||
{
|
{
|
||||||
uint32 us;
|
uint64 us;
|
||||||
uint8 option;
|
uint8 option;
|
||||||
//us = luaL_checkinteger( L, 1 );
|
//us = luaL_checkinteger( L, 1 );
|
||||||
// Set deleep option, skip if nil
|
// Set deleep option, skip if nil
|
||||||
|
@ -594,6 +599,7 @@ static const LUA_REG_TYPE node_map[] =
|
||||||
{
|
{
|
||||||
{ LSTRKEY( "restart" ), LFUNCVAL( node_restart ) },
|
{ LSTRKEY( "restart" ), LFUNCVAL( node_restart ) },
|
||||||
{ LSTRKEY( "dsleep" ), LFUNCVAL( node_deepsleep ) },
|
{ LSTRKEY( "dsleep" ), LFUNCVAL( node_deepsleep ) },
|
||||||
|
{ LSTRKEY( "dsleepMax" ), LFUNCVAL( dsleepMax ) },
|
||||||
#ifdef PMSLEEP_ENABLE
|
#ifdef PMSLEEP_ENABLE
|
||||||
{ LSTRKEY( "sleep" ), LFUNCVAL( node_sleep ) },
|
{ LSTRKEY( "sleep" ), LFUNCVAL( node_sleep ) },
|
||||||
PMSLEEP_INT_MAP,
|
PMSLEEP_INT_MAP,
|
||||||
|
|
|
@ -87,8 +87,7 @@ dofile("hello.lc")
|
||||||
|
|
||||||
Enters deep sleep mode, wakes up when timed out.
|
Enters deep sleep mode, wakes up when timed out.
|
||||||
|
|
||||||
The maximum sleep time is 4294967295us, ~71 minutes. This is an SDK limitation.
|
Theoretical maximum deep sleep duration can be found with [`node.dsleepMax()`](#nodedsleepmax)
|
||||||
Firmware from before 05 Jan 2016 have a maximum sleeptime of ~35 minutes.
|
|
||||||
|
|
||||||
!!! caution
|
!!! caution
|
||||||
|
|
||||||
|
@ -107,10 +106,7 @@ Firmware from before 05 Jan 2016 have a maximum sleeptime of ~35 minutes.
|
||||||
- 1, RF_CAL after deep-sleep wake up, there will be large current
|
- 1, RF_CAL after deep-sleep wake up, there will be large current
|
||||||
- 2, no RF_CAL after deep-sleep wake up, there will only be small current
|
- 2, no RF_CAL after deep-sleep wake up, there will only be small current
|
||||||
- 4, disable RF after deep-sleep wake up, just like modem sleep, there will be the smallest current
|
- 4, disable RF after deep-sleep wake up, just like modem sleep, there will be the smallest current
|
||||||
- `instant` number (integer) or `nil`. If present and non-zero, do not use
|
- `instant` number (integer) or `nil`. If present and non-zero, the chip will enter Deep-sleep immediately and will not wait for the Wi-Fi core to be shutdown.
|
||||||
the normal grace time before entering deep sleep. This is a largely
|
|
||||||
undocumented feature, and is only briefly mentioned in Espressif's
|
|
||||||
[low power solutions](https://espressif.com/sites/default/files/documentation/9b-esp8266_low_power_solutions_en.pdf#page=10) document (chapter 4.5).
|
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
`nil`
|
`nil`
|
||||||
|
@ -131,6 +127,38 @@ node.dsleep(nil,4)
|
||||||
- [`wifi.suspend()`](wifi.md#wifisuspend)
|
- [`wifi.suspend()`](wifi.md#wifisuspend)
|
||||||
- [`wifi.resume()`](wifi.md#wifiresume)
|
- [`wifi.resume()`](wifi.md#wifiresume)
|
||||||
- [`node.sleep()`](#nodesleep)
|
- [`node.sleep()`](#nodesleep)
|
||||||
|
- [`node.dsleepMax()`](#nodedsleepmax)
|
||||||
|
|
||||||
|
## node.dsleepMax()
|
||||||
|
|
||||||
|
Returns the current theoretical maximum deep sleep duration.
|
||||||
|
|
||||||
|
!!! caution
|
||||||
|
|
||||||
|
While it is possible to specify a longer sleep time than the theoretical maximum sleep duration, it is not recommended to exceed this maximum.
|
||||||
|
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
|
||||||
|
This theoretical maximum is dependent on ambient temperature.
|
||||||
|
(lower temp = shorter sleep duration, higher temp = longer sleep duration)
|
||||||
|
|
||||||
|
#### Syntax
|
||||||
|
`node.dsleepMax()`
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
none
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
`max_duration`
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
node.dsleep(node.dsleepMax())
|
||||||
|
```
|
||||||
|
|
||||||
|
#### See also
|
||||||
|
- [`node.dsleep()`](#nodedsleep)
|
||||||
|
|
||||||
## node.flashid()
|
## node.flashid()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue