Skip to content

Commit 802611c

Browse files
committed
Fixed Inkplate 4 Google Calendar Example
1 parent 0075d0d commit 802611c

File tree

3 files changed

+154
-27
lines changed

3 files changed

+154
-27
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// Picopixel by Sebastian Weber. A tiny font
2+
// with all characters within a 6 pixel height.
3+
4+
const uint8_t PicopixelBitmaps[] PROGMEM = {
5+
0xE8, 0xB4, 0x57, 0xD5, 0xF5, 0x00, 0x4E, 0x3E, 0x80, 0xA5, 0x4A, 0x4A,
6+
0x5A, 0x50, 0xC0, 0x6A, 0x40, 0x95, 0x80, 0xAA, 0x80, 0x5D, 0x00, 0x60,
7+
0xE0, 0x80, 0x25, 0x48, 0x56, 0xD4, 0x75, 0x40, 0xC5, 0x4E, 0xC5, 0x1C,
8+
0x97, 0x92, 0xF3, 0x1C, 0x53, 0x54, 0xE5, 0x48, 0x55, 0x54, 0x55, 0x94,
9+
0xA0, 0x46, 0x64, 0xE3, 0x80, 0x98, 0xC5, 0x04, 0x56, 0xC6, 0x57, 0xDA,
10+
0xD7, 0x5C, 0x72, 0x46, 0xD6, 0xDC, 0xF3, 0xCE, 0xF3, 0x48, 0x72, 0xD4,
11+
0xB7, 0xDA, 0xF8, 0x24, 0xD4, 0xBB, 0x5A, 0x92, 0x4E, 0x8E, 0xEB, 0x58,
12+
0x80, 0x9D, 0xB9, 0x90, 0x56, 0xD4, 0xD7, 0x48, 0x56, 0xD4, 0x40, 0xD7,
13+
0x5A, 0x71, 0x1C, 0xE9, 0x24, 0xB6, 0xD4, 0xB6, 0xA4, 0x8C, 0x6B, 0x55,
14+
0x00, 0xB5, 0x5A, 0xB5, 0x24, 0xE5, 0x4E, 0xEA, 0xC0, 0x91, 0x12, 0xD5,
15+
0xC0, 0x54, 0xF0, 0x90, 0xC7, 0xF0, 0x93, 0x5E, 0x71, 0x80, 0x25, 0xDE,
16+
0x5E, 0x30, 0x6E, 0x80, 0x77, 0x9C, 0x93, 0x5A, 0xB8, 0x45, 0x60, 0x92,
17+
0xEA, 0xAA, 0x40, 0xD5, 0x6A, 0xD6, 0x80, 0x55, 0x00, 0xD7, 0x40, 0x75,
18+
0x90, 0xE8, 0x71, 0xE0, 0xBA, 0x40, 0xB5, 0x80, 0xB5, 0x00, 0x8D, 0x54,
19+
0xAA, 0x80, 0xAC, 0xE0, 0xE5, 0x70, 0x6A, 0x26, 0xFC, 0xC8, 0xAC, 0x5A };
20+
21+
const GFXglyph PicopixelGlyphs[] PROGMEM = {
22+
{ 0, 0, 0, 2, 0, 1 }, // 0x20 ' '
23+
{ 0, 1, 5, 2, 0, -4 }, // 0x21 '!'
24+
{ 1, 3, 2, 4, 0, -4 }, // 0x22 '"'
25+
{ 2, 5, 5, 6, 0, -4 }, // 0x23 '#'
26+
{ 6, 3, 6, 4, 0, -4 }, // 0x24 '$'
27+
{ 9, 3, 5, 4, 0, -4 }, // 0x25 '%'
28+
{ 11, 4, 5, 5, 0, -4 }, // 0x26 '&'
29+
{ 14, 1, 2, 2, 0, -4 }, // 0x27 '''
30+
{ 15, 2, 5, 3, 0, -4 }, // 0x28 '('
31+
{ 17, 2, 5, 3, 0, -4 }, // 0x29 ')'
32+
{ 19, 3, 3, 4, 0, -3 }, // 0x2A '*'
33+
{ 21, 3, 3, 4, 0, -3 }, // 0x2B '+'
34+
{ 23, 2, 2, 3, 0, 0 }, // 0x2C ','
35+
{ 24, 3, 1, 4, 0, -2 }, // 0x2D '-'
36+
{ 25, 1, 1, 2, 0, 0 }, // 0x2E '.'
37+
{ 26, 3, 5, 4, 0, -4 }, // 0x2F '/'
38+
{ 28, 3, 5, 4, 0, -4 }, // 0x30 '0'
39+
{ 30, 2, 5, 3, 0, -4 }, // 0x31 '1'
40+
{ 32, 3, 5, 4, 0, -4 }, // 0x32 '2'
41+
{ 34, 3, 5, 4, 0, -4 }, // 0x33 '3'
42+
{ 36, 3, 5, 4, 0, -4 }, // 0x34 '4'
43+
{ 38, 3, 5, 4, 0, -4 }, // 0x35 '5'
44+
{ 40, 3, 5, 4, 0, -4 }, // 0x36 '6'
45+
{ 42, 3, 5, 4, 0, -4 }, // 0x37 '7'
46+
{ 44, 3, 5, 4, 0, -4 }, // 0x38 '8'
47+
{ 46, 3, 5, 4, 0, -4 }, // 0x39 '9'
48+
{ 48, 1, 3, 2, 0, -3 }, // 0x3A ':'
49+
{ 49, 2, 4, 3, 0, -3 }, // 0x3B ';'
50+
{ 50, 2, 3, 3, 0, -3 }, // 0x3C '<'
51+
{ 51, 3, 3, 4, 0, -3 }, // 0x3D '='
52+
{ 53, 2, 3, 3, 0, -3 }, // 0x3E '>'
53+
{ 54, 3, 5, 4, 0, -4 }, // 0x3F '?'
54+
{ 56, 3, 5, 4, 0, -4 }, // 0x40 '@'
55+
{ 58, 3, 5, 4, 0, -4 }, // 0x41 'A'
56+
{ 60, 3, 5, 4, 0, -4 }, // 0x42 'B'
57+
{ 62, 3, 5, 4, 0, -4 }, // 0x43 'C'
58+
{ 64, 3, 5, 4, 0, -4 }, // 0x44 'D'
59+
{ 66, 3, 5, 4, 0, -4 }, // 0x45 'E'
60+
{ 68, 3, 5, 4, 0, -4 }, // 0x46 'F'
61+
{ 70, 3, 5, 4, 0, -4 }, // 0x47 'G'
62+
{ 72, 3, 5, 4, 0, -4 }, // 0x48 'H'
63+
{ 74, 1, 5, 2, 0, -4 }, // 0x49 'I'
64+
{ 75, 3, 5, 4, 0, -4 }, // 0x4A 'J'
65+
{ 77, 3, 5, 4, 0, -4 }, // 0x4B 'K'
66+
{ 79, 3, 5, 4, 0, -4 }, // 0x4C 'L'
67+
{ 81, 5, 5, 6, 0, -4 }, // 0x4D 'M'
68+
{ 85, 4, 5, 5, 0, -4 }, // 0x4E 'N'
69+
{ 88, 3, 5, 4, 0, -4 }, // 0x4F 'O'
70+
{ 90, 3, 5, 4, 0, -4 }, // 0x50 'P'
71+
{ 92, 3, 6, 4, 0, -4 }, // 0x51 'Q'
72+
{ 95, 3, 5, 4, 0, -4 }, // 0x52 'R'
73+
{ 97, 3, 5, 4, 0, -4 }, // 0x53 'S'
74+
{ 99, 3, 5, 4, 0, -4 }, // 0x54 'T'
75+
{ 101, 3, 5, 4, 0, -4 }, // 0x55 'U'
76+
{ 103, 3, 5, 4, 0, -4 }, // 0x56 'V'
77+
{ 105, 5, 5, 6, 0, -4 }, // 0x57 'W'
78+
{ 109, 3, 5, 4, 0, -4 }, // 0x58 'X'
79+
{ 111, 3, 5, 4, 0, -4 }, // 0x59 'Y'
80+
{ 113, 3, 5, 4, 0, -4 }, // 0x5A 'Z'
81+
{ 115, 2, 5, 3, 0, -4 }, // 0x5B '['
82+
{ 117, 3, 5, 4, 0, -4 }, // 0x5C '\'
83+
{ 119, 2, 5, 3, 0, -4 }, // 0x5D ']'
84+
{ 121, 3, 2, 4, 0, -4 }, // 0x5E '^'
85+
{ 122, 4, 1, 4, 0, 1 }, // 0x5F '_'
86+
{ 123, 2, 2, 3, 0, -4 }, // 0x60 '`'
87+
{ 124, 3, 4, 4, 0, -3 }, // 0x61 'a'
88+
{ 126, 3, 5, 4, 0, -4 }, // 0x62 'b'
89+
{ 128, 3, 3, 4, 0, -2 }, // 0x63 'c'
90+
{ 130, 3, 5, 4, 0, -4 }, // 0x64 'd'
91+
{ 132, 3, 4, 4, 0, -3 }, // 0x65 'e'
92+
{ 134, 2, 5, 3, 0, -4 }, // 0x66 'f'
93+
{ 136, 3, 5, 4, 0, -3 }, // 0x67 'g'
94+
{ 138, 3, 5, 4, 0, -4 }, // 0x68 'h'
95+
{ 140, 1, 5, 2, 0, -4 }, // 0x69 'i'
96+
{ 141, 2, 6, 3, 0, -4 }, // 0x6A 'j'
97+
{ 143, 3, 5, 4, 0, -4 }, // 0x6B 'k'
98+
{ 145, 2, 5, 3, 0, -4 }, // 0x6C 'l'
99+
{ 147, 5, 3, 6, 0, -2 }, // 0x6D 'm'
100+
{ 149, 3, 3, 4, 0, -2 }, // 0x6E 'n'
101+
{ 151, 3, 3, 4, 0, -2 }, // 0x6F 'o'
102+
{ 153, 3, 4, 4, 0, -2 }, // 0x70 'p'
103+
{ 155, 3, 4, 4, 0, -2 }, // 0x71 'q'
104+
{ 157, 2, 3, 3, 0, -2 }, // 0x72 'r'
105+
{ 158, 3, 4, 4, 0, -3 }, // 0x73 's'
106+
{ 160, 2, 5, 3, 0, -4 }, // 0x74 't'
107+
{ 162, 3, 3, 4, 0, -2 }, // 0x75 'u'
108+
{ 164, 3, 3, 4, 0, -2 }, // 0x76 'v'
109+
{ 166, 5, 3, 6, 0, -2 }, // 0x77 'w'
110+
{ 168, 3, 3, 4, 0, -2 }, // 0x78 'x'
111+
{ 170, 3, 4, 4, 0, -2 }, // 0x79 'y'
112+
{ 172, 3, 4, 4, 0, -3 }, // 0x7A 'z'
113+
{ 174, 3, 5, 4, 0, -4 }, // 0x7B '{'
114+
{ 176, 1, 6, 2, 0, -4 }, // 0x7C '|'
115+
{ 177, 3, 5, 4, 0, -4 }, // 0x7D '}'
116+
{ 179, 4, 2, 5, 0, -3 } }; // 0x7E '~'
117+
118+
const GFXfont Picopixel PROGMEM = {
119+
(uint8_t *)PicopixelBitmaps,
120+
(GFXglyph *)PicopixelGlyphs,
121+
0x20, 0x7E, 7 };
122+
123+
// Approx. 852 bytes

