Skip to content

Commit e27c458

Browse files
committed
updated google cal and open meteo apps
for inkplates: 2 4 tempera 5v2 6 6 color 6 flick 6 plus 10
1 parent 3912cc4 commit e27c458

File tree

348 files changed

+30977
-48876
lines changed

Some content is hidden

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

348 files changed

+30977
-48876
lines changed

examples/Inkplate10/Projects/Inkplate10_Google_Calendar/Inkplate10_Google_Calendar.ino

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ Before You Start:
1818

1919
#include "src/includes.h" // Include necessary libraries and dependencies for Inkplate and networking
2020

21+
// --- WiFi Configuration ---
2122
const char *ssid = "Soldered-testingPurposes";
2223
const char *password = "Testing443";
2324

24-
int timeZone = 2; // timeZone is the number in (UTC + number) in your time zone UTC + 2 for Osijek, UTC - 4 for New York City
25-
26-
String calendarID = "[email protected]";
25+
// --- User Info ---
26+
String calendarID = "[email protected]";
2727
String apiKey = "yourapikey";
2828

29+
int timeZone = 2; // timeZone is the number in (UTC + number) in your time zone | UTC + 2 for Osijek, UTC - 4 for New York City
30+
const char *ntpServer = "pool.ntp.org"; // in case you want to use a different one
31+
32+
// --- Device and Data Objects ---
2933
Inkplate inkplate(INKPLATE_3BIT);
3034
calendarData calendar;
3135
Network network(calendarID, apiKey);
@@ -59,7 +63,7 @@ void setup()
5963
}
6064
else
6165
{
62-
configTime(timeZone * 3600, 0, "pool.ntp.org", "time.nist.gov");
66+
configTime(timeZone * 3600, 0, ntpServer);
6367
// Fetch and display calendar
6468
if (network.fetchCalendar(&calendar))
6569
{
@@ -73,7 +77,7 @@ void setup()
7377
}
7478
}
7579
// Sleep to save power; wakes every 10 minutes
76-
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); // Activate wake-up timer -- wake up after 30mins here
80+
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); // Activate wake-up timer
7781
esp_deep_sleep_start(); // Put ESP32 into deep sleep.
7882
}
7983

examples/Inkplate10/Projects/Inkplate10_Google_Calendar/src/Gui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <Inkplate.h>
44
#include "calendarData.h"
55

6-
#define MAX_SUMMARY_LENGTH 32
6+
#define MAX_SUMMARY_LENGTH 28
77

