-
Notifications
You must be signed in to change notification settings - Fork 0
/
ePaper_029TestCode.ino
115 lines (101 loc) · 6.27 KB
/
ePaper_029TestCode.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <SPI.h>
//EPD
#include "Display_EPD_W21_spi.h"
#include "Display_EPD_W21.h"
#include "Ap_29demo.h"
void setup() {
pinMode(D5, INPUT); //BUSY
pinMode(D0, OUTPUT); //RES
pinMode(D3, OUTPUT); //DC
pinMode(D1, OUTPUT); //CS
//SPI
SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
SPI.begin ();
}
//Tips//
/*
1.Flickering is normal when EPD is performing a full screen update to clear ghosting from the previous image so to ensure better clarity and legibility for the new image.
2.There will be no flicker when EPD performs a partial refresh.
3.Please make sue that EPD enters sleep mode when refresh is completed and always leave the sleep mode command. Otherwise, this may result in a reduced lifespan of EPD.
4.Please refrain from inserting EPD to the FPC socket or unplugging it when the MCU is being powered to prevent potential damage.)
5.Re-initialization is required for every full screen update.
6.When porting the program, set the BUSY pin to input mode and other pins to output mode.
*/
void loop() {
unsigned char i;
#if 1 //Full screen refresh, fast refresh, and partial refresh demostration.
EPD_HW_Init(); //Full screen refresh initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Full display(2s)*******************/
EPD_HW_Init(); //Full screen refresh initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen refresh.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast refresh mode(1.5s)*******************/
EPD_HW_Init_Fast(); //Fast refresh initialization.
EPD_WhiteScreen_ALL_Fast(gImage_1); //To display one image using fast refresh.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_HW_Init_Fast(); //Fast refresh initialization.
EPD_WhiteScreen_ALL_Fast(gImage_2); //To display the second image using fast refresh.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
/************Fast refresh mode(1s)*******************/
#if 1 //To enable this feature, please change 0 to 1
/************Onder versions do not support this feature*******************/
EPD_HW_Init_Fast2(); //Fast refresh initialization.
EPD_WhiteScreen_ALL_Fast2(gImage_1); //To display one image using fast refresh.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(1000); //Delay for 1s.
EPD_HW_Init_Fast2(); //EPD init Fast
EPD_WhiteScreen_ALL_Fast2(gImage_2); //To display the second image using fast refresh.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(1000); //Delay for 1s.
#endif
#if 1 //Partial refresh demostration.
//Partial refresh demo support displaying a clock at 5 locations with 00:00. If you need to perform partial refresh more than 5 locations, please use the feature of using partial refresh at the full screen demo.
//After 5 partial refreshes, implement a full screen refresh to clear the ghosting caused by partial refreshes.
//////////////////////Partial refresh time demo/////////////////////////////////////
EPD_HW_Init(); //Electronic paper initialization.
EPD_SetRAMValue_BaseMap(gImage_basemap); //Please do not delete the background color function, otherwise it will cause unstable display during partial refresh.
for(i=0;i<6;i++)
EPD_Dis_Part_Time(32,92+32*0,Num[i], //x-A,y-A,DATA-A
32,92+32*1,Num[0], //x-B,y-B,DATA-B
32,92+32*2,gImage_numdot, //x-C,y-C,DATA-C
32,92+32*3,Num[0], //x-D,y-D,DATA-D
32,92+32*4,Num[1],32,64); //x-E,y-E,DATA-E,Resolution 32*64
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_HW_Init(); //Full screen refresh initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
#endif
#if 0 //Demo of using partial refresh to update the full screen, to enable this feature, please change 0 to 1.
//After 5 partial refreshes, implement a full screen refresh to clear the ghosting caused by partial refreshes.
//////////////////////Partial refresh time demo/////////////////////////////////////
EPD_HW_Init(); //E-paper initialization
EPD_SetRAMValue_BaseMap(gImage_p1); //Please do not delete the background color function, otherwise it will cause an unstable display during partial refresh.
EPD_Dis_PartAll(gImage_p1); //Image 1
EPD_Dis_PartAll(gImage_p2); //Image 2
EPD_Dis_PartAll(gImage_p3); //Image 3
EPD_Dis_PartAll(gImage_p4); //Image 4
EPD_Dis_PartAll(gImage_p5); //Image 5
EPD_DeepSleep();//Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
EPD_HW_Init(); //Full screen refresh initialization.
EPD_WhiteScreen_White(); //Clear screen function.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
#endif
#if 0 //Demonstration of full screen refresh with 180-degree rotation, to enable this feature, please change 0 to 1.
/************Full display(2s)*******************/
EPD_HW_Init_180(); //Full screen refresh initialization.
EPD_WhiteScreen_ALL(gImage_1); //To Display one image using full screen refresh.
EPD_DeepSleep(); //Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
delay(2000); //Delay for 2s.
#endif
#endif
while(1); // The program stops here
}
//////////////////////////////////END//////////////////////////////////////////////////