8 if not alarm.wake_alarm:
9 # Use byte 5 in sleep memory. This is just an example.
10 alarm.sleep_memory[5] = 0
11 alarm.sleep_memory[5] = (alarm.sleep_memory[5] + 1) % 256
12 print(alarm.sleep_memory[5])
13 while True: pass
Traceback (most recent call last):
File "code.py", line 10, in <module>
IndexError: index out of range
What am I doing wrong?
Bruce
Adafruit CircuitPython 8.0.5 on 2023-03-31; Raspberry Pi Pico W with rp2040
Board ID:raspberry_pi_pico_w
UID:E6614103E719A637
MAC:28:CD:C1:00:6B:08
boot.py output:
Write to SD Card: True
Write to Flash : False
boot.py Finis
//| class SleepMemory:
//| """Store raw bytes in RAM that persists during deep sleep.
//| The class acts as a ``bytearray``.
//| If power is lost, the memory contents are lost.
//|
//| Note that this class can't be imported and used directly. The sole
//| instance of :class:`SleepMemory` is available at
//| :attr:`alarm.sleep_memory`.
//|
//| **Limitations:** Not supported on RP2040.
At first blush, I would say the same as NVM, 0x1000 bytes. Any more than that would be best implemented with external FRAM or EEPROM. I would expect sleep_memory will have a life span, but better than NVM. If not so, there is not much point in sleep_menory, the user may as well go for FRAM at the start.
Bruce
FYI, I am testing an FRAM chip and am at 4,200,000 Write/reads so far.
You over estimate my abilities. I don't know what to do with artifacts. I assume compile the OS with them. I have not jumped into that puddle yet. Will the feature appear in an upcoming Alpha version?
Thank you, works as described.
Is the reserved 256 bytes going to be a permanent part of the CP 8.1.x build from now on?
Can the reservation of those 256 bytes be turned off to recover those bytes?
It will be in all RP2040 builds after 8.1.0. A custom build could be made to turn it off. I made it only 256 bytes to not affect the RAM usage materially.