Skip to content

Commit 4822c07

Browse files
committed
Added new programs 13.3inch e-Paper (K) routine
1 parent 8316a45 commit 4822c07

159 files changed

Lines changed: 43054 additions & 4588 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Arduino/epd13in3k/epd13in3k.cpp

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
/**
2+
* @filename : epd13in3k.cpp
3+
* @brief : Implements for e-paper library
4+
* @author : Yehui from Waveshare
5+
*
6+
* Copyright (C) Waveshare September 25 2023
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documnetation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include <stdlib.h>
28+
#include "epd13in3k.h"
29+
30+
Epd::~Epd() {
31+
};
32+
33+
Epd::Epd() {
34+
reset_pin = RST_PIN;
35+
dc_pin = DC_PIN;
36+
cs_pin = CS_PIN;
37+
busy_pin = BUSY_PIN;
38+
width = EPD_WIDTH;
39+
height = EPD_HEIGHT;
40+
};
41+
42+
int Epd::Init(void) {
43+
if (IfInit() != 0) {
44+
return -1;
45+
}
46+
Reset();
47+
ReadBusy();
48+
49+
SendCommand(0x12);
50+
ReadBusy();
51+
52+
SendCommand(0x0C);
53+
SendData(0xAE);
54+
SendData(0xC7);
55+
SendData(0xC3);
56+
SendData(0xC0);
57+
SendData(0x80);
58+
59+
SendCommand(0x01);
60+
SendData(0xA7);
61+
SendData(0x02);
62+
SendData(0x00);
63+
64+
SendCommand(0x11);
65+
SendData(0x03);
66+
67+
SendCommand(0x44);
68+
SendData(0x00);
69+
SendData(0x00);
70+
SendData(0xBF);
71+
SendData(0x03);
72+
73+
SendCommand(0x45);
74+
SendData(0x00);
75+
SendData(0x00);
76+
SendData(0xA7);
77+
SendData(0x02);
78+
79+
SendCommand(0x3C);
80+
SendData(0x05);
81+
82+
SendCommand(0x18);
83+
SendData(0x80);
84+
85+
SendCommand(0x4E);
86+
SendData(0x00);
87+
88+
SendCommand(0x4F);
89+
SendData(0x00);
90+
SendData(0x00);
91+
92+
return 0;
93+
}
94+
95+
/**
96+
* @brief: basic function for sending commands
97+
*/
98+
void Epd::SendCommand(unsigned char command) {
99+
DigitalWrite(dc_pin, LOW);
100+
SpiTransfer(command);
101+
}
102+
103+
/**
104+
* @brief: basic function for sending data
105+
*/
106+
void Epd::SendData(unsigned char data) {
107+
DigitalWrite(dc_pin, HIGH);
108+
SpiTransfer(data);
109+
}
110+
111+
/**
112+
* @brief: Wait until the busy_pin goes HIGH
113+
*/
114+
void Epd::ReadBusy(void) {
115+
unsigned char busy;
116+
Serial.print("e-Paper Busy\r\n ");
117+
do{
118+
DelayMs(20);
119+
busy = DigitalRead(busy_pin);
120+
}while(busy == 1);
121+
Serial.print("e-Paper Busy Release\r\n ");
122+
DelayMs(20);
123+
}
124+
125+
/**
126+
* @brief: Refresh function
127+
*/
128+
void Epd::TurnOnDisplay(void) {
129+
SendCommand(0x22);
130+
SendData(0xF7);
131+
SendCommand(0x20);
132+
ReadBusy();
133+
}
134+
135+
/**
136+
* @brief: module reset.
137+
* often used to awaken the module in deep sleep,
138+
* see Epd::Sleep();
139+
*/
140+
void Epd::Reset(void) {
141+
DigitalWrite(reset_pin, HIGH);
142+
DelayMs(20);
143+
DigitalWrite(reset_pin, LOW); //module reset
144+
DelayMs(4);
145+
DigitalWrite(reset_pin, HIGH);
146+
DelayMs(20);
147+
}
148+
149+
void Epd::DisplayFrame(const unsigned char* frame_buffer) {
150+
151+
SendCommand(0x24);
152+
for (unsigned long j = 0; j < height; j++) {
153+
for (unsigned long i = 0; i < width/8; i++) {
154+
SendData(frame_buffer[i + j * width/8]);
155+
}
156+
}
157+
TurnOnDisplay();
158+
}
159+
160+
void Epd::Displaypart(const unsigned char* pbuffer, unsigned long xStart, unsigned long yStart,unsigned long Picture_Width,unsigned long Picture_Height) {
161+
SendCommand(0x24);
162+
for (unsigned long j = 0; j < height; j++) {
163+
for (unsigned long i = 0; i < width/8; i++) {
164+
if( (j>=yStart) && (j<yStart+Picture_Height) && (i*8>=xStart) && (i*8<xStart+Picture_Width)){
165+
SendData((pgm_read_byte(&(pbuffer[i-xStart/8 + (Picture_Width)/8*(j-yStart)]))) );
166+
// SendData(0xff);
167+
}else {
168+
SendData(0xFF);
169+
}
170+
}
171+
}
172+
TurnOnDisplay();
173+
}
174+
175+
/**
176+
* @brief: After this command is transmitted, the chip would enter the
177+
* deep-sleep mode to save power.
178+
* The deep sleep mode would return to standby by hardware reset.
179+
* The only one parameter is a check code, the command would be
180+
* executed if check code = 0xA5.
181+
* You can use EPD_Reset() to awaken
182+
*/
183+
void Epd::Sleep(void) {
184+
SendCommand(0x10);
185+
SendData(0x01);
186+
DelayMs(100);
187+
ReadBusy();
188+
}
189+
190+
void Epd::Clear(void) {
191+
192+
SendCommand(0x24);
193+
for(unsigned long i=0; i<height*width/8; i++) {
194+
SendData(0xFF);
195+
}
196+
TurnOnDisplay();
197+
}
198+
199+
200+
/* END OF FILE */
201+
202+

