-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinkplate-agenda.ino
73 lines (67 loc) · 1.78 KB
/
inkplate-agenda.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
#include <Inkplate.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include "secrets.h"
#define TEXT_SCALE_X 2
#define TEXT_SCALE_Y 3
#define DELAY_REFETCH 300000
#define CLEAN_REFRESHES 72
Inkplate display(INKPLATE_1BIT);
int refreshes;
void setup() {
Serial.begin(115200);
display.begin();
display.setTextSize(TEXT_SCALE_X, TEXT_SCALE_Y);
Serial.print("Hello from Inkplate!\n");
display.clearDisplay();
display.display();
display.println("Hello there friend! :)");
display.println("How are you?");
display.printf("Connecting to %s\n", ssid);
display.partialUpdate();
WiFi.begin(ssid, wifiPass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
display.print(".");
display.partialUpdate();
}
display.println();
display.printf("%s connected!\n", ssid);
display.printf("MAC Address: %s\n", WiFi.macAddress().c_str());
display.print("IP: ");
display.println(WiFi.localIP());
display.partialUpdate();
delay(5000);
refreshes = 0;
}
void loop() {
if (WiFi.status() != WL_CONNECTED) {
display.setCursor(0, 0);
display.println("\nWiFi disconnected.");
display.partialUpdate();
return;
}
HTTPClient http;
http.begin(url);
http.setAuthorization(httpUsername, httpPassword);
int httpCode = http.GET();
display.setCursor(0, 0);
if (httpCode > 0) {
display.clearDisplay();
display.println(http.getString());
} else {
display.printf("\nError in HTTP, got code %d\n", httpCode);
}
http.end();
refreshes++;
if (refreshes > CLEAN_REFRESHES) {
display.display();
refreshes = 0;
} else {
display.partialUpdate();
}
delay(DELAY_REFETCH);
}
// Local Variables:
// mode: c++
// End: