Skip to content

Commit ecdd8cf

Browse files
committed
Add 13.3inch e-Paper (E)
1 parent af4d8b4 commit ecdd8cf

File tree

1,411 files changed

+883717
-0
lines changed

Some content is hidden

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

1,411 files changed

+883717
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#include "EPD_13in3e.h"
2+
#include "GUI_Paint.h"
3+
#include "fonts.h"
4+
#include "ImageData.h"
5+
6+
void setup() {
7+
Debug("EPD_13IN3E_test Demo\r\n");
8+
DEV_Module_Init();
9+
10+
Debug("e-Paper Init and Clear...\r\n");
11+
EPD_13IN3E_Init();
12+
EPD_13IN3E_Clear(EPD_13IN3E_WHITE);
13+
DEV_Delay_ms(500);
14+
15+
//Create a new image cache named IMAGE_BW and fill it with white
16+
UBYTE *Image;
17+
UWORD Imagesize = ((EPD_13IN3E_WIDTH % 2 == 0)? (EPD_13IN3E_WIDTH / 2 ): (EPD_13IN3E_WIDTH / 2 + 1)) * EPD_13IN3E_HEIGHT;
18+
if((Image = (UBYTE *)malloc(20000)) == NULL) {
19+
Debug("Failed to apply for black memory...\r\n");
20+
DEV_Module_Exit();
21+
while(1);
22+
}
23+
Debug("NewImage:Image\r\n");
24+
Paint_NewImage(Image, 200, 200, 0, WHITE);
25+
26+
//Select Image
27+
Paint_SelectImage(Image);
28+
Paint_Clear(WHITE);
29+
30+
#if 1 // show bmp
31+
printf("show bmp1-----------------\r\n");
32+
EPD_13IN3E_DisplayPart(BMP_1, 400, 500, 400, 600);
33+
DEV_Delay_ms(3000);
34+
#else // Drawing on the image
35+
Paint_NewImage(Image, 200, 200, 90, EPD_13IN3E_WHITE);
36+
Paint_SetScale(6);
37+
// 1.Select Image
38+
Debug("SelectImage:Image\r\n");
39+
Paint_SelectImage(Image);
40+
Paint_Clear(EPD_13IN3E_WHITE);
41+
42+
// 2.Drawing on the image
43+
Debug("Drawing:Image\r\n");
44+
Paint_DrawPoint(10, 80, EPD_13IN3E_RED, DOT_PIXEL_1X1, DOT_STYLE_DFT);
45+
Paint_DrawPoint(10, 90, EPD_13IN3E_BLUE, DOT_PIXEL_2X2, DOT_STYLE_DFT);
46+
Paint_DrawPoint(10, 100, EPD_13IN3E_GREEN, DOT_PIXEL_3X3, DOT_STYLE_DFT);
47+
Paint_DrawLine(20, 70, 70, 120, EPD_13IN3E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
48+
Paint_DrawLine(70, 70, 20, 120, EPD_13IN3E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
49+
Paint_DrawRectangle(20, 70, 70, 120, EPD_13IN3E_BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
50+
Paint_DrawRectangle(80, 70, 130, 120, EPD_13IN3E_BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
51+
Paint_DrawCircle(45, 95, 20, EPD_13IN3E_BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
52+
Paint_DrawCircle(105, 95, 20, EPD_13IN3E_WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
53+
Paint_DrawLine(85, 95, 125, 95, EPD_13IN3E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
54+
Paint_DrawLine(105, 75, 105, 115, EPD_13IN3E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
55+
Paint_DrawString_CN(10, 130, "你好abc", &Font12CN, EPD_13IN3E_BLACK, EPD_13IN3E_WHITE);
56+
Paint_DrawString_CN(10, 150, "微雪电子", &Font24CN, EPD_13IN3E_WHITE, EPD_13IN3E_BLACK);
57+
Paint_DrawNum(10, 33, 123456789, &Font12, EPD_13IN3E_BLACK, EPD_13IN3E_WHITE);
58+
Paint_DrawNum(10, 50, 987654321, &Font16, EPD_13IN3E_WHITE, EPD_13IN3E_BLACK);
59+
Paint_DrawString_EN(145, 0, "Waveshare", &Font16, EPD_13IN3E_BLACK, EPD_13IN3E_WHITE);
60+
Paint_DrawString_EN(145, 35, "Waveshare", &Font16, EPD_13IN3E_GREEN, EPD_13IN3E_WHITE);
61+
Paint_DrawString_EN(145, 70, "Waveshare", &Font16, EPD_13IN3E_BLUE, EPD_13IN3E_WHITE);
62+
Paint_DrawString_EN(145, 105, "Waveshare", &Font16, EPD_13IN3E_RED, EPD_13IN3E_WHITE);
63+
Paint_DrawString_EN(145, 140, "Waveshare", &Font16, EPD_13IN3E_YELLOW, EPD_13IN3E_WHITE);
64+
65+
Debug("EPD_Display\r\n");
66+
EPD_13IN3E_DisplayPart(Image, 1000, 0, 200, 200);
67+
DEV_Delay_ms(3000);
68+
#endif
69+
70+
Debug("Clear...\r\n");
71+
EPD_13IN3E_Clear(EPD_13IN3E_WHITE);
72+
DEV_Delay_ms(2000);
73+
74+
Debug("Goto Sleep...\r\n");
75+
EPD_13IN3E_Sleep();
76+
free(Image);
77+
DEV_Delay_ms(2000);
78+
79+
// close 5V
80+
Debug("close 5V, Module enters 0 power consumption ...\r\n");
81+
DEV_Module_Exit();
82+
}
83+
84+
85+
void loop() {
86+
87+
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*****************************************************************************
2+
* | File : DEV_Config.c
3+
* | Author : Waveshare team
4+
* | Function : Hardware underlying interface
5+
* | Info :
6+
*----------------
7+
* | This version: V1.0
8+
* | Date : 2020-02-19
9+
* | Info :
10+
#
11+
# Permission is hereby granted, free of charge, to any person obtaining a copy
12+
# of this software and associated documnetation files (the "Software"), to deal
13+
# in the Software without restriction, including without limitation the rights
14+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
# copies of the Software, and to permit persons to whom the Software is
16+
# furished to do so, subject to the following conditions:
17+
#
18+
# The above copyright notice and this permission notice shall be included in
19+
# all copies or substantial portions of the Software.
20+
#
21+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27+
# THE SOFTWARE.
28+
#
29+
******************************************************************************/
30+
#include "DEV_Config.h"
31+
32+
void GPIO_Config(void)
33+
{
34+
pinMode(EPD_BUSY_PIN, INPUT);
35+
pinMode(EPD_RST_PIN , OUTPUT);
36+
pinMode(EPD_DC_PIN , OUTPUT);
37+
pinMode(EPD_PWR_PIN , OUTPUT);
38+
pinMode(EPD_CS_M_PIN , OUTPUT);
39+
pinMode(EPD_CS_S_PIN , OUTPUT);
40+
pinMode(EPD_SCK_PIN, OUTPUT);
41+
pinMode(EPD_MOSI_PIN, OUTPUT);
42+
43+
digitalWrite(EPD_PWR_PIN , HIGH);
44+
digitalWrite(EPD_CS_M_PIN , HIGH);
45+
digitalWrite(EPD_CS_S_PIN , HIGH);
46+
}
47+
48+
void GPIO_Mode(UWORD GPIO_Pin, UWORD Mode)
49+
{
50+
if(Mode == 0) {
51+
pinMode(GPIO_Pin , INPUT);
52+
} else {
53+
pinMode(GPIO_Pin , OUTPUT);
54+
}
55+
}
56+
/******************************************************************************
57+
function: Module Initialize, the BCM2835 library and initialize the pins, SPI protocol
58+
parameter:
59+
Info:
60+
******************************************************************************/
61+
UBYTE DEV_Module_Init(void)
62+
{
63+
//gpio
64+
GPIO_Config();
65+
66+
//serial printf
67+
Serial.begin(115200);
68+
69+
// // spi
70+
// SPI.begin();
71+
// SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
72+
73+
return 0;
74+
}
75+
76+
77+
void DEV_GPIO_Init(void)
78+
{
79+
SPI.end();
80+
pinMode(EPD_SCK_PIN, OUTPUT);
81+
pinMode(EPD_MOSI_PIN, OUTPUT);
82+
}
83+
84+
void DEV_SPI_Init(void)
85+
{
86+
SPI.begin();
87+
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
88+
}
89+
90+
91+
/******************************************************************************
92+
function:
93+
SPI read and write
94+
******************************************************************************/
95+
void DEV_SPI_WriteByte(UBYTE data)
96+
{
97+
SPI.transfer(data);
98+
}
99+
100+
void DEV_SPI_Write_nByte(UBYTE *pData, UDOUBLE len)
101+
{
102+
for (int i = 0; i < len; i++)
103+
DEV_SPI_WriteByte(pData[i]);
104+
}
105+
106+
void DEV_SPI_SendnByte(UBYTE *pData, UDOUBLE len)
107+
{
108+
for (int i = 0; i < len; i++)
109+
DEV_SPI_SendByte(pData[i]);
110+
}
111+
112+
void DEV_SPI_SendByte(UBYTE data)
113+
{
114+
for (int i = 0; i < 8; i++)
115+
{
116+
if ((data & 0x80) == 0) digitalWrite(EPD_MOSI_PIN, GPIO_PIN_RESET);
117+
else digitalWrite(EPD_MOSI_PIN, GPIO_PIN_SET);
118+
119+
data <<= 1;
120+
digitalWrite(EPD_SCK_PIN, GPIO_PIN_SET);
121+
digitalWrite(EPD_SCK_PIN, GPIO_PIN_RESET);
122+
}
123+
}
124+
125+
UBYTE DEV_SPI_ReadByte()
126+
{
127+
UBYTE j=0xff;
128+
GPIO_Mode(EPD_MOSI_PIN, INPUT);
129+
for (int i = 0; i < 8; i++)
130+
{
131+
j = j << 1;
132+
if (digitalRead(EPD_MOSI_PIN)) j = j | 0x01;
133+
else j = j & 0xfe;
134+
135+
digitalWrite(EPD_SCK_PIN, GPIO_PIN_SET);
136+
digitalWrite(EPD_SCK_PIN, GPIO_PIN_RESET);
137+
}
138+
GPIO_Mode(EPD_MOSI_PIN, 1);
139+
return j;
140+
}
141+
142+
143+
144+
145+
void DEV_Module_Exit(void)
146+
{
147+
digitalWrite(EPD_PWR_PIN , LOW);
148+
}
149+
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*****************************************************************************
2+
* | File : DEV_Config.h
3+
* | Author : Waveshare team
4+
* | Function : Hardware underlying interface
5+
* | Info :
6+
*----------------
7+
* | This version: V1.0
8+
* | Date : 2020-02-19
9+
* | Info :
10+
#
11+
# Permission is hereby granted, free of charge, to any person obtaining a copy
12+
# of this software and associated documnetation files (the "Software"), to deal
13+
# in the Software without restriction, including without limitation the rights
14+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
# copies of the Software, and to permit persons to whom the Software is
16+
# furished to do so, subject to the following conditions:
17+
#
18+
# The above copyright notice and this permission notice shall be included in
19+
# all copies or substantial portions of the Software.
20+
#
21+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27+
# THE SOFTWARE.
28+
#
29+
******************************************************************************/
30+
#ifndef _DEV_CONFIG_H_
31+
#define _DEV_CONFIG_H_
32+
33+
#include <Arduino.h>
34+
#include <stdint.h>
35+
#include <stdio.h>
36+
#include <SPI.h>
37+
38+
/**
39+
* data
40+
**/
41+
#define UBYTE uint8_t
42+
#define UWORD uint16_t
43+
#define UDOUBLE uint32_t
44+
45+
/**
46+
* GPIO config
47+
**/
48+
#define EPD_SCK_PIN 13
49+
#define EPD_MOSI_PIN 11
50+
#define EPD_CS_M_PIN 10
51+
#define EPD_CS_S_PIN 9
52+
#define EPD_DC_PIN 8
53+
#define EPD_RST_PIN 7
54+
#define EPD_BUSY_PIN 6
55+
#define EPD_PWR_PIN 5
56+
57+
#define GPIO_PIN_SET 1
58+
#define GPIO_PIN_RESET 0
59+
60+
/**
61+
* GPIO read and write
62+
**/
63+
#define DEV_Digital_Write(_pin, _value) digitalWrite(_pin, _value == 0? LOW:HIGH)
64+
#define DEV_Digital_Read(_pin) digitalRead(_pin)
65+
66+
/**
67+
* delay x ms
68+
**/
69+
#define DEV_Delay_ms(__xms) delay(__xms)
70+
71+
/*------------------------------------------------------------------------------------------------------*/
72+
UBYTE DEV_Module_Init(void);
73+
void DEV_GPIO_Init(void);
74+
void DEV_SPI_Init(void);
75+
76+
void GPIO_Mode(UWORD GPIO_Pin, UWORD Mode);
77+
void DEV_SPI_WriteByte(UBYTE data);
78+
void DEV_SPI_SendnByte(UBYTE *pData, UDOUBLE len);
79+
void DEV_SPI_SendByte(UBYTE data);
80+
UBYTE DEV_SPI_ReadByte();
81+
void DEV_SPI_Write_nByte(UBYTE *pData, UDOUBLE len);
82+
void DEV_Module_Exit(void);
83+
#endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*****************************************************************************
2+
* | File : Debug.h
3+
* | Author : Waveshare team
4+
* | Function : debug with printf
5+
* | Info :
6+
* Image scanning
7+
* Please use progressive scanning to generate images or fonts
8+
*----------------
9+
* | This version: V1.0
10+
* | Date : 2018-01-11
11+
* | Info : Basic version
12+
*
13+
******************************************************************************/
14+
#ifndef __DEBUG_H
15+
#define __DEBUG_H
16+
17+
#include <Wire.h>
18+
19+
#define USE_DEBUG 1
20+
#if USE_DEBUG
21+
#define Debug(__info) Serial.print(__info)
22+
#else
23+
#define Debug(__info)
24+
#endif
25+
26+
#endif
27+

0 commit comments

Comments
 (0)