Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoric committed Sep 25, 2024
2 parents 27c55e2 + 45be70f commit 2dd263f
Show file tree
Hide file tree
Showing 235 changed files with 4,722 additions and 3,097 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.12
- uses: DoozyX/clang-format-lint-action@v0.18.2
with:
source: "./src"
exclude: "./src/libs"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ There are many examples in the library that you demonstrate how to use any of th

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

### Soldered Image Converter

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).

### Using Inkplate with another microcontroller - Peripheral mode

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
Want to learn more about Inkplate? Visit www.inkplate.io
Looking to get support? Write on our forums: https://forum.soldered.com/
11 February 2021 by Soldered
In order to convert your images into a format compatible with Inkplate
use the Soldered Image Converter available at:
https://github.com/SolderedElectronics/Soldered-Image-Converter/releases
*/

// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
Want to learn more about Inkplate? Visit www.inkplate.io
Looking to get support? Write on our forums: https://forum.soldered.com/
23 January 2023 by Soldered
In order to convert your images into a format compatible with Inkplate
use the Soldered Image Converter available at:
https://github.com/SolderedElectronics/Soldered-Image-Converter/releases
*/

// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
Want to learn more about Inkplate? Visit www.inkplate.io
Looking to get support? Write on our forums: https://forum.soldered.com/
23 January 2023 by Soldered
In order to convert your images into a format compatible with Inkplate
use the Soldered Image Converter available at:
https://github.com/SolderedElectronics/Soldered-Image-Converter/releases
*/

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

Large diffs are not rendered by default.

229 changes: 229 additions & 0 deletions examples/Inkplate10/Basic/Inkplate10_Black_And_White/logo.h

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions examples/Inkplate10/Basic/Inkplate10_Grayscale/image.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//Array that holds data for grayscale image of 500x332 pixels. You can convert your own image using Inkplate Image Converter.
//Image source: https://www.peakpx.com/583083/grayscale-photo-of-lighthouse
/*
In order to convert your images into a format compatible with Inkplate
use the Soldered Image Converter available at:
https://github.com/SolderedElectronics/Soldered-Image-Converter/releases
*/
const uint8_t picture1[] = {
0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x99, 0x98, 0x88, 0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x98, 0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xbb, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xab, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xab, 0xbb, 0xbb, 0xbb, 0xbb, 0xbc, 0xcb, 0xbc, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xbb, 0xba, 0xaa, 0xaa, 0x99, 0x99, 0x89, 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x66, 0x66, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x78, 0x88, 0x87, 0x88, 0x88, 0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0xa9, 0x99, 0x99, 0xaa, 0xab, 0xba, 0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xbb, 0xbb, 0xbc, 0xcc, 0xcc, 0xcb, 0xbb, 0xbb, 0xbb, 0xaa, 0xaa, 0x9a, 0xaa, 0xaa, 0xaa, 0xbb, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xbb, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0x99, 0x98, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x88, 0x89, 0x88, 0x88, 0x88, 0x88, 0x88, 0x99, 0x88, 0x88, 0x88, 0x89, 0x99, 0x99, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xab, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xab, 0xba, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xa9, 0x9a, 0xaa, 0xaa, 0xba, 0xaa, 0xba, 0x9a, 0xba, 0xaa, 0xa9, 0x98, 0x88, 0x87, 0x77, 0x88, 0x88, 0x77, 0x88, 0x88, 0x88, 0x87, 0x88, 0x88, 0x78, 0x88, 0x87, 0x77, 0x77,
0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x99, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x99, 0x99, 0x99, 0x88, 0x88, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a, 0xaa, 0xaa, 0xaa, 0xaa, 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aa, 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ char pass[] = "";

// Delay between refreshed calls in miliseconds
#define DELAY_MS 3 * 60 * 1000
#define DELAY_WIFI_RETRY_SECONDS 10

// OPTIONAL:
// change to a different currency
Expand Down Expand Up @@ -113,6 +114,7 @@ textElement elements[] = {
};

// Our functions declared below setup and loop
void getTime();
void drawGraph();
void drawAll();

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

// Our begin function
network.begin();
// Try connecting to a WiFi network.
// Parameters are network SSID, password, timeout in seconds and whether to print to serial.
// If the Inkplate isn't able to connect to a network stop further code execution and print an error message.
if (!display.connectWiFi(ssid, pass, WIFI_TIMEOUT, true))
{
// Can't connect to netowrk
// Clear display for the error message
display.clearDisplay();
// Set the font size;
display.setTextSize(3);
// Set the cursor positions and print the text.
display.setCursor((display.width() / 2) - 200, display.height() / 2);
display.print(F("Unable to connect to "));
display.println(F(ssid));
display.setCursor((display.width() / 2) - 200, (display.height() / 2) + 30);
display.println(F("Please check ssid and pass!"));
// Display the error message on the Inkplate and go to deep sleep
display.display();
esp_sleep_enable_timer_wakeup(1000L * DELAY_WIFI_RETRY_SECONDS);
(void)esp_deep_sleep_start();
}

// After connecting to WiFi we need to get internet time from NTP server
setTime();

// After setting the correct time, we can start pulling data about BTC prices.
Serial.print("Retrying retriving data ");
while (!network.getData(data))
{
Expand All @@ -153,6 +178,26 @@ void loop()
// Never here
}

// Function for getting time from NTP server
void setTime()
{
// Structure used to hold time information
struct tm timeInfo;
time_t nowSec;
// Fetch current time in epoch format and store it
display.getNTPEpoch(&nowSec);
// This loop ensures that the NTP time fetched is valid and beyond a certain threshold
while (nowSec < 8 * 3600 * 2)
{
delay(500);
yield();
display.getNTPEpoch(&nowSec);
}
gmtime_r(&nowSec, &timeInfo);
Serial.print(F("Current time: "));
Serial.print(asctime(&timeInfo));
}

// Function to draw our graph
void drawGraph()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ void Network::begin()
}
}
Serial.println(F(" connected"));