examples/Inkplate4/Projects/Inkplate4_Google_Calendar/Inkplate4_Google_Calendar.ino

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
// Including fonts
3838
#include "Fonts/FreeSans12pt7b.h"
3939
#include "Fonts/FreeSans9pt7b.h"
40+
#include "Fonts/Picopixel.h"
4041

4142
// Includes
4243
#include "Network.h"
@@ -46,13 +47,13 @@
4647
// --------------- CHANGE HERE ----------------:
4748

4849
// Enter your WiFi credentials
49-
char ssid[] = "Soldered";
50-
char pass[] = "dasduino";
50+
char ssid[] = "";
51+
char pass[] = "";
5152

5253
// Secret address in iCal format
53-
char calendarURL[] = "https://calendar.google.com/calendar/ical/robert%40soldered.com/private-bc147845014b4905f9fed21bea8d25c3/basic.ics";
54+
char calendarURL[] = "";
5455

55-
int timeZone = 1; // 2 means UTC+2
56+
int timeZone = 2; // 2 means UTC+2
5657

5758
// Delay between API calls in seconds
5859
#define DELAY_SECS 4 * 60 // Every 4 minutes
@@ -197,16 +198,16 @@ void drawGrid()
197198
int n = 1, m = 4;
198199

199200
// Line drawing
200-
display.drawThickLine(x1, y1 + header, x2, y1 + header, INKPLATE_BLACK, 1.0);
201+
display.drawThickLine(x1, y1 + header, x2, y1 + header, INKPLATE_BLACK, 0.5);
201202
for (int i = 0; i < n + 1; ++i)
202203
{
203204
display.drawThickLine(x1, (int)((float)y1 + (float)i * (float)(y2 - y1) / (float)n), x2,
204-
(int)((float)y1 + (float)i * (float)(y2 - y1) / (float)n), INKPLATE_BLACK, 1.0);
205+
(int)((float)y1 + (float)i * (float)(y2 - y1) / (float)n), INKPLATE_BLACK, 0.5);
205206
}
206207
for (int i = 0; i < m + 1; ++i)
207208
{
208209
display.drawThickLine((int)((float)x1 + (float)i * (float)(x2 - x1) / (float)m), y1,
209-
(int)((float)x1 + (float)i * (float)(x2 - x1) / (float)m), y2, INKPLATE_BLACK, 1.0);
210+
(int)((float)x1 + (float)i * (float)(x2 - x1) / (float)m), y2, INKPLATE_BLACK, 0.5);
210211
display.setFont();
211212