Arduino/epd13in3k/epd13in3k.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* @filename : epd13in3k.h
3+
* @brief : Header file for e-paper library epd7in5.cpp
4+
* @author : Yehui from Waveshare
5+
*
6+
* Copyright (C) Waveshare September 25 2023
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documnetation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef EPD13IN3_H
28+
#define EPD13IN3_H
29+
30+
#include "epdif.h"
31+
32+
// Display resolution
33+
#define EPD_WIDTH 960
34+
#define EPD_HEIGHT 680
35+
36+
class Epd : EpdIf {
37+
public:
38+
Epd();
39+
~Epd();
40+
int Init(void);
41+
void ReadBusy(void);
42+
void Reset(void);
43+
void TurnOnDisplay(void);
44+
void DisplayFrame(const unsigned char* frame_buffer);
45+
void SendCommand(unsigned char command);
46+
void SendData(unsigned char data);
47+
void Sleep(void);
48+
void Clear(void);
49+
void Epd::Displaypart(const unsigned char* pbuffer, unsigned long Start_X, unsigned long Start_Y,unsigned long END_X,unsigned long END_Y);
50+
51+
private:
52+
unsigned int reset_pin;
53+
unsigned int dc_pin;
54+
unsigned int cs_pin;
55+
unsigned int busy_pin;
56+
unsigned long width;
57+
unsigned long height;
58+
};
59+
60+
#endif /* EPD7IN5_H */
61+
62+
/* END OF FILE */

Arduino/epd13in3k/epd13in3k.ino

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* @filename : epd13in3k-demo.ino
3+
* @brief : 7.5inch e-paper display demo
4+
* @author : Yehui from Waveshare
5+
*
6+
* Copyright (C) Waveshare September 25 2023
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documnetation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include <SPI.h>
28+
#include "epd13in3k.h"
29+
#include "imagedata.h"
30+
31+
void setup() {
32+
// put your setup code here, to run once:
33+
Serial.begin(115200);
34+
Epd epd;
35+
Serial.print("e-Paper init \r\n ");
36+
if (epd.Init() != 0) {
37+
Serial.print("e-Paper init failed\r\n ");
38+
return;
39+
}
40+
41+
Serial.print("e-Paper Display\r\n ");
42+
epd.Displaypart(IMAGE_DATA,250, 200,240,103);
43+
44+
Serial.print("e-Paper Clear\r\n ");
45+
epd.Clear();
46+
47+
epd.Sleep();
48+
}
49+
50+
void loop() {
51+
// put your main code here, to run repeatedly:
52+
53+
}

Arduino/epd13in3k/epdif.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* @filename : epdif.cpp
3+
* @brief : Implements EPD interface functions
4+
* Users have to implement all the functions in epdif.cpp
5+
* @author : Yehui from Waveshare
6+
*
7+
* Copyright (C) Waveshare August 10 2017
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documnetation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furished to do so, subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in
17+
* all copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
#include "epdif.h"
29+
#include <SPI.h>
30+
31+
EpdIf::EpdIf() {
32+
};
33+
34+
EpdIf::~EpdIf() {
35+
};
36+
37+
void EpdIf::DigitalWrite(int pin, int value) {
38+
digitalWrite(pin, value);
39+
}
40+
41+
int EpdIf::DigitalRead(int pin) {
42+
return digitalRead(pin);
43+
}
44+
45+
void EpdIf::DelayMs(unsigned int delaytime) {
46+
delay(delaytime);
47+
}
48+
49+
void EpdIf::SpiTransfer(unsigned char data) {
50+
digitalWrite(CS_PIN, LOW);
51+
SPI.transfer(data);
52+
digitalWrite(CS_PIN, HIGH);
53+
}
54+
55+
int EpdIf::IfInit(void) {
56+
pinMode(CS_PIN, OUTPUT);
57+
pinMode(RST_PIN, OUTPUT);
58+
pinMode(DC_PIN, OUTPUT);
59+
pinMode(BUSY_PIN, INPUT);
60+
61+
pinMode(PWR_PIN, OUTPUT);
62+
DigitalWrite(PWR_PIN, 1);
63+
64+
SPI.begin();
65+
SPI.beginTransaction(SPISettings(7000000, MSBFIRST, SPI_MODE0));
66+
return 0;
67+
}
68+

0 commit comments

Comments
 (0)