System class.
More...
#include <System.h>
◆ SystemClass()
SystemClass::SystemClass |
( |
| ) |
|
|
inline |
◆ deepSleep()
Enter deep sleep mode. Deep sleep turns off processor and keeps only the RTC memory active.
- Parameters
-
timeMilliseconds | Quantity of milliseconds to remain in deep sleep mode |
options | Deep sleep options |
- Note
- Determine reset cause like this:
auto info = system_get_rst_info();
if(info->reason == REASON_DEEP_SLEEP_AWAKE) {
// ...
}
-
ESP8266: Ensure GPIO 16 (XPD_DCDC) is connected to RST (EXT_RSTB). and call pinMode(16, WAKEUP_PULLUP) to enable wakeup from deep sleep.
◆ getCpuFrequency()
Get the CPU frequency.
- Return values
-
CpuFrequency | The frequency of the CPU |
◆ getMaxTaskCount()
static unsigned SystemClass::getMaxTaskCount |
( |
| ) |
|
|
inlinestatic |
Get maximum number of tasks seen on queue at any one time.
- Return values
-
- Note
- If return value is higher than maximum task queue TASK_QUEUE_LENGTH then the queue has overflowed at some point and tasks have been left un-executed.
◆ getTaskCount()
static unsigned SystemClass::getTaskCount |
( |
| ) |
|
|
inlinestatic |
Get number of tasks currently on queue.
- Return values
-
◆ initialize()
static bool SystemClass::initialize |
( |
| ) |
|
|
static |
System initialisation.
- Return values
-
- Note
- Called by user_main: applications should not call this function or the task queue will be re-initialised and any currently queued tasks won't be called.
◆ isReady()
bool SystemClass::isReady |
( |
| ) |
|
|
inline |
Check if system ready.
- Return values
-
bool | True if system initialisation is complete and system is now ready |
◆ onReady() [1/2]
Set handler for system ready event.
- Parameters
-
readyHandler | Function to handle event |
- Note
- if system is ready, callback is executed immediately without deferral
◆ onReady() [2/2]
Set handler for system ready event.
- Parameters
-
readyHandler | Function to handle event |
- Note
- if system is ready, callback is executed immediately without deferral
◆ queueCallback() [1/4]
Queue a deferred callback with no callback parameter.
◆ queueCallback() [2/4]
static bool SystemClass::queueCallback |
( |
TaskCallback |
callback, |
|
|
void * |
param = nullptr |
|
) |
| |
|
inlinestatic |
Queue a deferred callback, with optional void* parameter.
◆ queueCallback() [3/4]
Queue a deferred callback.
- Parameters
-
callback | The function to be called |
param | Parameter passed to the callback (optional) |
- Return values
-
bool | false if callback could not be queued |
- Note
- It is important to check the return value to avoid memory leaks and other issues, for example if memory is allocated and relies on the callback to free it again. Note also that this method is typically called from interrupt context so must avoid things like heap allocation, etc.
◆ queueCallback() [4/4]
Queue a deferred Delegate callback.
- Parameters
-
- Return values
-
bool | false if callback could not be queued |
- Note
- Provides flexibility and ease of use for using capturing lambdas, etc. but requires heap allocation and not as fast as a function callback. DO NOT use from interrupt context, use a Task/Interrupt callback.
◆ restart()
void SystemClass::restart |
( |
unsigned |
deferMillis = 0 | ) |
|
Request a restart of the system.
- Parameters
-
deferMillis | defer restart request by a number of milliseconds |
- Note
- A delay is often required to allow network callback code to complete correctly. The restart is always deferred, either using the task queue (if deferMillis == 0) or using a timer. This method always returns immediately.
◆ setCpuFrequency()
Set the CPU frequency.
- Parameters
-
- Return values
-
The documentation for this class was generated from the following file: