color wave4i7color 640x400 B%7CR%7CY%7CBlue%7CG%7CO - martinberlin/cale-idf GitHub Wiki

4 01inch-e-Paper-HAT

Test code:

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "color/wave4i7Color.h"

// Single SPI EPD
EpdSpi io;
Wave4i7Color display(io);

extern "C" { void app_main(); }

void app_main(void)
{
   printf("CalEPD version: %s\n", CALEPD_VERSION);
   // Initialize class
   display.init(false);
   // Draw some colorful squares
   uint16_t rectW = display.width()/4; // For 640 = 160 pix width
  
   display.fillRect(      1, 1, rectW, rectW, EPD_RED);
   display.fillRect(rectW  , 1, rectW, rectW, EPD_GREEN);
   display.fillRect(rectW*2, 1, rectW, rectW, EPD_YELLOW); 
   display.fillRect(rectW*3, 1, rectW, rectW, EPD_BLUE);
   // Refresh epaper
   display.update(); 
}

More information and technical details

Please check the Wave5i7color class to read more technical details about colors and how GFX / epaper buffer work together.

Color reference and epaper buffer

Every pixel in the epaper buffer takes 4 bits. Technically 3 will be enough but they make it 4 so it's easier for programming. So every byte holds 2 pixels.

Color 	BIN 	HEX
Black 	0b0000 	0x0 	
White 	0b0001 	0x1 	
Green 	0b0010 	0x2 	
Blue 	0b0011 	0x3 	
Red 	0b0100 	0x4 	
Yellow 	0b0101 	0x5 	
Orange 	0b0110 	0x6

Example 2 bytes: 4 color pixels

Data 	0 0 1 0 | 0 1 0 1   0 1 0 0 | 0 1 1 0 				
Colors  Green     Yellow    Red       Orange       
Byte 	0x25 	            0x46
⚠️ **GitHub.com Fallback** ⚠️