Waveshare IT8951 library adaptation for 32bit microcontroller under Arduino framework
Adaptation of the Waveshare IT8951 library for 32bit microcontroller under Arduino framework optimized for low memory. It uses 1 bit per pixel to divide by 8 the total capacity of one image (only 2 greyscale values). All functions and declarations of the buffers are done for 1 bit per pixel.
Juste redefine the RESET
and HDRY
constants to match your microcontroller. You can also change the configuration of the SPI interface in the init function.
This library is designed for the Waveshare 6inch HD e-Paper display (aka. ED060KC1). But it can suit for all EPaper displays with the same interface (IT8951), you have just to check the values in the header file.
You can use the xbpp-img2array utility to convert your image to a 1bpp array.
#include "it8951.h"
extern uint8_t* gpFrameBuf;
extern IT8951DevInfo gstI80DevInfo;
bool display_begin() {
uint8_t err = IT8951_Init();
return err == 0;
}
void display_buffer(const uint8_t* addr, uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
gpFrameBuf = (uint8_t *)addr;
IT8951AreaImgInfo stAreaImgInfo;
IT8951WaitForDisplayReady();
stAreaImgInfo.usX = x;
stAreaImgInfo.usY = y;
stAreaImgInfo.usWidth = w;
stAreaImgInfo.usHeight = h;
IT8951Load1bppImage(gpFrameBuf, stAreaImgInfo.usX, stAreaImgInfo.usY, stAreaImgInfo.usWidth, stAreaImgInfo.usHeight);
IT8951DisplayArea1bpp(stAreaImgInfo.usX, stAreaImgInfo.usY, stAreaImgInfo.usWidth, stAreaImgInfo.usHeight, 0x01, 0x00, 0xFF);
}
void display_clear() {
IT8951AreaImgInfo stAreaImgInfo;
memset(gpFrameBuf, 0xff, (gstI80DevInfo.usPanelW * gstI80DevInfo.usPanelH) / 8);
IT8951WaitForDisplayReady();
stAreaImgInfo.usX = 0;
stAreaImgInfo.usY = 0;
stAreaImgInfo.usWidth = gstI80DevInfo.usPanelW;
stAreaImgInfo.usHeight = gstI80DevInfo.usPanelH;
IT8951Load1bppImage(gpFrameBuf, stAreaImgInfo.usX, stAreaImgInfo.usY, stAreaImgInfo.usWidth, stAreaImgInfo.usHeight);
IT8951DisplayArea1bpp(0, 0, gstI80DevInfo.usPanelW, gstI80DevInfo.usPanelH, 0x00, 0x00, 0xFF);
}
👤 Le French POC
- Github: @LeFrenchPOC
- Website: https://www.lefrenchpoc.fr/
Give a ⭐️ if this project helped you!
Copyright © 2021 Le French POC.
This project is MIT licensed.