-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinkplate6.ino
81 lines (66 loc) · 1.96 KB
/
inkplate6.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef ARDUINO_ESP32_DEV
#error "Wrong board selection for this project, please select Inkplate 6 in the boards menu."
#endif
#include "Inkplate.h"
#include "Network.h"
#include "DTWWidget.h"
#include "GCalEventListWidget.h"
#define DELAY_MS 60000
// display object
Inkplate display(INKPLATE_1BIT);
// network object
Network network;
// variable for counting partial refreshes
RTC_DATA_ATTR unsigned refreshes = 0;
// constant to determine when to full update
const int fullRefresh = 10;
// Set up the board
void setup() {
Serial.begin(115200);
// This must be called before anything else
display.begin();
// Set rotation of the screen 1-4 (1 & 3 = portrait, 2 & 4 = landscape)
// If changing to portrait, change Widget.cpp resolution as well
display.setRotation(4);
display.setTextWrap(false);
// Partial update only works with 1bit mode
display.setDisplayMode(INKPLATE_1BIT);
// Initial screen and network setup
if (refreshes == 0)
{
display.setTextColor(BLACK);
display.setCursor(60, 230);
display.setTextSize(3);
display.println(F("Welcome!"));
display.setCursor(60, 280);
display.println(F("Connecting to WiFi..."));
display.display();
delay(1000);
network.init(WIFI_SSID, WIFI_PASSWORD);
display.clearDisplay();
}
}
void loop() {
bool partialUpdate = refreshes % fullRefresh != 0;
// Only do partial update every fullRefresh interval (minutes)
if(!partialUpdate) {
display.clearDisplay();
}
++refreshes;
// Start drawing widgets
GCalEventListWidget elw(&display, &network);
elw.setColorScheme(WIDGET_COLORSCHEME_DARK);
elw.setLocation(WIDGET_LOCATION_HALF_LEFT);
elw.draw(partialUpdate);
DTWWidget dtw(&display, &network);
dtw.setColorScheme(WIDGET_COLORSCHEME_LIGHT);
dtw.setLocation(WIDGET_LOCATION_HALF_RIGHT);
dtw.draw(partialUpdate);
// Display and delay for next loop
if(partialUpdate) {
display.partialUpdate();
} else {
display.display();
}
delay(DELAY_MS);
}