Skip to content

Commit 2dd263f

Browse files
committed
Merge branch 'dev'
2 parents 27c55e2 + 45be70f commit 2dd263f

File tree

235 files changed

+4722
-3097
lines changed

Some content is hidden

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

235 files changed

+4722
-3097
lines changed

.github/workflows/format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v2
11-
- uses: DoozyX/clang-format-lint-action@v0.12
11+
- uses: DoozyX/clang-format-lint-action@v0.18.2
1212
with:
1313
source: "./src"
1414
exclude: "./src/libs"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ There are many examples in the library that you demonstrate how to use any of th
2626

2727
Find Inkplate documentation [here](https://inkplate.readthedocs.io/en/latest/arduino.html).
2828

29+
### Soldered Image Converter
30+
31+
In order to display an Image on Inkplate, you can use the Soldered Image Converter to convert from .png, .jpg, .bmp to .h files which can be easily added to your project. Download the latest release [here](https://github.com/SolderedElectronics/Soldered-Image-Converter/releases).
2932

3033
### Using Inkplate with another microcontroller - Peripheral mode
3134

examples/Inkplate10/Advanced/DeepSleep/Inkplate10_Simple_Deep_Sleep/Inkplate10_Simple_Deep_Sleep.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
Want to learn more about Inkplate? Visit www.inkplate.io
1616
Looking to get support? Write on our forums: https://forum.soldered.com/
1717
11 February 2021 by Soldered
18+
19+
In order to convert your images into a format compatible with Inkplate
20+
use the Soldered Image Converter available at:
21+
https://github.com/SolderedElectronics/Soldered-Image-Converter/releases
1822
*/
1923

2024
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them

examples/Inkplate10/Advanced/Other/Inkplate10_Read_Battery_Voltage/Inkplate10_Read_Battery_Voltage.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
Want to learn more about Inkplate? Visit www.inkplate.io
1111
Looking to get support? Write on our forums: https://forum.soldered.com/
1212
23 January 2023 by Soldered
13+
14+
In order to convert your images into a format compatible with Inkplate
15+
use the Soldered Image Converter available at:
16+
https://github.com/SolderedElectronics/Soldered-Image-Converter/releases
1317
*/
1418

1519
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them

examples/Inkplate10/Advanced/Other/Inkplate10_Read_Temperature/Inkplate10_Read_Temperature.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
Want to learn more about Inkplate? Visit www.inkplate.io
1212
Looking to get support? Write on our forums: https://forum.soldered.com/
1313
23 January 2023 by Soldered
14+
15+
In order to convert your images into a format compatible with Inkplate
16+
use the Soldered Image Converter available at:
17+
https://github.com/SolderedElectronics/Soldered-Image-Converter/releases
1418
*/
1519

1620
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them

examples/Inkplate10/Basic/Inkplate10_Black_And_White/Inkplate10_Black_And_White.ino

Lines changed: 7 additions & 224 deletions
Large diffs are not rendered by default.

examples/Inkplate10/Basic/Inkplate10_Black_And_White/logo.h

Lines changed: 229 additions & 0 deletions
Large diffs are not rendered by default.

examples/Inkplate10/Basic/Inkplate10_Grayscale/image.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
//Array that holds data for grayscale image of 500x332 pixels. You can convert your own image using Inkplate Image Converter.
2-
//Image source: https://www.peakpx.com/583083/grayscale-photo-of-lighthouse
1+
/*
2+
In order to convert your images into a format compatible with Inkplate
3+
use the Soldered Image Converter available at:
4+
https://github.com/SolderedElectronics/Soldered-Image-Converter/releases
5+
*/
36
const uint8_t picture1[] = {
47
0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x99, 0x98, 0x88, 0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x98, 0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x99, 0x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xaa, 0xaa, 0xab, 0xbb, 0xbb, 0xbc, 0xcc, 0xcc, 0xcc, 0xcb, 0xbb, 0xba, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x9a, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0x99, 0x88, 0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x88, 0x89, 0x98, 0x88, 0x88, 0x88, 0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xab, 0xbb, 0xaa, 0xaa, 0xaa, 0xaa, 0x9a, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xba, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0xa9, 0x99, 0xaa, 0x99, 0x99, 0x9a, 0xa9, 0xaa, 0xa9, 0x88, 0x88, 0x77, 0x77, 0x87, 0x77, 0x77, 0x77, 0x77, 0x77, 0x76, 0x67, 0x77, 0x88, 0x77, 0x77, 0x66, 0x66,

examples/Inkplate10/Projects/Inkplate10_Crypto_Currency_Tracker/Inkplate10_Crypto_Currency_Tracker.ino

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ char pass[] = "";
3636

3737
// Delay between refreshed calls in miliseconds
3838
#define DELAY_MS 3 * 60 * 1000
39+
#define DELAY_WIFI_RETRY_SECONDS 10
3940

4041
// OPTIONAL:
4142
// change to a different currency
@@ -113,6 +114,7 @@ textElement elements[] = {
113114
};
114115

115116
// Our functions declared below setup and loop
117+
void getTime();
116118
void drawGraph();
117119
void drawAll();
118120

@@ -126,9 +128,32 @@ void setup()
126128
display.setTextWrap(false);
127129
display.setTextColor(0, 7);
128130

129-
// Our begin function
130-
network.begin();
131+
// Try connecting to a WiFi network.
132+
// Parameters are network SSID, password, timeout in seconds and whether to print to serial.
133+
// If the Inkplate isn't able to connect to a network stop further code execution and print an error message.
134+
if (!display.connectWiFi(ssid, pass, WIFI_TIMEOUT, true))
135+
{
136+
// Can't connect to netowrk
137+
// Clear display for the error message
138+
display.clearDisplay();
139+
// Set the font size;
140+
display.setTextSize(3);
141+
// Set the cursor positions and print the text.
142+
display.setCursor((display.width() / 2) - 200, display.height() / 2);
143+
display.print(F("Unable to connect to "));
144+
display.println(F(ssid));
145+
display.setCursor((display.width() / 2) - 200, (display.height() / 2) + 30);
146+
display.println(F("Please check ssid and pass!"));
147+
// Display the error message on the Inkplate and go to deep sleep
148+
display.display();
149+
esp_sleep_enable_timer_wakeup(1000L * DELAY_WIFI_RETRY_SECONDS);
150+
(void)esp_deep_sleep_start();
151+
}
131152

153+
// After connecting to WiFi we need to get internet time from NTP server
154+
setTime();
155+
156+
// After setting the correct time, we can start pulling data about BTC prices.
132157
Serial.print("Retrying retriving data ");
133158
while (!network.getData(data))
134159
{
@@ -153,6 +178,26 @@ void loop()
153178
// Never here
154179
}
155180

181+
// Function for getting time from NTP server
182+
void setTime()
183+
{
184+
// Structure used to hold time information
185+
struct tm timeInfo;
186+
time_t nowSec;
187+
// Fetch current time in epoch format and store it
188+
display.getNTPEpoch(&nowSec);
189+
// This loop ensures that the NTP time fetched is valid and beyond a certain threshold
190+
while (nowSec < 8 * 3600 * 2)
191+
{
192+
delay(500);
193+
yield();
194+
display.getNTPEpoch(&nowSec);
195+
}
196+
gmtime_r(&nowSec, &timeInfo);
197+
Serial.print(F("Current time: "));
198+
Serial.print(asctime(&timeInfo));
199+
}
200+
156201
// Function to draw our graph
157202
void drawGraph()
158203
{

examples/Inkplate10/Projects/Inkplate10_Crypto_Currency_Tracker/Network.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ void Network::begin()
5858
}
5959
}
6060
Serial.println(F(" connected"));
61-
62-
// Find internet time
63-
setTime();
6461
}
6562

6663
// Gets time from ntp server
@@ -189,29 +186,3 @@ bool Network::getData(double *data)
189186

190187
return !f;
191188
}
192-
193-
// Function for initial time setting ovet the ntp server
194-
void Network::setTime()
195-
{
196-
// Used for setting correct time
197-
configTime(0, 0, "pool.ntp.org", "time.nist.gov");
198-
199-
Serial.print(F("Waiting for NTP time sync: "));
200-
time_t nowSecs = time(nullptr);
201-
while (nowSecs < 8 * 3600 * 2)
202-
{
203-
delay(500);
204-
Serial.print(F("."));
205-
yield();
206-
nowSecs = time(nullptr);
207-
}
208-
209-
Serial.println();
210-
211-
// Used to store time info
212-
struct tm timeinfo;
213-
gmtime_r(&nowSecs, &timeinfo);
214-
215-
Serial.print(F("Current time: "));
216-
Serial.print(asctime(&timeinfo));
217-
}

