Skip to content

Commit 9345364

Browse files
authored
Merge pull request #27 from adafruit/partial29
grayscale, partial, and refactor for per-panel configuration
2 parents 51a0d84 + f51e590 commit 9345364

Some content is hidden

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

43 files changed

+2440
-161
lines changed

.github/workflows/githubci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
steps:
1010
- uses: actions/setup-python@v1
1111
with:
12-
python-version: '3.x'
12+
python-version: '3.8'
1313
- uses: actions/checkout@v2
1414
- uses: actions/checkout@v2
1515
with:
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/***************************************************
2+
Adafruit invests time and resources providing this open source code,
3+
please support Adafruit and open-source hardware by purchasing
4+
products from Adafruit!
5+
6+
Written by Limor Fried/Ladyada for Adafruit Industries.
7+
MIT license, all text above must be included in any redistribution
8+
****************************************************/
9+
10+
#include "Adafruit_ThinkInk.h"
11+
12+
#define EPD_CS 10
13+
#define EPD_DC 9
14+
#define SRAM_CS 11
15+
#define EPD_RESET 5 // can set to -1 and share with microcontroller Reset!
16+
#define EPD_BUSY 7 // can set to -1 to not use a pin (will wait a fixed delay)
17+
18+
//ThinkInk_154_Grayscale4_T8 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
19+
//ThinkInk_213_Grayscale4_T5 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
20+
ThinkInk_290_Grayscale4_T5 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
21+
22+
#define COLOR1 EPD_BLACK
23+
#define COLOR2 EPD_LIGHT
24+
#define COLOR3 EPD_DARK
25+
26+
void setup() {
27+
Serial.begin(115200);
28+
while (!Serial) {
29+
delay(10);
30+
}
31+
Serial.println("Adafruit EPD full update test in mono & grayscale");
32+
}
33+
34+
bool gray = false;
35+
void loop() {
36+
37+
// alternate modes!
38+
if (gray) {
39+
display.begin(THINKINK_GRAYSCALE4);
40+
Serial.println("Grayscale!");
41+
} else {
42+
display.begin(THINKINK_MONO);
43+
Serial.println("Monochrome!");
44+
}
45+
46+
display.clearBuffer();
47+
display.setTextSize(3);
48+
display.setTextColor(EPD_BLACK);
49+
display.setCursor(20, 40);
50+
if (gray) {
51+
display.print("Grayscale");
52+
} else {
53+
display.print("Monochrome");
54+
}
55+
56+
57+
gray = !gray;
58+
59+
display.display();
60+
delay(1000);
61+
62+
display.clearBuffer();
63+
display.fillRect(display.width() / 4, 0, display.width() / 4, display.height(), EPD_LIGHT);
64+
display.fillRect((display.width() * 2) / 4, 0, display.width() / 4, display.height(), EPD_DARK);
65+
display.fillRect((display.width() * 3) / 4, 0, display.width() / 4, display.height(), EPD_BLACK);
66+
display.display();
67+
delay(2000);
68+
69+
Serial.println("Text demo");
70+
// large block of text
71+
display.clearBuffer();
72+
display.setTextSize(1);
73+
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. ", COLOR1);
74+
display.display();
75+
delay(2000);
76+
77+
display.clearBuffer();
78+
for (int16_t i = 0; i < display.width(); i += 4) {
79+
display.drawLine(0, 0, i, display.height() - 1, COLOR1);
80+
}
81+
82+
for (int16_t i = 0; i < display.height(); i += 4) {
83+
display.drawLine(display.width() - 1, 0, 0, i, COLOR2); // on grayscale this will be mid-gray
84+
}
85+
display.display();
86+
delay(2000);
87+
}
88+
89+
90+
void testdrawtext(char *text, uint16_t color) {
91+
display.setCursor(0, 0);
92+
display.setTextColor(color);
93+
display.setTextWrap(true);
94+
display.print(text);
95+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/***************************************************
2+
Adafruit invests time and resources providing this open source code,
3+
please support Adafruit and open-source hardware by purchasing
4+
products from Adafruit!
5+
6+
Written by Limor Fried/Ladyada for Adafruit Industries.
7+
MIT license, all text above must be included in any redistribution
8+
****************************************************/
9+
10+
#include "Adafruit_ThinkInk.h"
11+
12+
#define SD_CS 5
13+
#define SRAM_CS 6
14+
#define EPD_CS 9
15+
#define EPD_DC 10
16+
#define EPD_RESET -1 // can set to -1 and share with microcontroller Reset!
17+
#define EPD_BUSY -1 // can set to -1 to not use a pin (will wait a fixed delay)
18+
19+
//ThinkInk_154_Mono_D67 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
20+
//ThinkInk_154_Mono_D27 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
21+
//ThinkInk_213_Mono_B72 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
22+
//ThinkInk_213_Mono_B73 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
23+
//ThinkInk_213_Mono_BN display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
24+
//ThinkInk_420_Mono_BN display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
25+
ThinkInk_290_Grayscale4_T5 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
26+
27+
void setup() {
28+
Serial.begin(115200);
29+
while (!Serial) { delay(10); }
30+
Serial.println("Adafruit EPD full update test in mono");
31+
display.begin(THINKINK_MONO);
32+
}
33+
34+
void loop() {
35+
Serial.println("Banner demo");
36+
display.clearBuffer();
37+
display.setTextSize(3);
38+
display.setCursor((display.width() - 180)/2, (display.height() - 24)/2);
39+
display.setTextColor(EPD_BLACK);
40+
display.print("Monochrome");
41+
display.display();
42+
43+
delay(2000);
44+
45+
Serial.println("B/W rectangle demo");
46+
display.clearBuffer();
47+
display.fillRect(display.width()/2, 0, display.width()/2, display.height(), EPD_BLACK);
48+
display.display();
49+
50+
delay(2000);
51+
52+
Serial.println("Text demo");
53+
// large block of text
54+
display.clearBuffer();
55+
display.setTextSize(1);
56+
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);
57+
display.display();
58+
59+
delay(2000);
60+
61+
display.clearBuffer();
62+
for (int16_t i=0; i<display.width(); i+=4) {
63+
display.drawLine(0, 0, i, display.height()-1, EPD_BLACK);
64+
}
65+
66+
for (int16_t i=0; i<display.height(); i+=4) {
67+
display.drawLine(display.width()-1, 0, 0, i, EPD_BLACK);
68+
}
69+
display.display();
70+
71+
delay(2000);
72+
}
73+
74+
75+
void testdrawtext(char *text, uint16_t color) {
76+
display.setCursor(0, 0);
77+
display.setTextColor(color);
78+
display.setTextWrap(true);
79+
display.print(text);
80+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/***************************************************
2+
Adafruit invests time and resources providing this open source code,
3+
please support Adafruit and open-source hardware by purchasing
4+
products from Adafruit!
5+
6+
Written by Limor Fried/Ladyada for Adafruit Industries.
7+
MIT license, all text above must be included in any redistribution
8+
****************************************************/
9+
10+
#include "Adafruit_ThinkInk.h"
11+
12+
#define EPD_CS 10
13+
#define EPD_DC 9
14+
#define SRAM_CS -1
15+
#define EPD_RESET 5 // can set to -1 and share with microcontroller Reset!
16+
#define EPD_BUSY 6 // can set to -1 to not use a pin (will wait a fixed delay)
17+
18+
//ThinkInk_290_Grayscale4 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
19+
ThinkInk_154_Mono_D67 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
20+
21+
void setup() {
22+
Serial.begin(115200);
23+
while (!Serial) { delay(10); }
24+
Serial.println("Adafruit counter");
25+
display.begin(THINKINK_MONO);
26+
display.setRotation(0);
27+
}
28+
29+
uint16_t counter = 0;
30+
31+
void loop() {
32+
display.clearBuffer();
33+
display.setTextSize(4);
34+
display.setTextColor(EPD_BLACK);
35+
display.setCursor(32, 32);
36+
display.print((counter / 1000) % 10);
37+
display.print((counter / 100) % 10);
38+
display.print((counter / 10) % 10);
39+
display.print(counter % 10);
40+
41+
if ((counter % 10) == 0) {
42+
display.display(false);
43+
} else {
44+
// redraw only 4th digit
45+
display.displayPartial(32+(24*3), 32, 32+(24*4), 32+(4*8));
46+
}
47+
48+
counter++;
49+
/*
50+
display.fillRect(0, 0, 16, 32, EPD_BLACK);
51+
display.fillRect(4, 4, 8, 24, EPD_WHITE);
52+
// display.display();
53+
display.displayPartial(0, 0, 16, 32);
54+
delay(3000);
55+
*/
56+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/***************************************************
2+
Adafruit invests time and resources providing this open source code,
3+
please support Adafruit and open-source hardware by purchasing
4+
products from Adafruit!
5+
6+
Written by Limor Fried/Ladyada for Adafruit Industries.
7+
MIT license, all text above must be included in any redistribution
8+
****************************************************/
9+
10+
#include "Adafruit_ThinkInk.h"
11+
12+
13+
#define EPD_CS 10
14+
#define EPD_DC 9
15+
#define SRAM_CS -1
16+
#define EPD_RESET 5 // can set to -1 and share with microcontroller Reset!
17+
#define EPD_BUSY 6 // can set to -1 to not use a pin (will wait a fixed delay)
18+
19+
//ThinkInk_154_Tricolor_Z17 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
20+
//ThinkInk_213_Tricolor_RW display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
21+
//ThinkInk_213_Tricolor_Z16 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
22+
//ThinkInk_270_Tricolor_C44 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
23+
//ThinkInk_290_Tricolor_Z10 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
24+
ThinkInk_420_Tricolor_RW display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
25+
26+
void setup() {
27+
Serial.begin(115200);
28+
while (!Serial) { delay(10); }
29+
Serial.println("Adafruit EPD full update test in red/black/white");
30+
display.begin(THINKINK_TRICOLOR);
31+
}
32+
33+
void loop() {
34+
Serial.println("Banner demo");
35+
display.clearBuffer();
36+
display.setTextSize(3);
37+
display.setCursor((display.width() - 144)/2, (display.height() - 24)/2);
38+
display.setTextColor(EPD_BLACK);
39+
display.print("Tri");
40+
display.setTextColor(EPD_RED);
41+
display.print("Color");
42+
display.display();
43+
44+
delay(15000);
45+
46+
Serial.println("Color rectangle demo");
47+
display.clearBuffer();
48+
display.fillRect(display.width()/3, 0, display.width()/3, display.height(), EPD_BLACK);
49+
display.fillRect((display.width()*2)/3, 0, display.width()/3, display.height(), EPD_RED);
50+
display.display();
51+
52+
delay(15000);
53+
54+
Serial.println("Text demo");
55+
// large block of text
56+
display.clearBuffer();
57+
display.setTextSize(1);
58+
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);
59+
display.display();
60+
61+
delay(15000);
62+
63+
display.clearBuffer();
64+
for (int16_t i=0; i<display.width(); i+=4) {
65+
display.drawLine(0, 0, i, display.height()-1, EPD_BLACK);
66+
}
67+
68+
for (int16_t i=0; i<display.height(); i+=4) {
69+
display.drawLine(display.width()-1, 0, 0, i, EPD_RED);
70+
}
71+
display.display();
72+
73+
delay(15000);
74+
}
75+
76+
77+
void testdrawtext(char *text, uint16_t color) {
78+
display.setCursor(0, 0);
79+
display.setTextColor(color);
80+
display.setTextWrap(true);
81+
display.print(text);
82+
}

0 commit comments

Comments
 (0)