pdf-icon

E-Ink

isInit()

功能说明:

初始化E-INK屏幕驱动

函数原型:

bool isInit()

clear()

功能说明:

清除墨水屏上的所有显示内容

函数原型:

int clear(int mode = INK_CLENR_MODE0)

案例程序:

#include "M5CoreInk.h"

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
}

Sprite

使用E-Ink屏幕操作函数前,需要创建实例并传入屏幕驱动地址.需调用M5.M5Ink.isInit(),与M5.M5Ink.clear()进行初始化。

creatSprite

功能说明:

创建图像区域,配置是否从屏幕驱动获取图像数据buff(默认为保存true)

函数原型:

int creatSprite(uint16_t posX, uint16_t posY, uint16_t width = 200, uint16_t height = 200, bool copyFromMem = true);

创建图像区域的x坐标必须为8的整数倍(eg:0, 8, 16...).否则会出现显示不正常的状况。

案例程序:

#include "M5CoreInk.h"
Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  //creat ink refresh Sprite
  if( InkPageSprite.creatSprite(0,0,200,200,true) != 0 ){
    Serial.printf("Ink Sprite creat faild");
  }else{
    Serial.printf("creatSprite success\n");
  }
}

pushSprite

功能说明:

推送已经编辑的图像数据到图像区域

函数原型:

int pushSprite()

使用绘图API操作后,都需要进行Push刷新屏幕,否则不会显示

案例程序:

#include "M5CoreInk.h"
Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  //creat ink refresh Sprite
  if( InkPageSprite.creatSprite(0,0,200,200,true) != 0 ){
    Serial.printf("Ink Sprite creat faild");
  }else{
    Serial.printf("creatSprite success\n");
    InkPageSprite.drawString(35,50,"creatSprite success");
    InkPageSprite.pushSprite();
  }
}

drawPix

功能说明:

在(x,y)处绘制单个像素点

函数原型:

void drawPix(uint16_t posX,uint16_t posY,uint8_t pixBit)

参数 pixBit 传入 0 时为黑色,传入 1 时为白色

案例程序:

#include "M5CoreInk.h"
Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  InkPageSprite.creatSprite(0,0,200,200,true);
  InkPageSprite.drawPix(100,100,0);
  InkPageSprite.pushSprite();
  }

drawChar

功能说明:

在(x,y)处绘制单个字符

函数原型:

void drawChar(uint16_t posX, uint16_t posY, char charData, Ink_eSPI_font_t* fontPtr)

#include "M5CoreInk.h"
Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  //creat ink refresh Sprite
  InkPageSprite.creatSprite(0,0,200,200,true);
  Serial.printf("Ink Sprite creat faild");
  InkPageSprite.drawChar(35,50,'M');
  InkPageSprite.pushSprite();
}

drawString

功能说明:

在(x,y)处绘制绘制字符串

函数原型:

void drawString(uint16_t posX, uint16_t posY, const char* charData, Ink_eSPI_font_t* fontPtr = &AsciiFont8x16)

案例程序:

#include "M5CoreInk.h"
Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  //creat ink refresh Sprite
  InkPageSprite.creatSprite(0,0,200,200,true);
  InkPageSprite.drawString(35,50,"Hello E-INK");
  InkPageSprite.pushSprite();
}

FillRect

功能说明:

在(x,y)处绘制宽为width,高为height的矩形

函数原型:

void FillRect(uint16_t posX, uint16_t posY, uint16_t width, uint16_t height, uint8_t pixBit)

参数 pixBit 传入 0 时为黑色,传入 1 时为白色

案例程序:

#include "M5CoreInk.h"
Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  InkPageSprite.creatSprite(0,0,200,200,true);
  InkPageSprite.FillRect(0,0,100,100,0);
  InkPageSprite.pushSprite();
}

drawFullBuff

功能说明:

绘制整个页面, 需要传入完整页面Buff

函数原型:

void drawFullBuff(uint8_t* buff, bool bitMode = true)

void drawBuff(uint16_t posX,uint16_t posY,uint16_t width,uint16_t height,uint8_t* imageDataptr)

clear

功能说明:

清除图像区域内容

函数原型:

void clear(int cleanFlag = CLEAR_DRAWBUFF)

cleanFlag 值 功能
CLEAR_DRAWBUFF 清除尚未Push的图像数据
CLEAR_LASTBUFF 清除上一次刷新的图像数据的缓存区,当再次push时将完整刷新屏幕

案例程序:

#include "M5CoreInk.h"
Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  InkPageSprite.creatSprite(0,0,200,200,true);
  InkPageSprite.FillRect(0,0,100,100,0);
  InkPageSprite.pushSprite();
  delay(2000);
  InkPageSprite.clear();
  InkPageSprite.pushSprite();
}

deleteSprite

功能说明:

释放已经创建的图像区域

函数原型:

int deleteSprite()

案例程序:

#include "M5CoreInk.h"
Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  if( InkPageSprite.creatSprite(0,0,200,200,true) != 0 ){
    Serial.printf("Ink Sprite creat faild");
  }else{
    Serial.printf("creat Sprite success\n");
  }
  if(InkPageSprite.deleteSprite()!= 0){
    Serial.printf("Sprite delete faild");
  }else{
    Serial.printf("delete Sprite success\n");
  }
}

getSpritePtr

功能说明:

获取图像Buff数据

函数原型:

uint8_t* getSpritePtr(){ return _spriteBuff;}

width

功能说明:

获取图像宽度

函数原型:

uint16_t width()

#include "M5CoreInk.h"

Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  InkPageSprite.creatSprite(0,0,200,200,true);
  Serial.printf("width:%d",InkPageSprite.width());
}

height

功能说明:

获取图像高度

函数原型:

uint16_t height()

#include "M5CoreInk.h"

Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  InkPageSprite.creatSprite(0,0,200,200,true);
  Serial.printf("height:%d",InkPageSprite.height());
}

posX

功能说明:

获取图像X坐标

函数原型:

uint16_t posX()

#include "M5CoreInk.h"

Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  InkPageSprite.creatSprite(0,0,200,200,true);
  Serial.printf("posX:%d",InkPageSprite.posX());
}

posY

功能说明:

获取图像Y坐标

函数原型:

uint16_t posY()

#include "M5CoreInk.h"

Ink_Sprite InkPageSprite(&M5.M5Ink);

void setup() {
  M5.begin();
  M5.M5Ink.isInit();
  M5.M5Ink.clear();
  delay(1000);
  InkPageSprite.creatSprite(0,0,200,200,true);
  Serial.printf("posY:%d",InkPageSprite.posY());
}
On This Page