GxEPD and GxEPD2 does not yet support this display from what I see. I would like to find more libraries for this display or help someone like @ZinggJM to help gain traction on this display as small 4 color epaper displays are becoming more common. I am not sure what it take to support this but I am finding it be very difficult on my end to get anything displayed other than the demo.
Here is where the display can be found [GDEM0097F51] 0.97-Inch E Ink Display Yellow and Red E-paper GDEM0097F51 Energy Efficient, High Contrast Screen for Smart Devices
Demo Code located at the bottom of main page.
Image Converter Code I was given by the supplier
// 4-Color Grayscale Processing Function for ePaper Displays
// Converts image data (RGB) into grayscale values and stores them in a compact format.
else if (mode === 'fourColor') {
const width = imageData.width;
const height = imageData.height;
const data = imageData.data;
const processedData = new Uint8Array(Math.ceil((width * height) / 4)); // Array size for 4-gray-scale mode
// Function to convert RGB colors to grayscale in 4-gray-scale mode
function rgbToGray(r, g, b) {
const grayscale = Math.round(0.299 * r + 0.587 * g + 0.114 * b);
if (grayscale < 64) return 0x03; // Black
if (grayscale < 128) return 0x02; // Red
if (grayscale < 140) return 0x00; // Yellow
return 0x01; // White
}
// Process the image data row by row
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const index = (y * width + x) * 4; // Get pixel index (RGBA format)
const r = data[index]; // Red channel
const g = data[index + 1]; // Green channel
const b = data[index + 2]; // Blue channel
const grayValue = rgbToGray(r, g, b);
// Store grayscale values in the processedData array
const newIndex = (y * width + x) / 4 | 0; // Calculate the new index
const shift = 6 - ((x % 4) * 2); // Determine bit position
processedData[newIndex] |= (grayValue << shift);
}
}
return processedData; // Returns the processed grayscale data
}
