epaper 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,215 @@
1
+ /******************************************************************************
2
+ * | File : GUI_Paint.h
3
+ * | Author : Waveshare electronics
4
+ * | Function : Achieve drawing: draw points, lines, boxes, circles and
5
+ * their size, solid dotted line, solid rectangle hollow
6
+ * rectangle, solid circle hollow circle.
7
+ * | Info :
8
+ * Achieve display characters: Display a single character, string, number
9
+ * Achieve time display: adaptive size display time minutes and seconds
10
+ *----------------
11
+ * | This version: V3.1
12
+ * | Date : 2019-10-10
13
+ * | Info :
14
+ * -----------------------------------------------------------------------------
15
+ * V3.1(2019-10-10):
16
+ * 1. Add gray level
17
+ * PAINT Add Scale
18
+ * 2. Add void Paint_SetScale(UBYTE scale);
19
+ *
20
+ * V3.0(2019-04-18):
21
+ * 1.Change:
22
+ * Paint_DrawPoint(..., DOT_STYLE DOT_STYLE)
23
+ * => Paint_DrawPoint(..., DOT_STYLE Dot_Style)
24
+ * Paint_DrawLine(..., LINE_STYLE Line_Style, DOT_PIXEL Dot_Pixel)
25
+ * => Paint_DrawLine(..., DOT_PIXEL Line_width, LINE_STYLE Line_Style)
26
+ * Paint_DrawRectangle(..., DRAW_FILL Filled, DOT_PIXEL Dot_Pixel)
27
+ * => Paint_DrawRectangle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
28
+ * Paint_DrawCircle(..., DRAW_FILL Draw_Fill, DOT_PIXEL Dot_Pixel)
29
+ * => Paint_DrawCircle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Filll)
30
+ *
31
+ * -----------------------------------------------------------------------------
32
+ * V2.0(2018-11-15):
33
+ * 1.add: Paint_NewImage()
34
+ * Create an image's properties
35
+ * 2.add: Paint_SelectImage()
36
+ * Select the picture to be drawn
37
+ * 3.add: Paint_SetRotate()
38
+ * Set the direction of the cache
39
+ * 4.add: Paint_RotateImage()
40
+ * Can flip the picture, Support 0-360 degrees,
41
+ * but only 90.180.270 rotation is better
42
+ * 4.add: Paint_SetMirroring()
43
+ * Can Mirroring the picture, horizontal, vertical, origin
44
+ * 5.add: Paint_DrawString_CN()
45
+ * Can display Chinese(GB1312)
46
+ *
47
+ * -----------------------------------------------------------------------------
48
+ * V1.0(2018-07-17):
49
+ * Create library
50
+ *
51
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
52
+ * of this software and associated documnetation files (the "Software"), to deal
53
+ * in the Software without restriction, including without limitation the rights
54
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
55
+ * copies of the Software, and to permit persons to whom the Software is
56
+ * furished to do so, subject to the following conditions:
57
+ *
58
+ * The above copyright notice and this permission notice shall be included in
59
+ * all copies or substantial portions of the Software.
60
+ *
61
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
63
+ * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
64
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
65
+ * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
66
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
67
+ * THE SOFTWARE.
68
+ *
69
+ ******************************************************************************/
70
+ #ifndef __GUI_PAINT_H
71
+ #define __GUI_PAINT_H
72
+
73
+ #include "DEV_Config.h"
74
+ #include "fonts.h"
75
+
76
+ /**
77
+ * Image attributes
78
+ **/
79
+ typedef struct {
80
+ UBYTE *Image;
81
+ UWORD Width;
82
+ UWORD Height;
83
+ UWORD WidthMemory;
84
+ UWORD HeightMemory;
85
+ UWORD Color;
86
+ UWORD Rotate;
87
+ UWORD Mirror;
88
+ UWORD WidthByte;
89
+ UWORD HeightByte;
90
+ UWORD Scale;
91
+ } PAINT;
92
+ extern PAINT Paint;
93
+
94
+ /**
95
+ * Display rotate
96
+ **/
97
+ #define ROTATE_0 0
98
+ #define ROTATE_90 90
99
+ #define ROTATE_180 180
100
+ #define ROTATE_270 270
101
+
102
+ /**
103
+ * Display Flip
104
+ **/
105
+ typedef enum {
106
+ MIRROR_NONE = 0x00,
107
+ MIRROR_HORIZONTAL = 0x01,
108
+ MIRROR_VERTICAL = 0x02,
109
+ MIRROR_ORIGIN = 0x03,
110
+ } MIRROR_IMAGE;
111
+ #define MIRROR_IMAGE_DFT MIRROR_NONE
112
+
113
+ /**
114
+ * image color
115
+ **/
116
+ #define WHITE 0xFF
117
+ #define BLACK 0x00
118
+ #define RED BLACK
119
+
120
+ #define IMAGE_BACKGROUND WHITE
121
+ #define FONT_FOREGROUND BLACK
122
+ #define FONT_BACKGROUND WHITE
123
+
124
+ //4 Gray level
125
+ #define GRAY1 0x03 //Blackest
126
+ #define GRAY2 0x02
127
+ #define GRAY3 0x01 //gray
128
+ #define GRAY4 0x00 //white
129
+ /**
130
+ * The size of the point
131
+ **/
132
+ typedef enum {
133
+ DOT_PIXEL_1X1 = 1, // 1 x 1
134
+ DOT_PIXEL_2X2 , // 2 X 2
135
+ DOT_PIXEL_3X3 , // 3 X 3
136
+ DOT_PIXEL_4X4 , // 4 X 4
137
+ DOT_PIXEL_5X5 , // 5 X 5
138
+ DOT_PIXEL_6X6 , // 6 X 6
139
+ DOT_PIXEL_7X7 , // 7 X 7
140
+ DOT_PIXEL_8X8 , // 8 X 8
141
+ } DOT_PIXEL;
142
+ #define DOT_PIXEL_DFT DOT_PIXEL_1X1 //Default dot pilex
143
+
144
+ /**
145
+ * Point size fill style
146
+ **/
147
+ typedef enum {
148
+ DOT_FILL_AROUND = 1, // dot pixel 1 x 1
149
+ DOT_FILL_RIGHTUP , // dot pixel 2 X 2
150
+ } DOT_STYLE;
151
+ #define DOT_STYLE_DFT DOT_FILL_AROUND //Default dot pilex
152
+
153
+ /**
154
+ * Line style, solid or dashed
155
+ **/
156
+ typedef enum {
157
+ LINE_STYLE_SOLID = 0,
158
+ LINE_STYLE_DOTTED,
159
+ } LINE_STYLE;
160
+
161
+ /**
162
+ * Whether the graphic is filled
163
+ **/
164
+ typedef enum {
165
+ DRAW_FILL_EMPTY = 0,
166
+ DRAW_FILL_FULL,
167
+ } DRAW_FILL;
168
+
169
+ /**
170
+ * Custom structure of a time attribute
171
+ **/
172
+ typedef struct {
173
+ UWORD Year; //0000
174
+ UBYTE Month; //1 - 12
175
+ UBYTE Day; //1 - 30
176
+ UBYTE Hour; //0 - 23
177
+ UBYTE Min; //0 - 59
178
+ UBYTE Sec; //0 - 59
179
+ } PAINT_TIME;
180
+ extern PAINT_TIME sPaint_time;
181
+
182
+ //init and Clear
183
+ void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color);
184
+ void Paint_SelectImage(UBYTE *image);
185
+ void Paint_SetRotate(UWORD Rotate);
186
+ void Paint_SetMirroring(UBYTE mirror);
187
+ void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color);
188
+ void Paint_SetScale(UBYTE scale);
189
+
190
+ void Paint_Clear(UWORD Color);
191
+ void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color);
192
+
193
+ //Drawing
194
+ void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_FillWay);
195
+ void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, LINE_STYLE Line_Style);
196
+ void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill);
197
+ void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill);
198
+
199
+ //Display string
200
+ void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Acsii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
201
+ void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
202
+ void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background);
203
+ void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
204
+ void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
205
+
206
+ //pic
207
+ void Paint_DrawBitMap(const unsigned char* image_buffer);
208
+
209
+
210
+ #endif
211
+
212
+
213
+
214
+
215
+
@@ -0,0 +1,152 @@
1
+ /*****************************************************************************
2
+ * | File : SYSFS_GPIO.c
3
+ * | Author : Waveshare team
4
+ * | Function : Drive SYSFS_ GPIO
5
+ * | Info : Read and write /sys/class/gpio
6
+ *----------------
7
+ * | This version: V1.0
8
+ * | Date : 2019-06-04
9
+ * | Info : Basic version
10
+ *
11
+ #
12
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ # of this software and associated documnetation files (the "Software"), to deal
14
+ # SYSFS_GPIO_IN the Software without restriction, including without limitation the rights
15
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ # copies of the Software, and to permit persons to whom the Software is
17
+ # furished to do so, subject to the folSYSFS_GPIO_LOWing conditions:
18
+ #
19
+ # The above copyright notice and this permission notice shall be included SYSFS_GPIO_IN
20
+ # all copies or substantial portions of the Software.
21
+ #
22
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. SYSFS_GPIO_IN NO EVENT SHALL THE
25
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ # LIABILITY WHETHER SYSFS_GPIO_IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ # SYSFS_GPIO_OUT OF OR SYSFS_GPIO_IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS SYSFS_GPIO_IN
28
+ # THE SOFTWARE.
29
+ #
30
+ ******************************************************************************/
31
+ #include "RPI_sysfs_gpio.h"
32
+ #include <sys/stat.h>
33
+ #include <sys/types.h>
34
+ #include <fcntl.h>
35
+ #include <stdio.h>
36
+ #include <stdlib.h>
37
+ #include <string.h>
38
+ #include <unistd.h>
39
+
40
+ int SYSFS_GPIO_Export(int Pin)
41
+ {
42
+ char buffer[NUM_MAXBUF];
43
+ int len;
44
+ int fd;
45
+
46
+ fd = open("/sys/class/gpio/export", O_WRONLY);
47
+ if (fd < 0) {
48
+ SYSFS_GPIO_Debug( "Export Failed: Pin%d\n", Pin);
49
+ return -1;
50
+ }
51
+
52
+ len = snprintf(buffer, NUM_MAXBUF, "%d", Pin);
53
+ write(fd, buffer, len);
54
+
55
+ SYSFS_GPIO_Debug( "Export: Pin%d\r\n", Pin);
56
+
57
+ close(fd);
58
+ return 0;
59
+ }
60
+
61
+ int SYSFS_GPIO_Unexport(int Pin)
62
+ {
63
+ char buffer[NUM_MAXBUF];
64
+ int len;
65
+ int fd;
66
+
67
+ fd = open("/sys/class/gpio/unexport", O_WRONLY);
68
+ if (fd < 0) {
69
+ SYSFS_GPIO_Debug( "unexport Failed: Pin%d\n", Pin);
70
+ return -1;
71
+ }
72
+
73
+ len = snprintf(buffer, NUM_MAXBUF, "%d", Pin);
74
+ write(fd, buffer, len);
75
+
76
+ SYSFS_GPIO_Debug( "Unexport: Pin%d\r\n", Pin);
77
+
78
+ close(fd);
79
+ return 0;
80
+ }
81
+
82
+ int SYSFS_GPIO_Direction(int Pin, int Dir)
83
+ {
84
+ const char dir_str[] = "in\0out";
85
+ char path[DIR_MAXSIZ];
86
+ int fd;
87
+
88
+ snprintf(path, DIR_MAXSIZ, "/sys/class/gpio/gpio%d/direction", Pin);
89
+ fd = open(path, O_WRONLY);
90
+ if (fd < 0) {
91
+ SYSFS_GPIO_Debug( "Set Direction failed: Pin%d\n", Pin);
92
+ return -1;
93
+ }
94
+
95
+ if (write(fd, &dir_str[Dir == SYSFS_GPIO_IN ? 0 : 3], Dir == SYSFS_GPIO_IN ? 2 : 3) < 0) {
96
+ SYSFS_GPIO_Debug("failed to set direction!\r\n");
97
+ return -1;
98
+ }
99
+
100
+ if(Dir == SYSFS_GPIO_IN){
101
+ SYSFS_GPIO_Debug("Pin%d:intput\r\n", Pin);
102
+ }else{
103
+ SYSFS_GPIO_Debug("Pin%d:Output\r\n", Pin);
104
+ }
105
+
106
+ close(fd);
107
+ return 0;
108
+ }
109
+
110
+ int SYSFS_GPIO_Read(int Pin)
111
+ {
112
+ char path[DIR_MAXSIZ];
113
+ char value_str[3];
114
+ int fd;
115
+
116
+ snprintf(path, DIR_MAXSIZ, "/sys/class/gpio/gpio%d/value", Pin);
117
+ fd = open(path, O_RDONLY);
118
+ if (fd < 0) {
119
+ SYSFS_GPIO_Debug( "Read failed Pin%d\n", Pin);
120
+ return -1;
121
+ }
122
+
123
+ if (read(fd, value_str, 3) < 0) {
124
+ SYSFS_GPIO_Debug( "failed to read value!\n");
125
+ return -1;
126
+ }
127
+
128
+ close(fd);
129
+ return(atoi(value_str));
130
+ }
131
+
132
+ int SYSFS_GPIO_Write(int Pin, int value)
133
+ {
134
+ const char s_values_str[] = "01";
135
+ char path[DIR_MAXSIZ];
136
+ int fd;
137
+
138
+ snprintf(path, DIR_MAXSIZ, "/sys/class/gpio/gpio%d/value", Pin);
139
+ fd = open(path, O_WRONLY);
140
+ if (fd < 0) {
141
+ SYSFS_GPIO_Debug( "Write failed : Pin%d,value = %d\n", Pin, value);
142
+ return -1;
143
+ }
144
+
145
+ if (write(fd, &s_values_str[value == SYSFS_GPIO_LOW ? 0 : 1], 1) < 0) {
146
+ SYSFS_GPIO_Debug( "failed to write value!\n");
147
+ return -1;
148
+ }
149
+
150
+ close(fd);
151
+ return 0;
152
+ }
@@ -0,0 +1,82 @@
1
+ /*****************************************************************************
2
+ * | File : sysfs_gpio.h
3
+ * | Author : Waveshare team
4
+ * | Function : Drive SC16IS752 GPIO
5
+ * | Info : Read and write /sys/class/gpio
6
+ *----------------
7
+ * | This version: V1.0
8
+ * | Date : 2019-06-04
9
+ * | Info : Basic version
10
+ *
11
+ #
12
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ # of this software and associated documnetation files (the "Software"), to deal
14
+ # in the Software without restriction, including without limitation the rights
15
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ # copies of the Software, and to permit persons to whom the Software is
17
+ # furished to do so, subject to the following conditions:
18
+ #
19
+ # The above copyright notice and this permission notice shall be included in
20
+ # all copies or substantial portions of the Software.
21
+ #
22
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
+ # THE SOFTWARE.
29
+ #
30
+ ******************************************************************************/
31
+ #ifndef __SYSFS_GPIO_
32
+ #define __SYSFS_GPIO_
33
+
34
+ #include <stdio.h>
35
+
36
+ #define SYSFS_GPIO_IN 0
37
+ #define SYSFS_GPIO_OUT 1
38
+
39
+ #define SYSFS_GPIO_LOW 0
40
+ #define SYSFS_GPIO_HIGH 1
41
+
42
+ #define NUM_MAXBUF 4
43
+ #define DIR_MAXSIZ 60
44
+
45
+ #define SYSFS_GPIO_DEBUG 0
46
+ #if SYSFS_GPIO_DEBUG
47
+ #define SYSFS_GPIO_Debug(__info,...) printf("Debug: " __info,##__VA_ARGS__)
48
+ #else
49
+ #define SYSFS_GPIO_Debug(__info,...)
50
+ #endif
51
+
52
+ // BCM GPIO for Jetson nano
53
+ #define GPIO4 4 // 7, 4
54
+ #define GPIO17 7 // 11, 17
55
+ #define GPIO18 18 // 12, 18
56
+ #define GPIO27 27 // 13, 27
57
+ #define GPIO22 22 // 15, 22
58
+ #define GPIO23 23 // 16, 23
59
+ #define GPIO24 24 // 18, 24
60
+ #define SPI0_MOSI 10 // 19, 10
61
+ #define SPI0_MISO 9 // 21, 9
62
+ #define GPIO25 28 // 22, 25
63
+ #define SPI0_SCK 11 // 23, 11
64
+ #define SPI0_CS0 8 // 24, 8
65
+ #define SPI0_CS1 7 // 26, 7
66
+ #define GPIO5 5 // 29, 5
67
+ #define GPIO6 6 // 31, 6
68
+ #define GPIO12 12 // 32, 12
69
+ #define GPIO13 13 // 33, 13
70
+ #define GPIO19 19 // 35, 19
71
+ #define GPIO16 16 // 36, 16
72
+ #define GPIO26 26 // 37, 26
73
+ #define GPIO20 20 // 38, 20
74
+ #define GPIO21 21 // 40, 21
75
+
76
+ int SYSFS_GPIO_Export(int Pin);
77
+ int SYSFS_GPIO_Unexport(int Pin);
78
+ int SYSFS_GPIO_Direction(int Pin, int Dir);
79
+ int SYSFS_GPIO_Read(int Pin);
80
+ int SYSFS_GPIO_Write(int Pin, int value);
81
+
82
+ #endif