I found the disconnect.
The code shown in the tutorial [here is a partial code, and not enough to load. It also doesn’t match the example code provided with the hyperdisplay 4DLCD-320240 library. (Example4_BufferingHyperDisplay.) The example provided with the 4DLCD-320240 library does not work as is.
I managed to get something working, but it breaks if I set a window larger than 240x166 pixels tall. (240x167 just doesn’t run)
I flipped the numbers, and the same is true. Does the Artemis board not have enough memory for a single full screen window buffer, or is there some other bug?
My current working code is below. It took a long time to get past the confusing example that constantly swapped windows for no reason.
If this is actually buffered, the render speed is only a tiny bit faster than direct mode.
#include "HyperDisplay_4DLCD-320240_4WSPI.h"
#define SERIAL_PORT Serial // Allows users to easily change target serial port (e.g. SAMD21's SerialUSB)
#define PWM_PIN PWM0 // Pin definitions
#define CS_PIN D0
#define DC_PIN D1
#define SPI_PORT SPI
#define SPI_SPEED 32000000 // Requests host uC to use the fastest possible SPI speed up to 32 MHz
LCD320240_4WSPI myTFT;
ILI9341_color_16_t defaultColor;
void setup() {
SERIAL_PORT.begin(115200);
SERIAL_PORT.println("Example4 HyperDisplay : SparkFun TFT LCD 2.4in");
myTFT.begin(DC_PIN, CS_PIN, PWM_PIN, SPI_PORT, SPI_SPEED); // This is a non-hyperdisplay function, but it is required to make the display work
myTFT.setInterfacePixelFormat(ILI9341_PXLFMT_16);
defaultColor = myTFT.rgbTo16b( 255, 255, 255 );
myTFT.setCurrentWindowColorSequence((color_t)&defaultColor);
}
void loop() {
//Direct Drawing
myTFT.pCurrentWindow = &hyperdisplayDefaultWindow; //Switch to default window
myTFT.direct(); // Set the window to buffer mode
// myTFT.clearDisplay(); //clear the display
ILI9341_color_16_t defaultBGcolor = myTFT.rgbTo16b( 200, 0, 0 ); //Set a background color
myTFT.fillWindow((color_t)&defaultBGcolor); //Fill backgrouund
myTFT.setTextCursor(12,12); //Set cursor position
myTFT.print("This text is direct mode..."); //Print text
myTFT.rectangle(0,0, 239, 319); // Draw a border around the window
myTFT.line(0,0, 239,319); // Draw a line
delay(1000);
//Buffered drawing
ILI9341_color_16_t window2Mem[240*166]; // Reserve memory for a sub-window
wind_info_t window2; // Create the sub-window structure
myTFT.setWindowDefaults(&window2); // Initialize the sub-window
window2.xMin = 0; // Top left corner
window2.yMin = 0; // Distance from top
window2.xMax = 239; // Bottom right corner
window2.yMax = 165; // Bottom left corner
myTFT.setWindowColorSequence(&window2, (color_t)&defaultColor); // Set a background color
myTFT.setWindowMemory(&window2, (color_t)window2Mem, 240*166); // Setup color space in memory
myTFT.pCurrentWindow = &window2; // Switch to sub-window
myTFT.buffer(); // Set the current window to buffer mode
ILI9341_color_16_t smallBGcolor = myTFT.rgbTo16b( 0, 200, 00 ); // Make a background color for the sub-window
myTFT.fillWindow((color_t)&smallBGcolor); // Fill background of the sub-window
myTFT.setTextCursor(12,12); //Set cursor position
myTFT.print("This text is buffered mode..."); //Print text
myTFT.line(0,0, 239,165); // Draw a line using the default color sequence
myTFT.rectangle(0,0, 239, 165); // Draw a border around the window
myTFT.show();
delay(1000);
}
](https://learn.sparkfun.com/tutorials/everything-you-should-know-about-hyperdisplay/buffering)