|
7 | 7 | MIT license, all text above must be included in any redistribution
|
8 | 8 | ****************************************************/
|
9 | 9 |
|
10 |
| -#include <Adafruit_GFX.h> // Core graphics library |
11 |
| -#include "Adafruit_EPD.h" |
| 10 | +#include "Adafruit_ThinkInk.h" |
12 | 11 |
|
13 | 12 | #define EPD_CS 0
|
14 | 13 | #define EPD_DC 1
|
|
25 | 24 | SPIClass* spi = &SPI1;
|
26 | 25 | #endif
|
27 | 26 |
|
28 |
| -Adafruit_IL0373 display(152, 152, EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY, spi); |
| 27 | +// 1.54" 152x152 Tricolor EPD with ILI0373 chipset |
| 28 | +//ThinkInk_154_Tricolor_Z17 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY); |
| 29 | +// 1.54" 200x200 Tricolor EPD with SSD1681 chipset |
| 30 | +ThinkInk_154_Tricolor_Z90 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY); |
29 | 31 |
|
30 | 32 | float p = 3.1415926;
|
31 | 33 |
|
32 | 34 | void setup(void) {
|
33 |
| - Serial.begin(9600); |
34 |
| - Serial.print("Hello! EPD Test"); |
| 35 | + Serial.begin(115200); |
| 36 | + Serial.print("Hello! EPD Gizmo Test"); |
35 | 37 |
|
36 |
| - display.begin(); |
37 |
| - display.setRotation(3); |
| 38 | + display.begin(THINKINK_TRICOLOR); |
38 | 39 |
|
39 | 40 | Serial.println("Initialized");
|
40 |
| - |
41 |
| - display.clearBuffer(); |
42 |
| - display.fillRect(display.width()/3, 0, display.width()/3, display.height(), EPD_RED); |
43 |
| - display.fillRect((display.width()*2)/3, 0, display.width()/3, display.height(), EPD_BLACK); |
44 |
| - display.display(); |
45 |
| - |
46 |
| - delay(15 * 1000); |
47 |
| - |
48 |
| - // large block of text |
49 |
| - display.clearBuffer(); |
50 |
| - display.fillScreen(EPD_WHITE); |
51 |
| - testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", EPD_BLACK); |
52 |
| - |
53 |
| - delay(15 * 1000); |
54 |
| - |
55 |
| - // epd print function! |
56 |
| - epdPrintTest(); |
57 |
| - |
58 |
| - delay(15 * 1000); |
59 |
| - |
60 |
| - // a single pixel |
61 |
| - display.clearBuffer(); |
62 |
| - display.drawPixel(display.width()/2, display.height()/2, EPD_BLACK); |
63 |
| - |
64 |
| - delay(15 * 1000); |
65 |
| - |
66 |
| - testtriangles(); |
67 |
| - |
68 |
| - delay(15 * 1000); |
69 |
| - |
70 |
| - // line draw test |
71 |
| - testlines(EPD_BLACK); |
72 |
| - |
73 |
| - delay(15 * 1000); |
74 |
| - |
75 |
| - // optimized lines |
76 |
| - testfastlines(EPD_BLACK, EPD_RED); |
77 |
| - |
78 |
| - delay(15 * 1000); |
79 |
| - |
80 |
| - testdrawrects(EPD_RED); |
81 |
| - |
82 |
| - delay(15 * 1000); |
83 |
| - |
84 |
| - testfillrects(EPD_BLACK, EPD_RED); |
85 |
| - |
86 |
| - delay(15 * 1000); |
87 |
| - |
88 |
| - display.fillScreen(EPD_WHITE); |
89 |
| - testfillcircles(10, EPD_RED); |
90 |
| - testdrawcircles(10, EPD_BLACK); |
91 |
| - |
92 |
| - delay(15 * 1000); |
93 |
| - |
94 |
| - testroundrects(); |
95 |
| - |
96 |
| - delay(15 * 1000); |
97 |
| - |
98 |
| - mediabuttons(); |
99 |
| - |
100 |
| - Serial.println("done"); |
101 | 41 | }
|
102 | 42 |
|
103 | 43 | void loop() {
|
104 |
| - delay(500); |
105 |
| -} |
106 |
| - |
107 |
| -void testlines(uint16_t color) { |
108 |
| - display.clearBuffer(); |
109 |
| - display.fillScreen(EPD_WHITE); |
110 |
| - for (int16_t x=0; x < display.width(); x+=6) { |
111 |
| - display.drawLine(0, 0, x, display.height()-1, color); |
112 |
| - } |
113 |
| - for (int16_t y=0; y < display.height(); y+=6) { |
114 |
| - display.drawLine(0, 0, display.width()-1, y, color); |
115 |
| - } |
116 |
| - |
117 |
| - display.fillScreen(EPD_WHITE); |
118 |
| - for (int16_t x=0; x < display.width(); x+=6) { |
119 |
| - display.drawLine(display.width()-1, 0, x, display.height()-1, color); |
120 |
| - } |
121 |
| - for (int16_t y=0; y < display.height(); y+=6) { |
122 |
| - display.drawLine(display.width()-1, 0, 0, y, color); |
123 |
| - } |
124 |
| - |
125 |
| - display.fillScreen(EPD_WHITE); |
126 |
| - for (int16_t x=0; x < display.width(); x+=6) { |
127 |
| - display.drawLine(0, display.height()-1, x, 0, color); |
128 |
| - } |
129 |
| - for (int16_t y=0; y < display.height(); y+=6) { |
130 |
| - display.drawLine(0, display.height()-1, display.width()-1, y, color); |
131 |
| - } |
132 |
| - |
133 |
| - display.fillScreen(EPD_WHITE); |
134 |
| - for (int16_t x=0; x < display.width(); x+=6) { |
135 |
| - display.drawLine(display.width()-1, display.height()-1, x, 0, color); |
136 |
| - } |
137 |
| - for (int16_t y=0; y < display.height(); y+=6) { |
138 |
| - display.drawLine(display.width()-1, display.height()-1, 0, y, color); |
139 |
| - } |
140 |
| - display.display(); |
141 |
| -} |
142 |
| - |
143 |
| -void testdrawtext(char *text, uint16_t color) { |
| 44 | + Serial.println("Banner demo"); |
144 | 45 | display.clearBuffer();
|
145 |
| - display.setCursor(5, 5); |
146 |
| - display.setTextColor(color); |
147 |
| - display.setTextWrap(true); |
148 |
| - display.print(text); |
| 46 | + display.setTextSize(3); |
| 47 | + display.setCursor((display.width() - 144)/2, (display.height() - 24)/2); |
| 48 | + display.setTextColor(EPD_BLACK); |
| 49 | + display.print("Tri"); |
| 50 | + display.setTextColor(EPD_RED); |
| 51 | + display.print("Color"); |
149 | 52 | display.display();
|
150 |
| -} |
151 | 53 |
|
152 |
| -void testfastlines(uint16_t color1, uint16_t color2) { |
| 54 | + delay(15000); |
| 55 | + |
| 56 | + Serial.println("Color rectangle demo"); |
153 | 57 | display.clearBuffer();
|
154 |
| - display.fillScreen(EPD_WHITE); |
155 |
| - for (int16_t y=0; y < display.height(); y+=5) { |
156 |
| - display.drawFastHLine(0, y, display.width(), color1); |
157 |
| - } |
158 |
| - for (int16_t x=0; x < display.width(); x+=5) { |
159 |
| - display.drawFastVLine(x, 0, display.height(), color2); |
160 |
| - } |
| 58 | + display.fillRect(display.width()/3, 0, display.width()/3, display.height(), EPD_BLACK); |
| 59 | + display.fillRect((display.width()*2)/3, 0, display.width()/3, display.height(), EPD_RED); |
161 | 60 | display.display();
|
162 |
| -} |
163 | 61 |
|
164 |
| -void testdrawrects(uint16_t color) { |
| 62 | + delay(15000); |
| 63 | + |
| 64 | + Serial.println("Text demo"); |
| 65 | + // large block of text |
165 | 66 | display.clearBuffer();
|
166 |
| - display.fillScreen(EPD_WHITE); |
167 |
| - for (int16_t x=0; x < display.width(); x+=6) { |
168 |
| - display.drawRect(display.width()/2 -x/2, display.height()/2 -x/2 , x, x, color); |
169 |
| - } |
| 67 | + display.setTextSize(1); |
| 68 | + testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", EPD_BLACK); |
170 | 69 | display.display();
|
171 |
| -} |
172 | 70 |
|
173 |
| -void testfillrects(uint16_t color1, uint16_t color2) { |
174 |
| - display.clearBuffer(); |
175 |
| - display.fillScreen(EPD_WHITE); |
176 |
| - for (int16_t x=display.width()-1; x > 6; x-=6) { |
177 |
| - display.fillRect(display.width()/2 -x/2, display.height()/2 -x/2 , x, x, color1); |
178 |
| - display.drawRect(display.width()/2 -x/2, display.height()/2 -x/2 , x, x, color2); |
179 |
| - } |
180 |
| - display.display(); |
181 |
| -} |
| 71 | + delay(15000); |
182 | 72 |
|
183 |
| -void testfillcircles(uint8_t radius, uint16_t color) { |
184 | 73 | display.clearBuffer();
|
185 |
| - for (int16_t x=radius; x < display.width(); x+=radius*2) { |
186 |
| - for (int16_t y=radius; y < display.height(); y+=radius*2) { |
187 |
| - display.fillCircle(x, y, radius, color); |
188 |
| - } |
| 74 | + for (int16_t i=0; i<display.width(); i+=4) { |
| 75 | + display.drawLine(0, 0, i, display.height()-1, EPD_BLACK); |
189 | 76 | }
|
190 |
| - display.display(); |
191 |
| -} |
192 | 77 |
|
193 |
| -void testdrawcircles(uint8_t radius, uint16_t color) { |
194 |
| - display.clearBuffer(); |
195 |
| - for (int16_t x=0; x < display.width()+radius; x+=radius*2) { |
196 |
| - for (int16_t y=0; y < display.height()+radius; y+=radius*2) { |
197 |
| - display.drawCircle(x, y, radius, color); |
198 |
| - } |
| 78 | + for (int16_t i=0; i<display.height(); i+=4) { |
| 79 | + display.drawLine(display.width()-1, 0, 0, i, EPD_RED); |
199 | 80 | }
|
200 | 81 | display.display();
|
201 |
| -} |
202 | 82 |
|
203 |
| -void testtriangles() { |
204 |
| - display.clearBuffer(); |
205 |
| - display.fillScreen(EPD_WHITE); |
206 |
| - int color = EPD_BLACK; |
207 |
| - int t; |
208 |
| - int w = display.width()/2; |
209 |
| - int x = display.height()-1; |
210 |
| - int y = 0; |
211 |
| - int z = display.width(); |
212 |
| - for(t = 0 ; t <= 15; t++) { |
213 |
| - display.drawTriangle(w, y, y, x, z, x, color); |
214 |
| - x-=4; |
215 |
| - y+=4; |
216 |
| - z-=4; |
217 |
| - if(t == 8) color = EPD_RED; |
218 |
| - } |
219 |
| - display.display(); |
| 83 | + delay(15000); |
220 | 84 | }
|
221 | 85 |
|
222 |
| -void testroundrects() { |
223 |
| - display.clearBuffer(); |
224 |
| - display.fillScreen(EPD_WHITE); |
225 |
| - int color = EPD_BLACK; |
226 |
| - int i; |
227 |
| - int t; |
228 |
| - for(t = 0 ; t <= 4; t+=1) { |
229 |
| - int x = 0; |
230 |
| - int y = 0; |
231 |
| - int w = display.width()-2; |
232 |
| - int h = display.height()-2; |
233 |
| - for(i = 0 ; i <= 16; i+=1) { |
234 |
| - display.drawRoundRect(x, y, w, h, 5, color); |
235 |
| - x+=2; |
236 |
| - y+=3; |
237 |
| - w-=4; |
238 |
| - h-=6; |
239 |
| - if(i == 7) color = EPD_RED; |
240 |
| - } |
241 |
| - color = EPD_BLACK; |
242 |
| - } |
243 |
| - display.display(); |
244 |
| -} |
245 | 86 |
|
246 |
| -void epdPrintTest() { |
247 |
| - display.clearBuffer(); |
248 |
| - display.setCursor(5, 5); |
249 |
| - display.fillScreen(EPD_WHITE); |
250 |
| - display.setTextColor(EPD_BLACK); |
251 |
| - display.setTextSize(2); |
252 |
| - display.println("Hello World!"); |
253 |
| - display.setTextSize(1); |
254 |
| - display.setTextColor(EPD_RED); |
255 |
| - display.print(p, 6); |
256 |
| - display.println(" Want pi?"); |
257 |
| - display.println(" "); |
258 |
| - display.print(8675309, HEX); // print 8,675,309 out in HEX! |
259 |
| - display.println(" Print HEX!"); |
260 |
| - display.println(" "); |
261 |
| - display.setTextColor(EPD_BLACK); |
262 |
| - display.println("Sketch has been"); |
263 |
| - display.println("running for: "); |
264 |
| - display.setTextColor(EPD_RED); |
265 |
| - display.print(millis() / 1000); |
266 |
| - display.setTextColor(EPD_BLACK); |
267 |
| - display.print(" seconds."); |
268 |
| - display.display(); |
269 |
| -} |
270 |
| - |
271 |
| -void mediabuttons() { |
272 |
| - display.clearBuffer(); |
273 |
| - // play |
274 |
| - display.fillScreen(EPD_WHITE); |
275 |
| - display.fillRoundRect(25, 10, 78, 60, 8, EPD_BLACK); |
276 |
| - display.fillTriangle(42, 20, 42, 60, 90, 40, EPD_RED); |
277 |
| - // pause |
278 |
| - display.fillRoundRect(25, 90, 78, 60, 8, EPD_BLACK); |
279 |
| - display.fillRoundRect(39, 98, 20, 45, 5, EPD_RED); |
280 |
| - display.fillRoundRect(69, 98, 20, 45, 5, EPD_RED); |
281 |
| - display.display(); |
| 87 | +void testdrawtext(char *text, uint16_t color) { |
| 88 | + display.setCursor(0, 0); |
| 89 | + display.setTextColor(color); |
| 90 | + display.setTextWrap(true); |
| 91 | + display.print(text); |
282 | 92 | }
|
0 commit comments