// Find internet time
setTime();
}

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

return !f;
}

// Function for initial time setting ovet the ntp server
void Network::setTime()
{
// Used for setting correct time
configTime(0, 0, "pool.ntp.org", "time.nist.gov");

Serial.print(F("Waiting for NTP time sync: "));
time_t nowSecs = time(nullptr);
while (nowSecs < 8 * 3600 * 2)
{
delay(500);
Serial.print(F("."));
yield();
nowSecs = time(nullptr);
}

Serial.println();

// Used to store time info
struct tm timeinfo;
gmtime_r(&nowSecs, &timeinfo);

Serial.print(F("Current time: "));
Serial.print(asctime(&timeinfo));
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
Want to learn more about Inkplate? Visit www.inkplate.io
Looking to get support? Write on our forums: https://forum.soldered.com/
11 February 2021 by Soldered
In order to convert your images into a format compatible with Inkplate
use the Soldered Image Converter available at:
https://github.com/SolderedElectronics/Soldered-Image-Converter/releases
*/

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

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

// Inkplate object
Inkplate display(INKPLATE_1BIT);
Expand Down Expand Up @@ -92,7 +97,7 @@ RTC_DATA_ATTR char temps[4][8] = {
"-",
};

// Variables for storing hour strings
// Variables for storing hour stringsF
RTC_DATA_ATTR uint8_t hours = 0;

// Variables for storing current time and weather info
Expand All @@ -115,15 +120,37 @@ void drawCurrent();
void drawTemps();
void drawCity();
void drawTime();
void setTime();

void setup()
{
// Begin serial and display
Serial.begin(115200);
display.begin();

// Calling our begin from network.h file
network.begin(ssid, pass);
// Try connecting to a WiFi network.
// Parameters are network SSID, password, timeout in seconds and whether to print to serial.
// If the Inkplate isn't able to connect to a network stop further code execution and print an error message.
if (!display.connectWiFi(ssid, pass, WIFI_TIMEOUT, true))
{
//Can't connect to netowrk
// Clear display for the error message
display.clearDisplay();
// Set the font size;
display.setTextSize(3);
// Set the cursor positions and print the text.
display.setCursor((display.width() / 2) - 200, display.height() / 2);
display.print(F("Unable to connect to "));
display.println(F(ssid));
display.setCursor((display.width() / 2) - 200, (display.height() / 2) + 30);
display.println(F("Please check ssid and pass!"));
// Display the error message on the Inkplate and go to deep sleep
display.display();
esp_sleep_enable_timer_wakeup(100L * DELAY_WIFI_RETRY_SECONDS);
(void)esp_deep_sleep_start();
}

setTime();

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

// Function for getting time from NTP server
void setTime()
{
// Structure used to hold time information
struct tm timeInfo;
display.getNTPDateTime(&timeInfo);
time_t nowSec;
// Fetch current time in epoch format and store it
display.getNTPEpoch(&nowSec);
// This loop ensures that the NTP time fetched is valid and beyond a certain threshold
while (nowSec < 8 * 3600 * 2)
{
delay(500);
yield();
display.getNTPEpoch(&nowSec);
}
gmtime_r(&nowSec, &timeInfo);
Serial.print(F("Current time: "));
Serial.print(asctime(&timeInfo));
}

// Function for drawing weather info
void drawWeather()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ void Network::begin(char *ssid, char *pass)
}
}
Serial.println(F(" connected"));

// Find internet time
setTime();
}

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

void Network::setTime()
{
// Used for setting correct time
configTime(0, 0, "pool.ntp.org", "time.nist.gov");

Serial.print(F("Waiting for NTP time sync: "));
time_t nowSecs = time(nullptr);
while (nowSecs < 8 * 3600 * 2)
{
// Print a dot every half a second while time is not set
delay(500);
Serial.print(F("."));
yield();
nowSecs = time(nullptr);
}

Serial.println();

// Used to store time info
struct tm timeinfo;
gmtime_r(&nowSecs, &timeinfo);

Serial.print(F("Current time: "));
Serial.print(asctime(&timeinfo));
}

void Network::getDays(char *day, char *day1, char *day2, char *day3)
{
// Seconds since 1.1.1970.
Expand Down
Loading

0 comments on commit 2dd263f

Please sign in to comment.