1
1
#include < Adafruit_4_01_ColourEPaper.h>
2
2
3
- #include < Fonts/FreeSansBold24pt7b.h>
4
-
5
3
#define RST_PIN 26
6
4
#define DC_PIN 27
7
5
#define BUSY_PIN 25
8
6
9
- #define HOWMUCH 71
10
-
11
7
#define WIDTH 640
12
8
#define HEIGHT 400
13
9
10
+ #define LOGO_HEIGHT 16
11
+ #define LOGO_WIDTH 16
12
+ static const unsigned char logo_bmp[] =
13
+ {0b00000000 , 0b11000000 ,
14
+ 0b00000001 , 0b11000000 ,
15
+ 0b00000001 , 0b11000000 ,
16
+ 0b00000011 , 0b11100000 ,
17
+ 0b11110011 , 0b11100000 ,
18
+ 0b11111110 , 0b11111000 ,
19
+ 0b01111110 , 0b11111111 ,
20
+ 0b00110011 , 0b10011111 ,
21
+ 0b00011111 , 0b11111100 ,
22
+ 0b00001101 , 0b01110000 ,
23
+ 0b00011011 , 0b10100000 ,
24
+ 0b00111111 , 0b11100000 ,
25
+ 0b00111111 , 0b11110000 ,
26
+ 0b01111100 , 0b11110000 ,
27
+ 0b01110000 , 0b01110000 ,
28
+ 0b00000000 , 0b00110000 };
29
+
14
30
Adafruit_4_01_ColourEPaper ePaperObject (WIDTH, HEIGHT, RST_PIN, DC_PIN, BUSY_PIN, false );
15
31
16
32
void setup ()
@@ -26,7 +42,7 @@ void loop()
26
42
{
27
43
// display clearing
28
44
Serial.println (" Clearing the screen" );
29
- ePaperObject.clear ();
45
+ ePaperObject.clearDisplay ();
30
46
ePaperObject.display ();
31
47
ePaperObject.waitForScreenBlocking ();
32
48
@@ -45,11 +61,11 @@ void loop()
45
61
// drawing lines on the display
46
62
Serial.println (" Drawing lines on the display" );
47
63
ePaperObject.clearDisplay (); // Clear display buffer
48
- for (i = 0 ; i < ePaperObject.width (); i += 4 )
64
+ for (int16_t i = 0 ; i < ePaperObject.width (); i += 4 )
49
65
{
50
66
ePaperObject.drawLine (0 , 0 , i, ePaperObject.height () - 1 , EPD_COLOUR_GREEN);
51
67
}
52
- for (i = 0 ; i < ePaperObject.height (); i += 4 )
68
+ for (int16_t i = 0 ; i < ePaperObject.height (); i += 4 )
53
69
{
54
70
ePaperObject.drawLine (0 , 0 , ePaperObject.width () - 1 , i, EPD_COLOUR_BLUE);
55
71
}
@@ -59,7 +75,7 @@ void loop()
59
75
// waiting for 10 seconds
60
76
delay (10000 );
61
77
62
- // drawing rectangles on the display
78
+ // drawing rectangles on the display
63
79
Serial.println (" Drawing rectangles on the display" );
64
80
ePaperObject.clearDisplay ();
65
81
for (int16_t i = 0 ; i < ePaperObject.height () / 2 ; i += 2 )
@@ -72,12 +88,11 @@ void loop()
72
88
// waiting for 10 seconds
73
89
delay (10000 );
74
90
75
- // drawing a filled rectangle
76
- Serial.println (" Drawing filled rectangle on the display. You will only see 1 though" );
91
+ // drawing a filled rectangle
92
+ Serial.println (" Drawing a filled rectangle on the display. You will only see 1 though" );
77
93
ePaperObject.clearDisplay ();
78
94
for (int16_t i = 0 ; i < ePaperObject.height () / 2 ; i += 3 )
79
95
{
80
- // The INVERSE color is used so rectangles alternate white/black
81
96
ePaperObject.fillRect (i, i, ePaperObject.width () - i * 2 , ePaperObject.height () - i * 2 , EPD_COLOUR_YELLOW);
82
97
}
83
98
ePaperObject.display ();
@@ -86,5 +101,159 @@ void loop()
86
101
// waiting for 10 seconds
87
102
delay (10000 );
88
103
104
+ // drawing circles
105
+ Serial.println (" Drawing circles on the display" );
106
+ ePaperObject.clearDisplay ();
107
+ for (int16_t i = 0 ; i < max (ePaperObject.width (), ePaperObject.height ()) / 2 ; i += 2 )
108
+ {
109
+ ePaperObject.drawCircle (ePaperObject.width () / 2 , ePaperObject.height () / 2 , i, EPD_COLOUR_ORANGE);
110
+ }
111
+ ePaperObject.display ();
112
+ ePaperObject.waitForScreenBlocking ();
113
+
114
+ // waiting for 10 seconds
115
+ delay (10000 );
116
+
117
+ // drawing a filled circle
118
+ Serial.println (" Drawing a filled circle on the display. You will only see 1 though" );
119
+ ePaperObject.clearDisplay ();
120
+ for (int16_t i = max (ePaperObject.width (), ePaperObject.height ()) / 2 ; i > 0 ; i -= 3 )
121
+ {
122
+ ePaperObject.fillCircle (ePaperObject.width () / 2 , ePaperObject.height () / 2 , i, EPD_COLOUR_BLACK);
123
+ }
124
+ ePaperObject.display ();
125
+ ePaperObject.waitForScreenBlocking ();
126
+
127
+ // waiting for 10 seconds
128
+ delay (10000 );
129
+
130
+ // drawing round rectangles
131
+ Serial.println (" Drawing round rectangles on the display." );
132
+ ePaperObject.clearDisplay ();
133
+ for (int16_t i = 0 ; i < ePaperObject.height () / 2 - 2 ; i += 2 )
134
+ {
135
+ ePaperObject.drawRoundRect (i, i, ePaperObject.width () - 2 * i, ePaperObject.height () - 2 * i,
136
+ ePaperObject.height () / 4 , EPD_COLOUR_GREEN);
137
+ }
138
+ ePaperObject.display ();
139
+ ePaperObject.waitForScreenBlocking ();
140
+
141
+ // waiting for 10 seconds
142
+ delay (10000 );
143
+
144
+ // drawing a filled round rectangle
145
+ Serial.println (" Drawing a filled round rectangle on the display. You will only see 1 though" );
146
+ ePaperObject.clearDisplay ();
147
+ for (int16_t i = 0 ; i < ePaperObject.height () / 2 - 2 ; i += 2 )
148
+ {
149
+ ePaperObject.fillRoundRect (i, i, ePaperObject.width () - 2 * i, ePaperObject.height () - 2 * i,
150
+ ePaperObject.height () / 4 , EPD_COLOUR_BLUE);
151
+ }
152
+ ePaperObject.display ();
153
+ ePaperObject.waitForScreenBlocking ();
154
+
155
+ // waiting for 10 seconds
156
+ delay (10000 );
157
+
158
+ // drawing triangles
159
+ Serial.println (" Drawing triangles on the display." );
160
+ ePaperObject.clearDisplay ();
161
+ for (int16_t i = 0 ; i < max (ePaperObject.width (), ePaperObject.height ()) / 2 ; i += 5 )
162
+ {
163
+ ePaperObject.drawTriangle (
164
+ ePaperObject.width () / 2 , ePaperObject.height () / 2 - i,
165
+ ePaperObject.width () / 2 - i, ePaperObject.height () / 2 + i,
166
+ ePaperObject.width () / 2 + i, ePaperObject.height () / 2 + i, EPD_COLOUR_RED);
167
+ }
168
+ ePaperObject.display ();
169
+ ePaperObject.waitForScreenBlocking ();
170
+
171
+ // waiting for 10 seconds
172
+ delay (10000 );
173
+
174
+ // drawing a filled triangle
175
+ Serial.println (" Drawing a filled triangle on the display. You will only see 1 though" );
176
+ ePaperObject.clearDisplay ();
177
+ for (int16_t i = max (ePaperObject.width (), ePaperObject.height ()) / 2 ; i > 0 ; i -= 5 )
178
+ {
179
+ ePaperObject.fillTriangle (
180
+ ePaperObject.width () / 2 , ePaperObject.height () / 2 - i,
181
+ ePaperObject.width () / 2 - i, ePaperObject.height () / 2 + i,
182
+ ePaperObject.width () / 2 + i, ePaperObject.height () / 2 + i, EPD_COLOUR_YELLOW);
183
+ }
184
+ ePaperObject.display ();
185
+ ePaperObject.waitForScreenBlocking ();
186
+
187
+ // waiting for 10 seconds
188
+ delay (10000 );
189
+
190
+ // Writing CP437 character set
191
+ Serial.println (" Writing CP437 character set on the screen" );
192
+ ePaperObject.clearDisplay ();
193
+ ePaperObject.setTextSize (1 ); // Normal 1:1 pixel scale
194
+ ePaperObject.setTextColor (EPD_COLOUR_ORANGE); // Draw orange text
195
+ ePaperObject.setCursor (0 , 0 ); // Start at top-left corner
196
+ ePaperObject.cp437 (true ); // Use full 256 char 'Code Page 437' font
197
+
198
+ // Not all the characters will fit on the display. This is normal.
199
+ // Library will draw what it can and the rest will be clipped.
200
+ for (int16_t i = 0 ; i < 256 ; i++)
201
+ {
202
+ if (i == ' \n ' )
203
+ ePaperObject.write (' ' );
204
+ else
205
+ ePaperObject.write (i);
206
+ }
207
+ ePaperObject.display ();
208
+ ePaperObject.waitForScreenBlocking ();
209
+
210
+ // waiting for 10 seconds
211
+ delay (10000 );
212
+
213
+ // Writing basic text
214
+ Serial.println (" Writing basic text on the screen(CP437)" );
215
+ ePaperObject.clearDisplay ();
216
+
217
+ ePaperObject.setTextSize (1 ); // Normal 1:1 pixel scale
218
+ ePaperObject.setTextColor (EPD_COLOUR_BLACK); // Draw black text
219
+ ePaperObject.setCursor (0 , 0 ); // Start at top-left corner
220
+ ePaperObject.println (" Hello, world!" );
221
+
222
+ ePaperObject.setTextColor (EPD_COLOUR_GREEN);
223
+ ePaperObject.println (3.141592 );
224
+
225
+ ePaperObject.setTextSize (2 ); // Draw 2X-scale text
226
+ ePaperObject.setTextColor (EPD_COLOUR_BLUE);
227
+ ePaperObject.print (" 0x" );
228
+ ePaperObject.println (0xDEADBEEF , HEX);
229
+ ePaperObject.display ();
230
+ ePaperObject.waitForScreenBlocking ();
231
+
232
+ // waiting for 10 seconds
233
+ delay (10000 );
234
+
235
+ // Drawing bitmap on the screen
236
+ Serial.println (" Drawing bitmap on the screen" );
237
+ ePaperObject.clearDisplay ();
238
+ ePaperObject.drawBitmap (
239
+ (ePaperObject.width () - LOGO_WIDTH) / 2 ,
240
+ (ePaperObject.height () - LOGO_HEIGHT) / 2 ,
241
+ logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, EPD_COLOUR_RED);
242
+ ePaperObject.display ();
243
+ ePaperObject.waitForScreenBlocking ();
244
+
245
+ // waiting for 10 seconds
246
+ delay (10000 );
247
+
248
+ // Drawing vertical bars of all colours
249
+ Serial.println (" Drawing vertical bars of all colours on the screen" );
250
+ ePaperObject.clearDisplay ();
251
+ ePaperObject.test ();
252
+ ePaperObject.display ();
253
+ ePaperObject.waitForScreenBlocking ();
254
+
89
255
Serial.println (" Done" );
90
- }
256
+
257
+ // waiting for 20 seconds
258
+ delay (20000 );
259
+ }
0 commit comments