examples/Inkplate10/Projects/Inkplate10_Daily_Weather_Station/Inkplate10_Daily_Weather_Station.ino

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
Want to learn more about Inkplate? Visit www.inkplate.io
1616
Looking to get support? Write on our forums: https://forum.soldered.com/
1717
11 February 2021 by Soldered
18+
19+
In order to convert your images into a format compatible with Inkplate
20+
use the Soldered Image Converter available at:
21+
https://github.com/SolderedElectronics/Soldered-Image-Converter/releases
1822
*/
1923

2024
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
@@ -57,6 +61,7 @@ char apiKey[] = "";
5761

5862
// Delay between API calls, about 1000 per month, which is the free tier limit
5963
#define DELAY_MS 267800L
64+
#define DELAY_WIFI_RETRY_SECONDS 10
6065

6166
// Inkplate object
6267
Inkplate display(INKPLATE_1BIT);
@@ -92,7 +97,7 @@ RTC_DATA_ATTR char temps[4][8] = {
9297
"-",
9398
};
9499

95-
// Variables for storing hour strings
100+
// Variables for storing hour stringsF
96101
RTC_DATA_ATTR uint8_t hours = 0;
97102

98103
// Variables for storing current time and weather info
@@ -115,15 +120,37 @@ void drawCurrent();
115120
void drawTemps();
116121
void drawCity();
117122
void drawTime();
123+
void setTime();
118124

119125
void setup()
120126
{
121127
// Begin serial and display
122128
Serial.begin(115200);
123129
display.begin();
124130

125-
// Calling our begin from network.h file
126-
network.begin(ssid, pass);
131+
// Try connecting to a WiFi network.
132+
// Parameters are network SSID, password, timeout in seconds and whether to print to serial.
133+
// If the Inkplate isn't able to connect to a network stop further code execution and print an error message.
134+
if (!display.connectWiFi(ssid, pass, WIFI_TIMEOUT, true))
135+
{
136+
//Can't connect to netowrk
137+
// Clear display for the error message
138+
display.clearDisplay();
139+
// Set the font size;
140+
display.setTextSize(3);
141+
// Set the cursor positions and print the text.
142+
display.setCursor((display.width() / 2) - 200, display.height() / 2);
143+
display.print(F("Unable to connect to "));
144+
display.println(F(ssid));
145+
display.setCursor((display.width() / 2) - 200, (display.height() / 2) + 30);
146+
display.println(F("Please check ssid and pass!"));
147+
// Display the error message on the Inkplate and go to deep sleep
148+
display.display();
149+
esp_sleep_enable_timer_wakeup(100L * DELAY_WIFI_RETRY_SECONDS);
150+
(void)esp_deep_sleep_start();
151+
}
152+
153+
setTime();
127154

128155
// Get all relevant data, see Network.cpp for info
129156
if (refreshes % fullRefresh == 0)
@@ -163,6 +190,27 @@ void loop()
163190
// nothing here
164191
}
165192

193+
// Function for getting time from NTP server
194+
void setTime()
195+
{
196+
// Structure used to hold time information
197+
struct tm timeInfo;
198+
display.getNTPDateTime(&timeInfo);
199+
time_t nowSec;
200+
// Fetch current time in epoch format and store it
201+
display.getNTPEpoch(&nowSec);
202+
// This loop ensures that the NTP time fetched is valid and beyond a certain threshold
203+
while (nowSec < 8 * 3600 * 2)
204+
{
205+
delay(500);
206+
yield();
207+
display.getNTPEpoch(&nowSec);
208+
}
209+
gmtime_r(&nowSec, &timeInfo);
210+
Serial.print(F("Current time: "));
211+
Serial.print(asctime(&timeInfo));
212+
}
213+
166214
// Function for drawing weather info
167215
void drawWeather()
168216
{

examples/Inkplate10/Projects/Inkplate10_Daily_Weather_Station/Network.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ void Network::begin(char *ssid, char *pass)
4343
}
4444
}
4545
Serial.println(F(" connected"));
46-
47-
// Find internet time
48-
setTime();
4946
}
5047

5148
// Gets time from ntp server
@@ -227,32 +224,6 @@ bool Network::getData(char *lat, char *lon, char *apiKey, char *city, char *temp
227224
return 1;
228225
}
229226

230-
void Network::setTime()
231-
{
232-
// Used for setting correct time
233-
configTime(0, 0, "pool.ntp.org", "time.nist.gov");
234-
235-
Serial.print(F("Waiting for NTP time sync: "));
236-
time_t nowSecs = time(nullptr);
237-
while (nowSecs < 8 * 3600 * 2)
238-
{
239-
// Print a dot every half a second while time is not set
240-
delay(500);
241-
Serial.print(F("."));
242-
yield();
243-
nowSecs = time(nullptr);
244-
}
245-
246-
Serial.println();
247-
248-
// Used to store time info
249-
struct tm timeinfo;
250-
gmtime_r(&nowSecs, &timeinfo);
251-
252-
Serial.print(F("Current time: "));
253-
Serial.print(asctime(&timeinfo));
254-
}
255-
256227
void Network::getDays(char *day, char *day1, char *day2, char *day3)
257228
{
258229
// Seconds since 1.1.1970.

0 commit comments

Comments
 (0)