As explained earlier, the EPD controller's RAM architecture is organized very differently from a TFT framebuffer, and this is the part most likely to trip up code ported from TFT experience.
If the target MCU doesn't have enough internal RAM to hold a full frame buffer — common on smaller 8-bit PICs when driving larger panels —
external SRAM can be used instead. Provided the external SRAM is large enough to hold the frame buffer, you can declare which plane it should be used for:
$define
EpdFrameBuffer
SRAM_1
SRAM_1 - By default used for the B&W plane.
$define
EpdFrameBuffer
SRAM_2
SRAM_2 - By default used for the R/Y plane.
$define
EpdFrameBuffer
SRAM_A
SRAM_A - Automatic mode: the library manages both planes' buffering for you, based on the declared panel type - ($define EpdType BW, $define EpdType BWR, or $define EpdType BWY).
Recommended unless your application has a specific reason to manage buffer placement manually.
The library supports a maximum of two virtual buffer regions within a single external SRAM chip, each sized (EPD width × EPD height) / 8 bytes.
By default, buffer 1 holds the B&W plane and buffer 2 holds the R/Y plane — but this is only a default assignment, not a fixed rule: either buffer can be assigned to hold either plane, and reassigning a buffer or plane at runtime simply redirects subsequent frame buffer operations to a different region within the chip - it does not move or copy any data.
This flexibility is useful in situations such as:
Select the current working buffer:
$define EPD_Buffer_A 0
$define EPD_Buffer_1 1
$define EPD_Buffer_2 2
Global Dim bWorkingBuffer As Byte Shared = EPD_Buffer_A
Proc EpdSetBuffer(bWorkingBuffer As bWorkingBuffer)
'Nothing
EndProc
$define EPD_Plane_BW BLACK
$define EPD_Plane_OLD BLACK
$define EPD_Plane_RY RED
$define EPD_Plane_NEW RED
Global Dim wWorkingPlane As Word Shared = EPD_Plane_BW
Proc EpdSetPlane(wWorkingPlane As wWorkingPlane)
'Nothing
EndProc
EpdSetBuffer selects which of the two virtual buffer regions within the external SRAM chip subsequent frame buffer operations act on; EpdSetPlane selects which logical plane, within that region, those operations write to.
Call these before a drawing operation to redirect it to a different buffer/plane combination than the current default.
Note: EPD_Plane_BW/EPD_Plane_OLD and EPD_Plane_RY/EPD_Plane_NEW are the same underlying values (BLACK and RED respectively) under different names, provided so your code can use whichever naming reads more clearly for the operation at hand — EPD_Plane_BW/RY when thinking in terms of display planes, EPD_Plane_OLD/NEW when thinking in terms of a previous vs. incoming frame.
Created with the Personal Edition of HelpNDoc: Effortlessly Create Encrypted, Password-Protected PDFs