Merged web and sd jpeg and bmpimage examples.

This commit is contained in:
nitko12 2020-09-24 09:56:23 +02:00
parent c30df6ee78
commit 7a40b54df1
10 changed files with 29 additions and 136 deletions

View File

@ -1,69 +0,0 @@
/*
5_Inkplate_SD_JPEG_pictures example for e-radionica Inkplate6
For this example you will need a micro USB cable, Inkplate6 and a SD card loaded with
pyramid.jpg file that can be found inside folder of this example.
Select "Inkplate 6(ESP32)" from Tools -> Board menu.
Don't have "Inkplate 6(ESP32)" option? Follow our tutorial and add it:
https://e-radionica.com/en/blog/add-inkplate-6-to-arduino-ide/
To work with SD card on Inkplate, you will need to add one extra library.
Download and install it from here: https://github.com/e-radionicacom/Inkplate-6-SDFat-Arduino-Library
You can open .jpg files that have resoluton smaller than 800x600 or otherwise it won't fit on screen.
Format your SD card in standard FAT fileformat.
This example will show you how you can read a .jpg file (picture) from SD card and
display that image on e-paper display.
Want to learn more about Inkplate? Visit www.inkplate.io
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
31 August 2020 by e-radionica.com
*/
#include "Inkplate.h" //Include Inkplate library to the sketch
#include "SdFat.h" //Include library for SD card
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1 Bit mode (BW)
SdFile file; // Create SdFile object used for accessing files on SD card
void setup()
{
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
display.clearDisplay(); // Clear frame buffer of display
display.display(); // Put clear image on display
// Init SD card. Display if SD card is init propery or not.
if (display.sdCardInit())
{
display.println("SD Card OK! Reading image...");
display.partialUpdate();
// If card is properly init, try to load image and display it on e-paper at position X=100, Y=0
// NOTE: These methods require you to pass a reference to the display object as first parameter.
// NOTE: Both drawJpegFromSd methods allow for an optional sixth "invert" parameter. Setting this parameter to
// true will flip all colors on the image, making black white and white black. fifth parameter will dither the
// image.
if (!display.drawJpegFromSd(&display, "pyramid.jpg", 100, 0, true, false))
{
// If is something failed (wrong filename or wrong format), write error message on the screen.
// You can turn off dithering for somewhat faster image load by changing the fifth parameter to false, or
// removing the parameter completely
display.println("Image open error");
display.display();
}
display.display();
}
else
{
// If SD card init not success, display error on screen and stop the program (using infinite loop)
display.println("SD Card error!");
display.partialUpdate();
while (true)
;
}
}
void loop()
{
// Nothing...
}

View File

@ -71,6 +71,20 @@ void setup()
display.drawBitmapFromSd(&file, 0, 0);
display.display();
}
display.clearDisplay();
delay(3000);
// Now draw a JPEG
if (!display.drawImage("pyramid.jpg", 100, 0, true, false))
{
// If is something failed (wrong filename or wrong format), write error message on the screen.
// You can turn off dithering for somewhat faster image load by changing the fifth parameter to false, or
// removing the parameter completely
display.println("Image open error");
display.display();
}
display.display();
}
void loop()

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -1,67 +0,0 @@
/*
12-Inkplate_Web_JPEG_pictures for e-radionica Inkplate6
For this example you will need a micro USB cable, Inkplate6, and an available WiFi connection.
Select "Inkplate 6(ESP32)" from Tools -> Board menu.
Don't have "Inkplate 6(ESP32)" option? Follow our tutorial and add it:
https://e-radionica.com/en/blog/add-inkplate-6-to-arduino-ide/
You can open .jpg files that have resoluton smaller than 800x600 or otherwise it won't fit on screen.
This example will show you how you can download a .jpg file (picture) from the web and
display that image on e-paper display.
Want to learn more about Inkplate? Visit www.inkplate.io
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
31 August 2020 by e-radionica.com
*/
#include "Inkplate.h" //Include Inkplate library to the sketch
#include "HTTPClient.h" //Include library for HTTPClient
#include "WiFi.h" //Include library for WiFi
Inkplate display(INKPLATE_1BIT); //Create an object on Inkplate library and also set library into 1 Bit mode (BW)
const char *ssid = ""; //Your WiFi SSID
const char *password = ""; //Your WiFi password
void setup()
{
Serial.begin(115200);
display.begin(); //Init Inkplate library (you should call this function ONLY ONCE)
display.clearDisplay(); //Clear frame buffer of display
display.display(); //Put clear image on display
display.print("Connecting to WiFi...");
display.partialUpdate();
//Connect to the WiFi network.
WiFi.mode(WIFI_MODE_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
display.print(".");
display.partialUpdate();
}
display.println("\nWiFi OK! Downloading...");
display.partialUpdate();
//Try to load image and display it on e-paper at position X=0, Y=100
//NOTE: These methods require you to pass a reference to the display object as first parameter.
//NOTE: Both drawJpegFromWeb methods allow for an optional sisxth "invert" parameter. Setting this parameter to true
//will flip all colors on the image, making black white and white black.
//fifth parameter will dither the image.
if (!display.drawJpegFromWeb(&display, "https://varipass.org/destination.jpg", 0, 100, true, false))
{
//If is something failed (wrong filename or format), write error message on the screen.
display.println("Image open error");
display.display();
}
display.display();
WiFi.mode(WIFI_OFF);
}
void loop()
{
//Nothing...
}

View File

@ -99,6 +99,21 @@ void setup()
display.display();
}
display.clearDisplay();
delay(3000);
// Try to load image and display it on e-paper at position X=0, Y=100
// NOTE: Both drawJpegFromWeb methods allow for an optional fifth "invert" parameter. Setting this parameter to
// true will flip all colors on the image, making black white and white black. forth parameter will dither the
// image.
if (!display.drawImage("https://varipass.org/destination.jpg", 0, 100, true, false))
{
// If is something failed (wrong filename or format), write error message on the screen.
display.println("Image open error");
display.display();
}
display.display();
http.end();
WiFi.mode(WIFI_OFF);

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB