Skip to content

Commit fc833ef

Browse files
committed
Complete modifiedAdafruitGFXExample. But hangs at the end.
1 parent 6fd45e2 commit fc833ef

File tree

2 files changed

+181
-16
lines changed

2 files changed

+181
-16
lines changed

examples/modifiedAdafruitGFXExample/modifiedAdafruitGFXExample.ino

Lines changed: 181 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
#include <Adafruit_4_01_ColourEPaper.h>
22

3-
#include <Fonts/FreeSansBold24pt7b.h>
4-
53
#define RST_PIN 26
64
#define DC_PIN 27
75
#define BUSY_PIN 25
86

9-
#define HOWMUCH 71
10-
117
#define WIDTH 640
128
#define HEIGHT 400
139

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+
1430
Adafruit_4_01_ColourEPaper ePaperObject(WIDTH, HEIGHT, RST_PIN, DC_PIN, BUSY_PIN, false);
1531

1632
void setup()
@@ -26,7 +42,7 @@ void loop()
2642
{
2743
// display clearing
2844
Serial.println("Clearing the screen");
29-
ePaperObject.clear();
45+
ePaperObject.clearDisplay();
3046
ePaperObject.display();
3147
ePaperObject.waitForScreenBlocking();
3248

@@ -45,11 +61,11 @@ void loop()
4561
// drawing lines on the display
4662
Serial.println("Drawing lines on the display");
4763
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)
4965
{
5066
ePaperObject.drawLine(0, 0, i, ePaperObject.height() - 1, EPD_COLOUR_GREEN);
5167
}
52-
for (i = 0; i < ePaperObject.height(); i += 4)
68+
for (int16_t i = 0; i < ePaperObject.height(); i += 4)
5369
{
5470
ePaperObject.drawLine(0, 0, ePaperObject.width() - 1, i, EPD_COLOUR_BLUE);
5571
}
@@ -59,7 +75,7 @@ void loop()
5975
// waiting for 10 seconds
6076
delay(10000);
6177

62-
//drawing rectangles on the display
78+
// drawing rectangles on the display
6379
Serial.println("Drawing rectangles on the display");
6480
ePaperObject.clearDisplay();
6581
for (int16_t i = 0; i < ePaperObject.height() / 2; i += 2)
@@ -72,12 +88,11 @@ void loop()
7288
// waiting for 10 seconds
7389
delay(10000);
7490

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");
7793
ePaperObject.clearDisplay();
7894
for (int16_t i = 0; i < ePaperObject.height() / 2; i += 3)
7995
{
80-
// The INVERSE color is used so rectangles alternate white/black
8196
ePaperObject.fillRect(i, i, ePaperObject.width() - i * 2, ePaperObject.height() - i * 2, EPD_COLOUR_YELLOW);
8297
}
8398
ePaperObject.display();
@@ -86,5 +101,159 @@ void loop()
86101
// waiting for 10 seconds
87102
delay(10000);
88103

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+
89255
Serial.println("Done");
90-
}
256+
257+
// waiting for 20 seconds
258+
delay(20000);
259+
}

examples/testFunction/testFunction.ino

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
#include <Adafruit_4_01_ColourEPaper.h>
22

3-
#include <Fonts/FreeSansBold24pt7b.h>
4-
53
#define RST_PIN 26
64
#define DC_PIN 27
75
#define BUSY_PIN 25
86

9-
#define HOWMUCH 71
10-
117
#define WIDTH 640
128
#define HEIGHT 400
139

0 commit comments

Comments
 (0)