Two new classes have been added to the Ports library:
- MemoryPlug – provides access to the EEPROM(s) via PortI2C
- MemoryStream – access one or more pages as a byte stream
This code is now included as “memory_demo” example in the Ports Library.
It collects all incoming data from the serial / USB port, as much as will fit on the Memory Plug’s EEPROM chips that is (512 Kb if all four M24M01’s have been installed).
Pressing button 1 (green LED on my setup) replays all stored data back to that same serial port (this process is interrupted if anything is received).
Pressing button 2 (red LED for me) resets the stream and clears all data stored so far.
Here is some sample output:
What I did was: 1) send “aaa”, 2) press button 2, 3) send “bbb”, 4) send “ccc”, and 5) press button 1. As you can see, everything sent after pressing button 2 is echoed back when button 1 is pressed.
The first line of the sample output illustrates random access to the Memory Plug without using streams. Multiple memory chips will be addressed as if they were one, i.e. the MemoryPlug class automatically selects the proper 0x50..0x70 I2C device address.
The public interface to these two classes is as follows:
You can define multiple streams at the same time on a single memory plug, by picking different starting pages, and they can fill additional pages in increasing (dir=1) or decreasing (dir=-1) order.