Skip to content

Commit ec1a3b6

Browse files
committed
Added Inkplate 4 examples
1 parent 802611c commit ec1a3b6

File tree

5 files changed

+542
-1
lines changed

5 files changed

+542
-1
lines changed

examples/Inkplate4/Projects/Inkplate4_Google_Calendar/Inkplate4_Google_Calendar.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ void drawData()
496496
// Draw notification showing that there are more events than drawn ones
497497
display.fillRoundRect(6 + i * ((E_INK_WIDTH - 4) / 4) - i, 300 - 24, ((E_INK_WIDTH - 4) / 4) - 5, 20, 10, INKPLATE_WHITE);
498498
display.drawRoundRect(6 + i * ((E_INK_WIDTH - 4) / 4) - i, 300 - 24, ((E_INK_WIDTH - 4) / 4) - 5, 20, 10, INKPLATE_BLACK);
499-
display.setCursor(26 + i * ((E_INK_WIDTH - 3) / 4), (i == 0) ? 280 : 287);
499+
display.setCursor(26 + i * ((E_INK_WIDTH - 3) / 4), 280);
500500
Serial.println(display.getCursorY());
501501
display.setFont(&Picopixel);
502502
display.print(cloggedCount[i]);
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
const uint8_t LoveLetter_Regular10Bitmaps[] PROGMEM = {
2+
0x00, 0xFE, 0x40, 0xB6, 0x80, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
3+
0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81,
4+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81,
5+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81,
6+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xE0, 0xFF, 0x81,
7+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF,
8+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF,
9+
0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
10+
0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
11+
0x81, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
12+
0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81,
13+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81,
14+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81,
15+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81,
16+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81,
17+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF,
18+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF,
19+
0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
20+
0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
21+
0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
22+
0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
23+
0x81, 0x81, 0x81, 0xFF, 0xC0, 0x04, 0xC0, 0x06, 0x00, 0xFF, 0x81, 0x81,
24+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81,
25+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF,
26+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF,
27+
0x76, 0xA5, 0x23, 0x11, 0x08, 0x02, 0x00, 0xFF, 0x81, 0x81, 0x81, 0x81,
28+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0x18, 0x18, 0x24, 0x24,
29+
0x24, 0x7C, 0x42, 0x82, 0x82, 0x81, 0xF9, 0x0A, 0x14, 0x6B, 0x90, 0xA0,
30+
0xC1, 0x87, 0xF0, 0x3C, 0xC5, 0x0C, 0x08, 0x10, 0x20, 0x20, 0x62, 0x78,
31+
0xC2, 0x48, 0xA1, 0x86, 0x18, 0x62, 0xF0, 0x7E, 0x08, 0x20, 0xF2, 0x08,
32+
0x20, 0x83, 0xF0, 0xFA, 0x08, 0x20, 0x83, 0xC8, 0x20, 0x82, 0x00, 0x3C,
33+
0x62, 0xC0, 0x80, 0x80, 0x87, 0x83, 0xC3, 0x45, 0x38, 0x81, 0x06, 0x0C,
34+
0x28, 0x5F, 0xA1, 0x42, 0x85, 0x08, 0xFF, 0xC0, 0x11, 0x11, 0x11, 0x11,
35+
0x99, 0x96, 0x05, 0x12, 0x45, 0x8A, 0x1C, 0x24, 0x48, 0x89, 0x12, 0x10,
36+
0x42, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x0F, 0xC0, 0xB8, 0xD5, 0x2F,
37+
0x18, 0xE3, 0x1C, 0x63, 0x0C, 0x61, 0x0C, 0x21, 0x84, 0x50, 0x88, 0x01,
38+
0xC1, 0xE1, 0xA1, 0x91, 0x99, 0x89, 0x85, 0x85, 0x83, 0x80, 0x1C, 0x62,
39+
0x41, 0x81, 0x99, 0x99, 0x81, 0x82, 0x46, 0x3C, 0x64, 0xE3, 0x19, 0x72,
40+
0x10, 0x84, 0x00, 0x3C, 0x66, 0x43, 0x81, 0x81, 0x99, 0x81, 0xC2, 0x44,
41+
0x3A, 0xFA, 0x38, 0x61, 0x8A, 0xC9, 0xA2, 0x86, 0x10, 0x74, 0x63, 0x06,
42+
0x08, 0x31, 0x8B, 0x80, 0xFF, 0x04, 0x02, 0x01, 0x00, 0x80, 0x40, 0x20,
43+
0x10, 0x08, 0x00, 0x83, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xE3, 0x3C, 0x03,
44+
0x06, 0x0A, 0x14, 0x48, 0x89, 0x14, 0x18, 0x30, 0x80, 0x30, 0x86, 0x30,
45+
0xC5, 0x18, 0xA4, 0x94, 0x94, 0x92, 0x8A, 0x51, 0x84, 0x10, 0x40, 0xA0,
46+
0x88, 0x82, 0xC1, 0x40, 0x40, 0x60, 0x48, 0x42, 0x21, 0x20, 0x40, 0x03,
47+
0x05, 0x12, 0x22, 0x82, 0x04, 0x08, 0x10, 0x20, 0x7D, 0x08, 0x20, 0x41,
48+
0x04, 0x10, 0x20, 0x83, 0xFC, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
49+
0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81,
50+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81, 0x81,
51+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81,
52+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81,
53+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81,
54+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0x39,
55+
0x18, 0xE3, 0x95, 0x90, 0x82, 0x08, 0x2E, 0xEF, 0x1C, 0x61, 0x87, 0x23,
56+
0x00, 0x72, 0x61, 0x08, 0x41, 0x2E, 0x04, 0x10, 0x41, 0x05, 0xDC, 0xE1,
57+
0x86, 0x1C, 0xDD, 0x39, 0xAC, 0xA6, 0xE2, 0x04, 0x5E, 0x3B, 0x11, 0xE4,
58+
0x21, 0x08, 0x42, 0x10, 0x74, 0xE3, 0x19, 0xB4, 0x21, 0xC9, 0x80, 0x82,
59+
0x08, 0x26, 0xAF, 0x1C, 0x61, 0x86, 0x18, 0x40, 0x45, 0x55, 0x50, 0x20,
60+
0x12, 0x49, 0x24, 0x95, 0x80, 0x82, 0x08, 0x21, 0x8A, 0x4A, 0x3C, 0x8A,
61+
0x28, 0x40, 0x12, 0x49, 0x24, 0x97, 0x00, 0x3B, 0xBA, 0x9C, 0x46, 0x11,
62+
0x84, 0x61, 0x18, 0x84, 0x19, 0x4B, 0x0E, 0x1C, 0x38, 0x60, 0x80, 0x3C,
63+
0x8E, 0x0C, 0x18, 0x30, 0x51, 0x1C, 0x73, 0x28, 0x61, 0x86, 0x18, 0xBE,
64+
0x82, 0x08, 0x00, 0x38, 0x62, 0x20, 0x90, 0x48, 0x26, 0x11, 0x18, 0x74,
65+
0x02, 0x01, 0x40, 0xC0, 0x60, 0x82, 0xEE, 0x30, 0x82, 0x08, 0x20, 0x74,
66+
0xE2, 0xC1, 0xC6, 0x2E, 0x42, 0x3C, 0x84, 0x21, 0x08, 0x49, 0x80, 0x86,
67+
0x18, 0x61, 0x86, 0x3C, 0xDD, 0x06, 0x14, 0x52, 0x48, 0xA3, 0x0C, 0x80,
68+
0xA2, 0x28, 0xC9, 0x32, 0x4C, 0x93, 0x25, 0x30, 0xCC, 0x85, 0x22, 0x8C,
69+
0x30, 0xA4, 0xA1, 0x82, 0x14, 0x51, 0x44, 0xB3, 0xC1, 0x85, 0x23, 0x80,
70+
0x79, 0x12, 0x20, 0x82, 0x09, 0x21, 0x7E, 0xFF, 0x81, 0x81, 0x81, 0x81,
71+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81, 0x81,
72+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81, 0x81,
73+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0xFF, 0x81,
74+
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF };
75+
76+
const GFXglyph LoveLetter_Regular10Glyphs[] PROGMEM = {
77+
{ 0, 1, 1, 4, 0, 0 }, // 0x20 ' '
78+
{ 1, 1, 10, 4, 2, -11 }, // 0x21 '!'
79+
{ 3, 3, 4, 4, 1, -11 }, // 0x22 '"'
80+
{ 5, 8, 13, 9, 0, -12 }, // 0x23 '#'
81+
{ 18, 8, 13, 9, 0, -12 }, // 0x24 '$'
82+
{ 31, 8, 13, 9, 0, -12 }, // 0x25 '%'
83+
{ 44, 8, 13, 9, 0, -12 }, // 0x26 '&'
84+
{ 57, 1, 3, 3, 1, -10 }, // 0x27 '''
85+
{ 58, 8, 13, 9, 0, -12 }, // 0x28 '('
86+
{ 71, 8, 13, 9, 0, -12 }, // 0x29 ')'
87+
{ 84, 8, 13, 9, 0, -12 }, // 0x2A '*'
88+
{ 97, 8, 13, 9, 0, -12 }, // 0x2B '+'
89+
{ 110, 1, 3, 3, 1, -3 }, // 0x2C ','
90+
{ 111, 8, 1, 13, 5, -8 }, // 0x2D '-'
91+
{ 112, 2, 1, 3, 1, -2 }, // 0x2E '.'
92+
{ 113, 8, 13, 9, 0, -12 }, // 0x2F '/'
93+
{ 126, 8, 13, 9, 0, -12 }, // 0x30 '0'
94+
{ 139, 8, 13, 9, 0, -12 }, // 0x31 '1'
95+
{ 152, 8, 13, 9, 0, -12 }, // 0x32 '2'
96+
{ 165, 8, 13, 9, 0, -12 }, // 0x33 '3'
97+
{ 178, 8, 13, 9, 0, -12 }, // 0x34 '4'
98+
{ 191, 8, 13, 9, 0, -12 }, // 0x35 '5'
99+
{ 204, 8, 13, 9, 0, -12 }, // 0x36 '6'
100+
{ 217, 8, 13, 9, 0, -12 }, // 0x37 '7'
101+
{ 230, 8, 13, 9, 0, -12 }, // 0x38 '8'
102+
{ 243, 8, 13, 9, 0, -12 }, // 0x39 '9'
103+
{ 256, 2, 7, 3, 1, -8 }, // 0x3A ':'
104+
{ 258, 2, 9, 3, 1, -9 }, // 0x3B ';'
105+
{ 261, 8, 13, 9, 0, -12 }, // 0x3C '<'
106+
{ 274, 8, 13, 9, 0, -12 }, // 0x3D '='
107+
{ 287, 8, 13, 9, 0, -12 }, // 0x3E '>'
108+
{ 300, 5, 10, 6, 1, -11 }, // 0x3F '?'
109+
{ 307, 8, 13, 9, 0, -12 }, // 0x40 '@'
110+
{ 320, 8, 10, 10, 1, -11 }, // 0x41 'A'
111+
{ 330, 7, 10, 9, 1, -11 }, // 0x42 'B'
112+
{ 339, 7, 10, 8, 1, -11 }, // 0x43 'C'
113+
{ 348, 6, 9, 8, 1, -10 }, // 0x44 'D'
114+
{ 355, 6, 10, 7, 1, -11 }, // 0x45 'E'
115+
{ 363, 6, 10, 7, 1, -11 }, // 0x46 'F'
116+
{ 371, 8, 10, 10, 1, -11 }, // 0x47 'G'
117+
{ 381, 7, 10, 9, 1, -11 }, // 0x48 'H'
118+
{ 390, 1, 10, 3, 1, -11 }, // 0x49 'I'
119+
{ 392, 4, 12, 6, 1, -11 }, // 0x4A 'J'
120+
{ 398, 7, 11, 8, 1, -12 }, // 0x4B 'K'
121+
{ 408, 6, 11, 8, 1, -12 }, // 0x4C 'L'
122+
{ 417, 11, 10, 13, 1, -11 }, // 0x4D 'M'
123+
{ 431, 8, 11, 11, 2, -12 }, // 0x4E 'N'
124+
{ 442, 8, 10, 10, 1, -11 }, // 0x4F 'O'
125+
{ 452, 5, 10, 8, 2, -11 }, // 0x50 'P'
126+
{ 459, 8, 10, 10, 1, -11 }, // 0x51 'Q'
127+
{ 469, 6, 10, 9, 2, -11 }, // 0x52 'R'
128+
{ 477, 5, 10, 7, 1, -11 }, // 0x53 'S'
129+
{ 484, 9, 9, 10, 1, -11 }, // 0x54 'T'
130+
{ 495, 7, 9, 9, 1, -10 }, // 0x55 'U'
131+
{ 503, 7, 10, 9, 1, -11 }, // 0x56 'V'
132+
{ 512, 11, 10, 13, 2, -11 }, // 0x57 'W'
133+
{ 526, 9, 11, 10, 1, -12 }, // 0x58 'X'
134+
{ 539, 7, 10, 9, 1, -11 }, // 0x59 'Y'
135+
{ 548, 7, 10, 10, 2, -11 }, // 0x5A 'Z'
136+
{ 557, 8, 13, 9, 0, -12 }, // 0x5B '['
137+
{ 570, 8, 13, 9, 0, -12 }, // 0x5C '\'
138+
{ 583, 8, 13, 9, 0, -12 }, // 0x5D ']'
139+
{ 596, 8, 13, 9, 0, -12 }, // 0x5E '^'
140+
{ 609, 8, 13, 9, 0, -12 }, // 0x5F '_'
141+
{ 622, 8, 13, 9, 0, -12 }, // 0x60 '`'
142+
{ 635, 6, 6, 8, 1, -7 }, // 0x61 'a'
143+
{ 640, 6, 11, 8, 1, -12 }, // 0x62 'b'
144+
{ 649, 5, 8, 7, 1, -9 }, // 0x63 'c'
145+
{ 654, 6, 12, 8, 1, -13 }, // 0x64 'd'
146+
{ 663, 6, 8, 7, 1, -9 }, // 0x65 'e'
147+
{ 669, 5, 11, 7, 2, -12 }, // 0x66 'f'
148+
{ 676, 5, 10, 8, 2, -8 }, // 0x67 'g'
149+
{ 683, 6, 11, 9, 2, -12 }, // 0x68 'h'
150+
{ 692, 2, 10, 4, 1, -11 }, // 0x69 'i'
151+
{ 695, 3, 14, 6, 2, -12 }, // 0x6A 'j'
152+
{ 701, 6, 11, 7, 1, -12 }, // 0x6B 'k'
153+
{ 710, 3, 11, 4, 1, -12 }, // 0x6C 'l'
154+
{ 715, 10, 7, 13, 2, -8 }, // 0x6D 'm'
155+
{ 724, 7, 7, 9, 1, -8 }, // 0x6E 'n'
156+
{ 731, 7, 8, 9, 1, -9 }, // 0x6F 'o'
157+
{ 738, 6, 11, 9, 2, -9 }, // 0x70 'p'
158+
{ 747, 9, 12, 10, 1, -9 }, // 0x71 'q'
159+
{ 761, 6, 8, 7, 1, -9 }, // 0x72 'r'
160+
{ 767, 5, 8, 7, 1, -9 }, // 0x73 's'
161+
{ 772, 5, 10, 6, 1, -11 }, // 0x74 't'
162+
{ 779, 6, 8, 8, 1, -9 }, // 0x75 'u'
163+
{ 785, 6, 8, 8, 2, -9 }, // 0x76 'v'
164+
{ 791, 10, 8, 11, 1, -9 }, // 0x77 'w'
165+
{ 801, 6, 8, 8, 1, -9 }, // 0x78 'x'
166+
{ 807, 6, 11, 9, 2, -8 }, // 0x79 'y'
167+
{ 816, 7, 8, 8, 1, -9 }, // 0x7A 'z'
168+
{ 823, 8, 13, 9, 0, -12 }, // 0x7B '{'
169+
{ 836, 8, 13, 9, 0, -12 }, // 0x7C '|'
170+
{ 849, 8, 13, 9, 0, -12 }, // 0x7D '}'
171+
{ 862, 8, 13, 9, 0, -12 } }; // 0x7E '~'
172+
173+
const GFXfont LoveLetter_Regular10 PROGMEM = {
174+
(uint8_t *)LoveLetter_Regular10Bitmaps,
175+
(GFXglyph *)LoveLetter_Regular10Glyphs,
176+
0x20, 0x7E, 17 };
177+
178+
// Approx. 1548 bytes
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*
2+
Inkplate4_Quotables example for Soldered Inkplate 4
3+
For this example you will need only USB cable, Inkplate 4 and a WiFi with stable Internet connection.
4+
Select "Soldered Inkplate4" from Tools -> Board menu.
5+
Don't have "Soldered Inkplate4" option? Follow our tutorial and add it:
6+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
7+
8+
This example shows you how to use simple API call without API key. Response
9+
from server is in JSON format, so that will be shown too how it is used. What happens
10+
here is basically ESP32 connects to WiFi and sends API call and server returns HTML
11+
document containing one quote and some information about it, then using library ArduinoJSON
12+
we extract only quote from JSON data and show it on Inkplate 4. After displaying quote
13+
ESP32 goes to sleep and wakes up every 300 seconds to show new quote(you can change time interval).
14+
15+
IMPORTANT:
16+
Make sure to change wifi credentials below
17+
Also have ArduinoJSON installed in your Arduino libraries, download here: https://arduinojson.org/
18+
You can deserialize JSON data easily using JSON assistant https://arduinojson.org/v6/assistant/
19+
20+
Want to learn more about Inkplate? Visit www.inkplate.io
21+
Looking to get support? Write on our forums: https://forum.soldered.com/
22+
7 April 2022 by Soldered
23+
*/
24+
25+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
26+
#ifndef ARDUINO_INKPLATE4
27+
#error "Wrong board selection for this example, please select Soldered Inkplate4 in the boards menu."
28+
#endif
29+
30+
#include "Inkplate.h" // Include Inkplate library to the sketch
31+
32+
#include "Network.h" // Our networking functions, declared in Network.cpp
33+
34+
#include "Fonts/LoveLetter_Regular10.h" // Include fonts used
35+
36+
// Delay between API calls in seconds, 300 seconds is 5 minutes
37+
#define DELAY_S 300
38+
39+
// create object with all networking functions
40+
Network network;
41+
42+
// create display object
43+
Inkplate display;
44+
45+
// Put in your ssid and password
46+
char ssid[] = "";
47+
char pass[] = "";
48+
49+
// Buffers to store quote, author name and quote length
50+
char quote[256];
51+
char author[64];
52+
int len;
53+
54+
void setup()
55+
{
56+
// Begin serial communitcation, used for debugging
57+
Serial.begin(115200);
58+
59+
// Initial display settings
60+
display.begin();
61+
display.setTextWrap(true); // Set text wrapping to true
62+
display.setTextColor(INKPLATE_BLACK, INKPLATE_WHITE);
63+
64+
// Our begin function
65+
network.begin(ssid, pass);
66+
67+
// Try to get the new random quote from the Internet.
68+
while (!network.getData(quote, author, &len, &display))
69+
{
70+
Serial.println("Retrying retriving data!");
71+
delay(1000);
72+
}
73+
74+
// Our main drawing function
75+
drawAll();
76+
// Full refresh
77+
display.display();
78+
79+
// Go to sleep before checking again
80+
// This is set in microseconds, so it needs to be
81+
// multiplied by million to get seconds
82+
esp_sleep_enable_timer_wakeup(1000000 * DELAY_S); // Activate wake-up timer
83+
display.setPanelDeepSleep(0); // Put the panel into deep sleep
84+
esp_deep_sleep_start(); // Put ESP32 into deep sleep. Program stops here
85+
}
86+
87+
void loop()
88+
{
89+
// Never here! If you are using deep sleep, the whole program should be in setup() because the board restarts each
90+
// time. loop() must be empty!
91+
}
92+
93+
// Our main drawing function
94+
void drawAll()
95+
{
96+
// Print quote
97+
display.setFont(&LoveLetter_Regular10); // Set custom font
98+
display.setTextSize(2);
99+
display.setTextColor(INKPLATE_BLACK, INKPLATE_WHITE);
100+
printQuote();
101+
102+
// Print author in red
103+
display.setTextSize(1);
104+
display.setCursor(20, 295);
105+
display.setTextColor(INKPLATE_RED, INKPLATE_WHITE);
106+
display.print("-");
107+
display.println(author);
108+
}
109+
110+
void printQuote()
111+
{
112+
int currentChar = 0;
113+
char currentWordBuf[128] = {0};
114+
display.setCursor(20, 35);
115+
bool lastWord = false;
116+
int currentRow = 0;
117+
118+
while (1)
119+
{
120+
// Start from the current char
121+
int i = currentChar;
122+
while (quote[i] != ' ') // Find the next space
123+
{
124+
i++; // Finds the index where the current word ends
125+
if (i > len)
126+
lastWord = true; // If we went further than index, we're in the last word
127+
}
128+
129+
// Clear current word buffer and copy the current word substring in it
130+
memset(currentWordBuf, 0, 128);
131+
132+
if (!lastWord)
133+
{
134+
// copy currently observed part of the string as the current word
135+
memcpy(currentWordBuf, quote + currentChar, i - currentChar);
136+
}
137+
else
138+
{
139+
// If it's the last word, copy it until the ending
140+
memcpy(currentWordBuf, quote + currentChar, len - currentChar);
141+
}
142+
143+
int16_t x1, y1;
144+
uint16_t w, h;
145+
146+
// Check if the current word will go out of bounds
147+
display.getTextBounds(currentWordBuf, display.getCursorX(), display.getCursorY(), &x1, &y1, &w, &h);
148+
if ((x1 + w) > 380)
149+
{
150+
// Print in new row if it will
151+
currentRow++;
152+
// Offset for each row is 31 pixels
153+
// +35 for the first row
154+
display.setCursor(20, (31 * currentRow) + 35);
155+
}
156+
157+
// Print word and space
158+
display.print(currentWordBuf);
159+
display.print(" ");
160+
161+
// If we've reached the last word, end the print
162+
if (lastWord)
163+
return;
164+
165+
currentChar = i + 1;
166+
}
167+
}

0 commit comments

Comments
 (0)