From 4df7dcb3eecb2b0d693542bc78bb5302c6679936 Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Tue, 5 Jan 2016 12:43:57 +1100 Subject: [PATCH] Transferred rtcmem module documentation. --- docs/en/modules/rtcmem.md | 62 +++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 63 insertions(+) create mode 100644 docs/en/modules/rtcmem.md diff --git a/docs/en/modules/rtcmem.md b/docs/en/modules/rtcmem.md new file mode 100644 index 00000000..0982dfad --- /dev/null +++ b/docs/en/modules/rtcmem.md @@ -0,0 +1,62 @@ +# rtcmem Module +The rtcmem module provides basic access to the RTC (Real Time Clock) memory. + +The RTC in the ESP8266 contains memory registers which survive a deep sleep, making them highly useful for keeping state across sleep cycles. Some of this memory is reserved for system use, but 128 slots (each 32bit wide) are available for application use. This module provides read and write access to these. + +Due to the very limited amount of memory available, there is no mechanism for arbitrating use of particular slots. It is up to the end user to be aware of which memory is used for what, and avoid conflicts. Note that some Lua modules lay claim to certain slots. + +####See also + - rtctime module + - rtcfifo module + +## rtcmem.read32() + +Reads one or more 32bit values from RTC user memory. + +####Syntax +`rtcmem.read32(idx [, num])` + +####Parameters + - `idx`: The index to start reading from. Zero-based. + - `num`: Number of slots to read (default 1). + +####Returns +The value(s) read from RTC user memory. + +If `idx` is outside the valid range [0,127] this function returns nothing. + +If `num` results in overstepping the end of available memory, the function only returns the data from the valid slots. + +####Example +```lua +val = rtcmem.read32(0) -- Read the value in slot 0 +val1, val2 = rtcmem.read32(42, 2) -- Read the values in slots 42 and 43 +``` +####See also + - `rtcmem.write32()` +___ +## rtcmem.write32() + +Writes one or more values to RTC user memory, starting at index `idx`. + +Writing to indices outside the valid range [0,127] has no effect. + +####Syntax +`rtcmem.write32(idx, val [, val2, ...])` + +####Parameters + - `idx`: Index to start writing to. Auto-increments if multiple values are given. Zero-based. + - `val`: The (32bit) value to store. + - `val2...`: Additional values to store. Optional. + +####Returns +`nil` + +####Example +```lua +rtcmem.write32(0, 53) -- Store the value 53 in slot 0 +rtcmem.write32(42, 2, 5, 7) -- Store the values 2, 5 and 7 into slots 42, 43 and 44, respectively. +``` +####See also + - `rtcmem.read32()` +___ diff --git a/mkdocs.yml b/mkdocs.yml index 167f0c11..676faba4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -31,5 +31,6 @@ pages: - Modules: - 'node': 'en/modules/node.md' - 'file': 'en/modules/file.md' + - 'rtcmem': 'en/modules/rtcmem.md' - Deutsch: - Home: 'de/index.md'