212213
// Display day info using time offset
@@ -215,7 +216,7 @@ void drawGrid()
215216
temp[10] = 0;
216217

217218
// calculate where to put text and print it
218-
display.setCursor(5 + (int)((float)x1 + (float)i * (float)(x2 - x1) / (float)m) + 15, y1 + header - 10);
219+
display.setCursor(5 + (int)((float)x1 + (float)i * (float)(x2 - x1) / (float)m) + 15, y1 + header - 12);
219220
display.println(temp);
220221
}
221222
}
@@ -295,7 +296,7 @@ void getToFrom(char *dst, char *from, char *to, int *day, int *timeStamp)
295296
bool drawEvent(entry *event, int day, int beginY, int maxHeigth, int *heigthNeeded)
296297
{
297298
// Upper left coordintes
298-
int x1 = 3 + 4 + (954 / 4) * day;
299+
int x1 = 4 + (396 / 4) * day;
299300
int y1 = beginY + 3;
300301

301302
// Setting text font
@@ -307,7 +308,7 @@ bool drawEvent(entry *event, int day, int beginY, int maxHeigth, int *heigthNeed
307308

308309
// Insert line brakes into setTextColor
309310
int lastSpace = -100;
310-
display.setCursor(x1 + 5, beginY + 26);
311+
display.setCursor(x1 + 9 - day, beginY+5);
311312
for (int i = 0; i < min((size_t)64, strlen(event->name)); ++i)
312313
{
313314
// Copy name letter by letter and check if it overflows space given
@@ -323,7 +324,7 @@ bool drawEvent(entry *event, int day, int beginY, int maxHeigth, int *heigthNeed
323324
display.getTextBounds(line, 0, 0, &xt1, &yt1, &w, &h);
324325

325326
// Char out of bounds, put in next line
326-
if (w > display.width() / 4 - 30)
327+
if (w > display.width() / 4 - 18)
327328
{
328329
// if there was a space 5 chars before, break line there
329330
if (n - lastSpace < 5)
@@ -333,7 +334,7 @@ bool drawEvent(entry *event, int day, int beginY, int maxHeigth, int *heigthNeed
333334
}
334335

335336
// Print text line
336-
display.setCursor(x1 + 5, display.getCursorY());
337+
display.setCursor(x1 + 9 - day, display.getCursorY());
337338
display.println(line);
338339

339340
// Clears line (null termination on first charachter)
@@ -343,11 +344,11 @@ bool drawEvent(entry *event, int day, int beginY, int maxHeigth, int *heigthNeed
343344
}
344345

345346
// display last line
346-
display.setCursor(x1 + 5, display.getCursorY());
347+
display.setCursor(x1 + 9 - day, display.getCursorY());
347348
display.println(line);
348349

349350
// Set cursor on same y but change x
350-
display.setCursor(x1 + 3, display.getCursorY());
351+
display.setCursor(x1 + 16 - day, display.getCursorY() + 10);
351352
display.setFont();
352353

353354
// Print time
@@ -356,7 +357,7 @@ bool drawEvent(entry *event, int day, int beginY, int maxHeigth, int *heigthNeed
356357
{
357358
display.println(event->time);
358359

359-
display.setCursor(x1 + 5, display.getCursorY());
360+
display.setCursor(x1 + 6, display.getCursorY()+10);
360361

361362
char line[128] = {0};
362363

@@ -386,22 +387,22 @@ bool drawEvent(entry *event, int day, int beginY, int maxHeigth, int *heigthNeed
386387
display.print(event->time);
387388
}
388389

389-
int bx1 = x1 + 2;
390+
int bx1 = x1 + 3 - day;
390391
int by1 = y1;
391392
int bx2 = x1 + display.width() / 4 - 7;
392-
int by2 = display.getCursorY() + 7;
393+
int by2 = display.getCursorY() + 10;
393394

394395
// Draw event rect bounds
395-
display.drawThickLine(bx1, by1, bx1, by2, INKPLATE_BLACK, 1.0);
396-
display.drawThickLine(bx1, by2, bx2, by2, INKPLATE_BLACK, 1.0);
397-
display.drawThickLine(bx2, by2, bx2, by1, INKPLATE_BLACK, 1.0);
398-
display.drawThickLine(bx2, by1, bx1, by1, INKPLATE_BLACK, 1.0);
396+
display.drawThickLine(bx1, by1, bx1, by2, INKPLATE_RED, 0.5);
397+
display.drawThickLine(bx1, by2, bx2, by2, INKPLATE_RED, 0.5);
398+
display.drawThickLine(bx2, by2, bx2, by1, INKPLATE_RED, 0.5);
399+
display.drawThickLine(bx2, by1, bx1, by1, INKPLATE_RED, 0.5);
399400

400401
// Set how high is the event
401402
*heigthNeeded = display.getCursorY() + 12 - y1;
402403

403404
// Return is it overflowing
404-
return display.getCursorY() < maxHeigth - 5;
405+
return display.getCursorY() < maxHeigth - 6;
405406
}
406407

407408
// Struct event comparison function, by timestamp, used for qsort later on
@@ -475,7 +476,7 @@ void drawData()
475476

476477
// We store how much height did one event take up
477478
int shift = 0;
478-
bool s = drawEvent(&entries[i], entries[i].day, columns[entries[i].day] + 64, E_INK_HEIGHT - 4, &shift);
479+
bool s = drawEvent(&entries[i], entries[i].day, columns[entries[i].day] + 32, E_INK_HEIGHT - 6, &shift);
479480

480481
columns[entries[i].day] += shift;
481482

@@ -493,11 +494,13 @@ void drawData()
493494
if (clogged[i])
494495
{
495496
// Draw notification showing that there are more events than drawn ones
496-
display.fillRoundRect(5 + i * ((E_INK_WIDTH - 4) / 4), 540 - 24, ((E_INK_WIDTH - 4) / 4) - 5, 20, 10, INKPLATE_BLACK);
497-
display.setCursor(65 + i * ((E_INK_WIDTH - 4) / 4), 532);
498-
display.setFont();
497+
display.fillRoundRect(6 + i * ((E_INK_WIDTH - 4) / 4) - i, 300 - 24, ((E_INK_WIDTH - 4) / 4) - 5, 20, 10, INKPLATE_WHITE);
498+
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);
500+
Serial.println(display.getCursorY());
501+
display.setFont(&Picopixel);
499502
display.print(cloggedCount[i]);
500-
display.print(" more events");
503+
display.print(" more events...");
501504
}
502505
}
503506
}

examples/Inkplate4/Projects/Inkplate4_Google_Calendar/Network.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ bool Network::getData(char *calendarURL, char *data)
9696
HTTPClient http;
9797
http.getStream().setTimeout(10);
9898
http.getStream().flush();
99+
http.getStream().setNoDelay(true);
99100

100101
// Begin http by passing url to it
101102
http.begin(calendarURL);

0 commit comments

Comments
 (0)