88
class Gui {
99
public:

examples/Inkplate10/Projects/Inkplate10_OpenMeteo_Weather_Station/Inkplate10_OpenMeteo_Weather_Station.ino

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
By default, the app uses the metric system.
2222
To switch to Imperial units, change the metricUnits to "bool metricUnits = false;"
2323
*/
24+
25+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
26+
#if !defined(ARDUINO_INKPLATE10) && !defined(ARDUINO_INKPLATE10V2)
27+
#error "Wrong board selection for this example, please select e-radionica Inkplate10 or Soldered Inkplate10 in the boards menu."
28+
#endif
29+
2430
#include "src/includes.h" // Include necessary libraries and dependencies for Inkplate and networking
2531

2632
// --- WiFi Configuration ---
@@ -76,7 +82,7 @@ void setup()
7682
{
7783
configTime(timeZone * 3600, 0, ntpServer); // Set local time via NTP server
7884
// Gather battery and city info
79-
userInfo.voltage = inkplate.readBattery();
85+
gui.voltage = inkplate.readBattery();
8086
userInfo.city = myCity;
8187
userInfo.username = myUsername;
8288
userInfo.useMetric = metricUnits;

examples/Inkplate10/Projects/Inkplate10_OpenMeteo_Weather_Station/src/Gui.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ void Gui::apiError()
6666
inkplate.display();
6767
}
6868

69+
int Gui::voltageToPercentage(double voltage) {
70+
if (voltage >= 4.2) return 100;
71+
if (voltage <= 3.0) return 0;
72+
73+
// Simple linear approximation
74+
return (int)(((voltage - 3.0) / (4.2 - 3.0)) * 100);
75+
}
76+
6977
// Weather Icons based on open-meteo api code
7078
const uint8_t *Gui::getWeatherIcon(int code)
7179
{
@@ -274,15 +282,18 @@ void Gui::displayWeatherData(WeatherData *weatherData, Network::UserInfo *userIn
274282
inkplate.println(weatherData->weatherDescription);
275283

276284
// Section 2: User Info and Battery
285+
286+
batteryLevel = voltageToPercentage(voltage);
287+
277288
inkplate.setFont(&FreeSans12pt7b);
278289
inkplate.setTextColor(7);
279290

280291
int yUser = 55;
281292

282-
inkplate.drawBitmap(800, 25, getBatteryIcon(userInfo->batteryLevel), 48, 48, 7);
293+
inkplate.drawBitmap(800, 25, getBatteryIcon(batteryLevel), 48, 48, 7);
283294

284295
inkplate.setCursor(850, yUser);
285-
inkplate.print(userInfo->batteryLevel);
296+
inkplate.print(batteryLevel);
286297
inkplate.println("%");
287298

288299
yUser += 50;

examples/Inkplate10/Projects/Inkplate10_OpenMeteo_Weather_Station/src/Gui.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ class Gui
1515
void displayWeatherData(WeatherData *weatherData, Network::UserInfo *userInfo);
1616
void wifiError();
1717
void apiError();
18+
int batteryLevel;
19+
double voltage;
1820

1921
private:
2022
Inkplate &inkplate;
2123
void drawTemperaturePrecipGraph(WeatherData *weatherData, Network::UserInfo *userInfo);
2224
const uint8_t* getWeatherIcon(int code);
2325
const uint8_t* getBatteryIcon(int percentage);
26+
int voltageToPercentage(double voltage);
2427

2528
};
2629

examples/Inkplate10/Projects/Inkplate10_OpenMeteo_Weather_Station/src/Network.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "Network.h"
22
#include <WiFi.h>
33
#include <HTTPClient.h>
4-
#include "weatherData.h"
4+
#include "WeatherData.h"
55

66
#include <ArduinoJson.h>
77

@@ -45,14 +45,6 @@ String Network::extractTime(String dateTime) {
4545
return "??:??";
4646
}
4747

48-
int Network::voltageToPercentage(double voltage) {
49-
if (voltage >= 4.2) return 100;
50-
if (voltage <= 3.0) return 0;
51-
52-
// Simple linear approximation
53-
return (int)(((voltage - 3.0) / (4.2 - 3.0)) * 100);
54-
}
55-
5648
String Network::getFormattedTime() {
5749
struct tm timeinfo;
5850
if (!getLocalTime(&timeinfo)) {
@@ -126,8 +118,6 @@ void Network::fetchWeatherData(WeatherData* weatherData, UserInfo* userInfo, con
126118

127119
HTTPClient http;
128120

129-
String fake = "http://this.does.not.exist"; // fake url for api error testing
130-
131121
if (userInfo->useMetric == true){
132122
userInfo->temperatureLabel = " C";
133123
userInfo->speedLabel = " km/h";
@@ -152,7 +142,6 @@ void Network::fetchWeatherData(WeatherData* weatherData, UserInfo* userInfo, con
152142
deserializeJson(doc, payload); // Deserialize the JSON payload
153143

154144
// UserInfo Data
155-
userInfo->batteryLevel = voltageToPercentage(userInfo->voltage);
156145
userInfo->lastUpdated = getFormattedTime();
157146
userInfo->currentHour = getCurrentHour();
158147
userInfo->lastUpdatedDate = extractDate(userInfo->lastUpdated);

examples/Inkplate10/Projects/Inkplate10_OpenMeteo_Weather_Station/src/Network.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ class Network {
1313
// --- Struct UserInfo ---
1414
struct UserInfo {
1515
String lastUpdated;
16-
int batteryLevel;
17-
double voltage;
1816
int currentHour;
1917
String city;
2018
String username;
@@ -35,7 +33,6 @@ class Network {
3533
String extractDate(String dateTime);
3634
String extractTime(String dateTime);
3735
String extractSun(String dateTime);
38-
int voltageToPercentage(double voltage);
3936
String getFormattedTime();
4037
int getCurrentHour();
4138
String getDayName(int dayIndex);

examples/Inkplate2/Projects/Inkplate2_Google_Calendar/Inkplate2_Google_Calendar.ino

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,25 @@ Before You Start:
1616
Make sure your calendar is public under "Access permissions" in calendar settings.
1717
*/
1818

19+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
20+
#ifndef ARDUINO_INKPLATE2
21+
#error "Wrong board selection for this example, please select Soldered Inkplate 2 in the boards menu."
22+
#endif
23+
1924
#include "src/includes.h" // Include necessary libraries and dependencies for Inkplate and networking
2025

2126
// --- WiFi Configuration ---
2227
const char *ssid = "Soldered-testingPurposes";
2328
const char *password = "Testing443";
2429

25-
int timeZone = 2; // timeZone is the number in (UTC + number) in your time zone UTC + 2 for Osijek, UTC - 4 for New York City
26-
27-
String calendarID = "[email protected]";
30+
// --- User Info ---
31+
String calendarID = "[email protected]";
2832
String apiKey = "yourapikey";
2933

34+
int timeZone = 2; // timeZone is the number in (UTC + number) in your time zone | UTC + 2 for Osijek, UTC - 4 for New York City
35+
const char *ntpServer = "pool.ntp.org"; // in case you want to use a different one
36+
37+
// --- Device and Data Objects ---
3038
Inkplate inkplate;
3139
calendarData calendar;
3240
Network network(calendarID, apiKey);
@@ -60,7 +68,7 @@ void setup()
6068
}
6169
else
6270
{
63-
configTime(timeZone * 3600, 0, "pool.ntp.org");
71+
configTime(timeZone * 3600, 0, ntpServer);
6472
// Fetch and display calendar
6573
if (network.fetchCalendar(&calendar))
6674
{
@@ -74,7 +82,7 @@ void setup()
7482
}
7583
}
7684
// Sleep to save power; wakes every 10 minutes
77-
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); // Activate wake-up timer -- wake up after 30mins here
85+
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); // Activate wake-up timer
7886
esp_deep_sleep_start(); // Put ESP32 into deep sleep.
7987
}
8088

examples/Inkplate2/Projects/Inkplate2_Google_Calendar/src/Gui.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "fonts/FreeSans12pt7b.h"
66
#include "fonts/FreeSans18pt7b.h"
77
#include "fonts/FreeSans9pt7b.h"
8-
#include "fonts/FreeSans6pt7b.h"
8+
#include "fonts/FreeSans7pt7b.h"
99
#include "fonts/FreeSansBold24pt7b.h"
1010

1111
Gui::Gui(Inkplate &inkplate) : inkplate(inkplate) {}
@@ -41,7 +41,7 @@ void Gui::wifiError()
4141
{
4242
inkplate.clearDisplay();
4343
inkplate.setTextColor(INKPLATE2_BLACK);
44-
inkplate.setFont(&FreeSans6pt7b);
44+
inkplate.setFont(&FreeSans7pt7b);
4545
inkplate.setCursor(10, 20);
4646
inkplate.print("WiFi connection failed.");
4747
inkplate.setCursor(10, 50);
@@ -72,7 +72,7 @@ void Gui::showCalendar(calendarData *calendar)
7272
// === Calendar Events ===
7373
Event *events = calendar->getEvents();
7474
int eventCount = calendar->getEventCount();
75-
int y = 12;
75+
int y = 20;
7676
int x = 40;
7777

7878
String lastDate = "";
@@ -110,16 +110,16 @@ void Gui::showCalendar(calendarData *calendar)
110110
inkplate.println(eventDate);
111111

112112
// Short Day (under date)
113-
inkplate.setFont(&FreeSans6pt7b);
114-
inkplate.setCursor(5, y + 15);
113+
inkplate.setFont(&FreeSans7pt7b);
114+
inkplate.setCursor(5, y + 18);
115115
inkplate.println(getShortDayName(timeStruct.tm_wday));
116116

117117
lastDate = eventDate;
118118
}
119119

120-
inkplate.setFont(&FreeSans6pt7b);
120+
inkplate.setFont(&FreeSans7pt7b);
121121
int yLineStart = y;
122-
int xTime = 175;
122+
int xTime = 170;
123123

124124
// Draw event summary and time
125125
inkplate.setCursor(x, y);
@@ -130,15 +130,17 @@ void Gui::showCalendar(calendarData *calendar)
130130
}
131131
inkplate.println(summary);
132132
inkplate.setCursor(xTime, y);
133-
inkplate.setFont(&FreeSans6pt7b);
133+
inkplate.setFont(&FreeSans7pt7b);
134134
inkplate.println(formatHour(events[i].startTime));
135135
inkplate.setTextColor(2);
136-
y += 10;
137-
inkplate.setFont(&FreeSans6pt7b);
136+
y += 12;
137+
inkplate.setFont(&FreeSans7pt7b);
138138
inkplate.setCursor(xTime, y);
139139
inkplate.println(formatHour(events[i].endTime));
140140
y += 16;
141141

142+
inkplate.drawLine(33, yLineStart - 12, 33, y - 12, 1);
143+
142144
counter = i;
143145

144146
if (y >= 85) // Stop drawing if out of vertical space
@@ -151,7 +153,7 @@ void Gui::showCalendar(calendarData *calendar)
151153
if (counter == eventCount - 1 && y < 90)
152154
{
153155
inkplate.setTextColor(1);
154-
inkplate.setFont(&FreeSans6pt7b);
156+
inkplate.setFont(&FreeSans7pt7b);
155157
inkplate.setCursor(10, y + 5);
156158
inkplate.println("No more events in the next 2 weeks!");
157159
}
@@ -163,7 +165,7 @@ void Gui::showCalendar(calendarData *calendar)
163165
void Gui::showError(const String &message)
164166
{
165167
inkplate.clearDisplay();
166-
inkplate.setFont(&FreeSans6pt7b);
168+
inkplate.setFont(&FreeSans7pt7b);
167169
inkplate.setTextColor(INKPLATE2_BLACK);
168170
inkplate.setCursor(10, 10);
169171
inkplate.println("Error:");

examples/Inkplate2/Projects/Inkplate2_Google_Calendar/src/Gui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <Inkplate.h>
44
#include "calendarData.h"
55

6-
#define MAX_SUMMARY_LENGTH 22
6+
#define MAX_SUMMARY_LENGTH 15
77

88
class Gui {
99
public:

0 commit comments

Comments
 (0)