2020.05.22
This commit is contained in:
parent
8973995e53
commit
853a3a4632
224 changed files with 26246 additions and 3145 deletions
|
|
@ -36,12 +36,12 @@ Epd::~Epd()
|
|||
|
||||
Epd::Epd()
|
||||
{
|
||||
reset_pin = RST_PIN;
|
||||
dc_pin = DC_PIN;
|
||||
cs_pin = CS_PIN;
|
||||
busy_pin = BUSY_PIN;
|
||||
width = EPD_WIDTH;
|
||||
height = EPD_HEIGHT;
|
||||
reset_pin = RST_PIN;
|
||||
dc_pin = DC_PIN;
|
||||
cs_pin = CS_PIN;
|
||||
busy_pin = BUSY_PIN;
|
||||
width = EPD_WIDTH;
|
||||
height = EPD_HEIGHT;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -49,8 +49,8 @@ Epd::Epd()
|
|||
*/
|
||||
void Epd::SendCommand(unsigned char command)
|
||||
{
|
||||
DigitalWrite(dc_pin, LOW);
|
||||
SpiTransfer(command);
|
||||
DigitalWrite(dc_pin, LOW);
|
||||
SpiTransfer(command);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -58,8 +58,8 @@ void Epd::SendCommand(unsigned char command)
|
|||
*/
|
||||
void Epd::SendData(unsigned char data)
|
||||
{
|
||||
DigitalWrite(dc_pin, HIGH);
|
||||
SpiTransfer(data);
|
||||
DigitalWrite(dc_pin, HIGH);
|
||||
SpiTransfer(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -67,64 +67,117 @@ void Epd::SendData(unsigned char data)
|
|||
*/
|
||||
void Epd::WaitUntilIdle(void)
|
||||
{
|
||||
while(DigitalRead(busy_pin) == 1) { //LOW: idle, HIGH: busy
|
||||
DelayMs(100);
|
||||
}
|
||||
DelayMs(200);
|
||||
while(DigitalRead(busy_pin) == 1) { //LOW: idle, HIGH: busy
|
||||
DelayMs(100);
|
||||
}
|
||||
DelayMs(200);
|
||||
}
|
||||
|
||||
int Epd::Init(void)
|
||||
int Epd::HDirInit(void)
|
||||
{
|
||||
/* this calls the peripheral hardware interface, see epdif */
|
||||
if (IfInit() != 0) {
|
||||
return -1;
|
||||
}
|
||||
/* EPD hardware init start */
|
||||
Reset();
|
||||
/* this calls the peripheral hardware interface, see epdif */
|
||||
if (IfInit() != 0) {
|
||||
return -1;
|
||||
}
|
||||
/* EPD hardware init start */
|
||||
Reset();
|
||||
|
||||
WaitUntilIdle();
|
||||
SendCommand(0x12); //SWRESET
|
||||
WaitUntilIdle();
|
||||
WaitUntilIdle();
|
||||
SendCommand(0x12); //SWRESET
|
||||
WaitUntilIdle();
|
||||
|
||||
SendCommand(0x01); //Driver output control
|
||||
SendData(0xC7);
|
||||
SendData(0x00);
|
||||
SendData(0x01);
|
||||
SendCommand(0x01); //Driver output control
|
||||
SendData(0xC7);
|
||||
SendData(0x00);
|
||||
SendData(0x01);
|
||||
|
||||
SendCommand(0x11); //data entry mode
|
||||
SendData(0x01);
|
||||
SendCommand(0x11); //data entry mode
|
||||
SendData(0x01);
|
||||
|
||||
SendCommand(0x44); //set Ram-X address start/end position
|
||||
SendData(0x00);
|
||||
SendData(0x18); //0x0C-->(18+1)*8=200
|
||||
SendCommand(0x44); //set Ram-X address start/end position
|
||||
SendData(0x00);
|
||||
SendData(0x18); //0x0C-->(18+1)*8=200
|
||||
|
||||
SendCommand(0x45); //set Ram-Y address start/end position
|
||||
SendData(0xC7); //0xC7-->(199+1)=200
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendCommand(0x45); //set Ram-Y address start/end position
|
||||
SendData(0xC7); //0xC7-->(199+1)=200
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(0x3C); //BorderWavefrom
|
||||
SendData(0x01);
|
||||
SendCommand(0x3C); //BorderWavefrom
|
||||
SendData(0x01);
|
||||
|
||||
SendCommand(0x18);
|
||||
SendData(0x80);
|
||||
SendCommand(0x18);
|
||||
SendData(0x80);
|
||||
|
||||
SendCommand(0x22); // //Load Temperature and waveform setting.
|
||||
SendData(0XB1);
|
||||
SendCommand(0x20);
|
||||
SendCommand(0x22); // //Load Temperature and waveform setting.
|
||||
SendData(0XB1);
|
||||
SendCommand(0x20);
|
||||
|
||||
SendCommand(0x4E); // set RAM x address count to 0;
|
||||
SendData(0x00);
|
||||
SendCommand(0x4F); // set RAM y address count to 0X199;
|
||||
SendData(0xC7);
|
||||
SendData(0x00);
|
||||
WaitUntilIdle();
|
||||
/* EPD hardware init end */
|
||||
SendCommand(0x4E); // set RAM x address count to 0;
|
||||
SendData(0x00);
|
||||
SendCommand(0x4F); // set RAM y address count to 0X199;
|
||||
SendData(0xC7);
|
||||
SendData(0x00);
|
||||
WaitUntilIdle();
|
||||
/* EPD hardware init end */
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Epd::LDirInit(void)
|
||||
{
|
||||
/* this calls the peripheral hardware interface, see epdif */
|
||||
if (IfInit() != 0) {
|
||||
return -1;
|
||||
}
|
||||
/* EPD hardware init start */
|
||||
Reset();
|
||||
|
||||
WaitUntilIdle();
|
||||
SendCommand(0x12); //SWRESET
|
||||
WaitUntilIdle();
|
||||
|
||||
SendCommand(0x01); //Driver output control
|
||||
SendData(0xC7);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(0x11); //data entry mode
|
||||
SendData(0x03);
|
||||
|
||||
SendCommand(0x44); //set Ram-X address start/end position
|
||||
SendData(0x00);
|
||||
SendData(0x18); //0x0C-->(18+1)*8=200
|
||||
|
||||
SendCommand(0x45); //set Ram-Y address start/end position
|
||||
SendData(0xC7); //0xC7-->(199+1)=200
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(0x3C); //BorderWavefrom
|
||||
SendData(0x01);
|
||||
|
||||
SendCommand(0x18);
|
||||
SendData(0x80);
|
||||
|
||||
SendCommand(0x22); // //Load Temperature and waveform setting.
|
||||
SendData(0XB1);
|
||||
SendCommand(0x20);
|
||||
|
||||
SendCommand(0x4E); // set RAM x address count to 0;
|
||||
SendData(0x00);
|
||||
SendCommand(0x4F); // set RAM y address count to 0X199;
|
||||
SendData(0xC7);
|
||||
SendData(0x00);
|
||||
WaitUntilIdle();
|
||||
/* EPD hardware init end */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief: module reset.
|
||||
* often used to awaken the module in deep sleep,
|
||||
|
|
@ -132,101 +185,227 @@ int Epd::Init(void)
|
|||
*/
|
||||
void Epd::Reset(void)
|
||||
{
|
||||
DigitalWrite(reset_pin, HIGH);
|
||||
DelayMs(200);
|
||||
DigitalWrite(reset_pin, LOW); //module reset
|
||||
DelayMs(10);
|
||||
DigitalWrite(reset_pin, HIGH);
|
||||
DelayMs(200);
|
||||
DigitalWrite(reset_pin, HIGH);
|
||||
DelayMs(200);
|
||||
DigitalWrite(reset_pin, LOW); //module reset
|
||||
DelayMs(20);
|
||||
DigitalWrite(reset_pin, HIGH);
|
||||
DelayMs(200);
|
||||
}
|
||||
|
||||
void Epd::Clear(void)
|
||||
{
|
||||
int w, h;
|
||||
w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
|
||||
h = EPD_HEIGHT;
|
||||
SendCommand(0x24);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(0xff);
|
||||
}
|
||||
}
|
||||
int w, h;
|
||||
w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
|
||||
h = EPD_HEIGHT;
|
||||
SendCommand(0x24);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(0xff);
|
||||
}
|
||||
}
|
||||
|
||||
//DISPLAY REFRESH
|
||||
SendCommand(0x22);
|
||||
SendData(0xF7);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
//DISPLAY REFRESH
|
||||
SendCommand(0x22);
|
||||
SendData(0xF7);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
void Epd::Display(const unsigned char* frame_buffer)
|
||||
{
|
||||
int w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
|
||||
int h = EPD_HEIGHT;
|
||||
int w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
|
||||
int h = EPD_HEIGHT;
|
||||
|
||||
if (frame_buffer != NULL) {
|
||||
SendCommand(0x24);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(pgm_read_byte(&frame_buffer[i + j * w]));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (frame_buffer != NULL) {
|
||||
SendCommand(0x24);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(pgm_read_byte(&frame_buffer[i + j * w]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//DISPLAY REFRESH
|
||||
SendCommand(0x22);
|
||||
SendData(0xF7);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
//DISPLAY REFRESH
|
||||
SendCommand(0x22);
|
||||
SendData(0xF7);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
void Epd::DisplayPartBaseImage(const unsigned char* frame_buffer)
|
||||
{
|
||||
int w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
|
||||
int h = EPD_HEIGHT;
|
||||
int w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
|
||||
int h = EPD_HEIGHT;
|
||||
|
||||
if (frame_buffer != NULL) {
|
||||
SendCommand(0x24);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(frame_buffer[i + j * w]);
|
||||
}
|
||||
}
|
||||
if (frame_buffer != NULL) {
|
||||
SendCommand(0x24);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(pgm_read_byte(&frame_buffer[i + j * w]));
|
||||
}
|
||||
}
|
||||
|
||||
SendCommand(0x26);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(frame_buffer[i + j * w]);
|
||||
}
|
||||
}
|
||||
}
|
||||
SendCommand(0x26);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(pgm_read_byte(&frame_buffer[i + j * w]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//DISPLAY REFRESH
|
||||
SendCommand(0x22);
|
||||
SendData(0xFF);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
//DISPLAY REFRESH
|
||||
SendCommand(0x22);
|
||||
SendData(0xFF);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
void Epd::DisplayPartBaseWhiteImage(void)
|
||||
{
|
||||
int w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
|
||||
int h = EPD_HEIGHT;
|
||||
|
||||
SendCommand(0x24);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(0xff);
|
||||
}
|
||||
}
|
||||
|
||||
SendCommand(0x26);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(0xff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//DISPLAY REFRESH
|
||||
SendCommand(0x22);
|
||||
SendData(0xFF);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
|
||||
void Epd::DisplayPart(const unsigned char* frame_buffer)
|
||||
{
|
||||
int w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
|
||||
int h = EPD_HEIGHT;
|
||||
int w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
|
||||
int h = EPD_HEIGHT;
|
||||
|
||||
if (frame_buffer != NULL) {
|
||||
SendCommand(0x24);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(frame_buffer[i + j * w]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (frame_buffer != NULL) {
|
||||
SendCommand(0x24);
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
SendData(pgm_read_byte(&frame_buffer[i + j * w]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//DISPLAY REFRESH
|
||||
SendCommand(0x22);
|
||||
SendData(0xFF);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
//DISPLAY REFRESH
|
||||
SendCommand(0x22);
|
||||
SendData(0xFF);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief: private function to specify the memory area for data R/W
|
||||
*/
|
||||
void Epd::SetMemoryArea(int x_start, int y_start, int x_end, int y_end)
|
||||
{
|
||||
SendCommand(0x44);
|
||||
/* x point must be the multiple of 8 or the last 3 bits will be ignored */
|
||||
SendData((x_start >> 3) & 0xFF);
|
||||
SendData((x_end >> 3) & 0xFF);
|
||||
SendCommand(0x45);
|
||||
SendData(y_start & 0xFF);
|
||||
SendData((y_start >> 8) & 0xFF);
|
||||
SendData(y_end & 0xFF);
|
||||
SendData((y_end >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: private function to specify the start point for data R/W
|
||||
*/
|
||||
void Epd::SetMemoryPointer(int x, int y)
|
||||
{
|
||||
SendCommand(0x4e);
|
||||
/* x point must be the multiple of 8 or the last 3 bits will be ignored */
|
||||
SendData((x >> 3) & 0xFF);
|
||||
SendCommand(0x4F);
|
||||
SendData(y & 0xFF);
|
||||
SendData((y >> 8) & 0xFF);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief: update the display
|
||||
* there are 2 memory areas embedded in the e-paper display
|
||||
* but once this function is called,
|
||||
* the the next action of SetFrameMemory or ClearFrame will
|
||||
* set the other memory area.
|
||||
*/
|
||||
void Epd::DisplayFrame(void)
|
||||
{
|
||||
//DISPLAY REFRESH
|
||||
SendCommand(0x22);
|
||||
SendData(0xF7);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
void Epd::DisplayPartFrame(void)
|
||||
{
|
||||
SendCommand(0x22);
|
||||
SendData(0xFF);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
|
||||
void Epd::SetFrameMemory(
|
||||
const unsigned char* image_buffer,
|
||||
int x,
|
||||
int y,
|
||||
int image_width,
|
||||
int image_height
|
||||
)
|
||||
{
|
||||
int x_end;
|
||||
int y_end;
|
||||
|
||||
if (
|
||||
image_buffer == NULL ||
|
||||
x < 0 || image_width < 0 ||
|
||||
y < 0 || image_height < 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
/* x point must be the multiple of 8 or the last 3 bits will be ignored */
|
||||
x &= 0xF8;
|
||||
image_width &= 0xF8;
|
||||
if (x + image_width >= this->width) {
|
||||
x_end = this->width - 1;
|
||||
} else {
|
||||
x_end = x + image_width - 1;
|
||||
}
|
||||
if (y + image_height >= this->height) {
|
||||
y_end = this->height - 1;
|
||||
} else {
|
||||
y_end = y + image_height - 1;
|
||||
}
|
||||
SetMemoryArea(x, y, x_end, y_end);
|
||||
SetMemoryPointer(x, y);
|
||||
SendCommand(0x24);
|
||||
/* send the image data */
|
||||
for (int j = 0; j < y_end - y + 1; j++) {
|
||||
for (int i = 0; i < (x_end - x + 1) / 8; i++) {
|
||||
SendData(image_buffer[i + j * (image_width / 8)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -239,11 +418,11 @@ void Epd::DisplayPart(const unsigned char* frame_buffer)
|
|||
*/
|
||||
void Epd::Sleep()
|
||||
{
|
||||
SendCommand(0x10); //enter deep sleep
|
||||
SendData(0x01);
|
||||
DelayMs(200);
|
||||
SendCommand(0x10); //enter deep sleep
|
||||
SendData(0x01);
|
||||
DelayMs(200);
|
||||
|
||||
DigitalWrite(reset_pin, LOW);
|
||||
DigitalWrite(reset_pin, LOW);
|
||||
}
|
||||
|
||||
/* END OF FILE */
|
||||
|
|
|
|||
|
|
@ -37,29 +37,45 @@
|
|||
#define EPD_WIDTH 200
|
||||
#define EPD_HEIGHT 200
|
||||
|
||||
class Epd : EpdIf {
|
||||
class Epd : EpdIf
|
||||
{
|
||||
public:
|
||||
unsigned long width;
|
||||
unsigned long height;
|
||||
unsigned long width;
|
||||
unsigned long height;
|
||||
|
||||
Epd();
|
||||
~Epd();
|
||||
int Init(void);
|
||||
void SendCommand(unsigned char command);
|
||||
void SendData(unsigned char data);
|
||||
void WaitUntilIdle(void);
|
||||
void Reset(void);
|
||||
void Clear(void);
|
||||
void Display(const unsigned char* frame_buffer);
|
||||
void DisplayPartBaseImage(const unsigned char* frame_buffer);
|
||||
void DisplayPart(const unsigned char* frame_buffer);
|
||||
|
||||
void Sleep(void);
|
||||
Epd();
|
||||
~Epd();
|
||||
// int Init(void);
|
||||
int LDirInit(void);
|
||||
int HDirInit(void);
|
||||
void SendCommand(unsigned char command);
|
||||
void SendData(unsigned char data);
|
||||
void WaitUntilIdle(void);
|
||||
void Reset(void);
|
||||
void Clear(void);
|
||||
void Display(const unsigned char* frame_buffer);
|
||||
void DisplayPartBaseImage(const unsigned char* frame_buffer);
|
||||
void DisplayPartBaseWhiteImage(void);
|
||||
void DisplayPart(const unsigned char* frame_buffer);
|
||||
void SetFrameMemory(
|
||||
const unsigned char* image_buffer,
|
||||
int x,
|
||||
int y,
|
||||
int image_width,
|
||||
int image_height
|
||||
);
|
||||
void DisplayFrame(void);
|
||||
void DisplayPartFrame(void);
|
||||
|
||||
void Sleep(void);
|
||||
private:
|
||||
unsigned int reset_pin;
|
||||
unsigned int dc_pin;
|
||||
unsigned int cs_pin;
|
||||
unsigned int busy_pin;
|
||||
unsigned int reset_pin;
|
||||
unsigned int dc_pin;
|
||||
unsigned int cs_pin;
|
||||
unsigned int busy_pin;
|
||||
|
||||
void SetMemoryArea(int x_start, int y_start, int x_end, int y_end);
|
||||
void SetMemoryPointer(int x, int y);
|
||||
};
|
||||
|
||||
#endif /* EPD1IN54B_H */
|
||||
|
|
|
|||
|
|
@ -1,32 +1,92 @@
|
|||
#include <SPI.h>
|
||||
#include "epd1in54_V2.h"
|
||||
#include "imagedata.h"
|
||||
#include "epdpaint.h"
|
||||
#include <stdio.h>
|
||||
|
||||
Epd epd;
|
||||
unsigned char image[1024];
|
||||
Paint paint(image, 0, 0);
|
||||
|
||||
unsigned long time_start_ms;
|
||||
unsigned long time_now_s;
|
||||
#define COLORED 0
|
||||
#define UNCOLORED 1
|
||||
|
||||
void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(9600);
|
||||
if (epd.Init() != 0) {
|
||||
Serial.println("e-Paper init failed");
|
||||
return;
|
||||
}
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(9600);
|
||||
Serial.println("e-Paper init and clear");
|
||||
epd.LDirInit();
|
||||
epd.Clear();
|
||||
|
||||
Serial.println("e-Paper clear");
|
||||
epd.Clear();
|
||||
paint.SetWidth(200);
|
||||
paint.SetHeight(24);
|
||||
|
||||
Serial.println("e-Paper show pic");
|
||||
epd.Display(IMAGE_DATA);
|
||||
Serial.println("e-Paper paint");
|
||||
paint.Clear(COLORED);
|
||||
paint.DrawStringAt(30, 4, "Hello world!", &Font16, UNCOLORED);
|
||||
epd.SetFrameMemory(paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight());
|
||||
|
||||
Serial.println("e-Paper clear and sleep");
|
||||
epd.Clear();
|
||||
epd.Sleep();
|
||||
paint.Clear(UNCOLORED);
|
||||
paint.DrawStringAt(30, 4, "e-Paper Demo", &Font16, COLORED);
|
||||
epd.SetFrameMemory(paint.GetImage(), 0, 30, paint.GetWidth(), paint.GetHeight());
|
||||
|
||||
paint.SetWidth(64);
|
||||
paint.SetHeight(64);
|
||||
|
||||
paint.Clear(UNCOLORED);
|
||||
paint.DrawRectangle(0, 0, 40, 50, COLORED);
|
||||
paint.DrawLine(0, 0, 40, 50, COLORED);
|
||||
paint.DrawLine(40, 0, 0, 50, COLORED);
|
||||
epd.SetFrameMemory(paint.GetImage(), 16, 60, paint.GetWidth(), paint.GetHeight());
|
||||
|
||||
paint.Clear(UNCOLORED);
|
||||
paint.DrawCircle(32, 32, 30, COLORED);
|
||||
epd.SetFrameMemory(paint.GetImage(), 120, 60, paint.GetWidth(), paint.GetHeight());
|
||||
|
||||
paint.Clear(UNCOLORED);
|
||||
paint.DrawFilledRectangle(0, 0, 40, 50, COLORED);
|
||||
epd.SetFrameMemory(paint.GetImage(), 16, 130, paint.GetWidth(), paint.GetHeight());
|
||||
|
||||
paint.Clear(UNCOLORED);
|
||||
paint.DrawFilledCircle(32, 32, 30, COLORED);
|
||||
epd.SetFrameMemory(paint.GetImage(), 120, 130, paint.GetWidth(), paint.GetHeight());
|
||||
epd.DisplayFrame();
|
||||
delay(2000);
|
||||
|
||||
Serial.println("e-Paper show pic");
|
||||
epd.HDirInit();
|
||||
epd.Display(IMAGE_DATA);
|
||||
|
||||
//Part display
|
||||
epd.HDirInit();
|
||||
epd.Clear();
|
||||
epd.DisplayPartBaseWhiteImage();
|
||||
|
||||
//paint.SetRotate(90);
|
||||
paint.SetWidth(200);
|
||||
paint.SetHeight(20);
|
||||
paint.Clear(UNCOLORED);
|
||||
|
||||
char i = 0;
|
||||
char str[10][10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
|
||||
for (i = 0; i < 10; i++) {
|
||||
paint.Clear(UNCOLORED);
|
||||
paint.DrawStringAt(0, 0, str[i], &Font24, COLORED);
|
||||
epd.SetFrameMemory(paint.GetImage(), 20, 20, paint.GetWidth(), paint.GetHeight());
|
||||
epd.DisplayPartFrame();
|
||||
delay(200);
|
||||
}
|
||||
|
||||
Serial.println("e-Paper clear and goto sleep");
|
||||
epd.HDirInit();
|
||||
epd.Clear();
|
||||
epd.Sleep();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,8 @@ int EpdIf::IfInit(void) {
|
|||
pinMode(RST_PIN, OUTPUT);
|
||||
pinMode(DC_PIN, OUTPUT);
|
||||
pinMode(BUSY_PIN, INPUT);
|
||||
|
||||
|
||||
SPI.begin();
|
||||
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -317,26 +317,3 @@ void Paint::DrawFilledCircle(int x, int y, int radius, int colored) {
|
|||
}
|
||||
|
||||
/* END OF FILE */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue