Add working library for all displays
This commit is contained in:
parent
aea5753b94
commit
c9c2031c66
|
@ -1,8 +1,6 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "WiFi.h"
|
||||
#include "HTTPClient.h"
|
||||
#include "Inkplate.h"
|
||||
Adafruit_MCP23017 mcp;
|
||||
SPIClass spi2(HSPI);
|
||||
|
@ -330,13 +328,13 @@ uint8_t Inkplate::getDisplayMode() {
|
|||
return _displayMode;
|
||||
}
|
||||
|
||||
int Inkplate::drawBitmapFromSD(SdFile* p, int x, int y, bool invert) {
|
||||
int Inkplate::drawBitmapFromSD(SdFile* p, int x, int y) {
|
||||
if(sdCardOk == 0) return 0;
|
||||
struct bitmapHeader bmpHeader;
|
||||
readBmpHeaderSd(p, &bmpHeader);
|
||||
if (bmpHeader.signature != 0x4D42 || bmpHeader.compression != 0 || !(bmpHeader.color == 1 || bmpHeader.color == 4 || bmpHeader.color == 8 || bmpHeader.color == 24)) return 0;
|
||||
readBmpHeader(p, &bmpHeader);
|
||||
if (bmpHeader.signature != 0x4D42 || bmpHeader.compression != 0 || !(bmpHeader.color == 1 || bmpHeader.color == 24)) return 0;
|
||||
|
||||
if ((bmpHeader.color == 4 || bmpHeader.color == 8 || bmpHeader.color == 24 || bmpHeader.color == 32) && getDisplayMode() != INKPLATE_3BIT) {
|
||||
if ((bmpHeader.color == 24 || bmpHeader.color == 32) && getDisplayMode() != INKPLATE_3BIT) {
|
||||
selectDisplayMode(INKPLATE_3BIT);
|
||||
}
|
||||
|
||||
|
@ -344,71 +342,22 @@ int Inkplate::drawBitmapFromSD(SdFile* p, int x, int y, bool invert) {
|
|||
selectDisplayMode(INKPLATE_1BIT);
|
||||
}
|
||||
|
||||
if (bmpHeader.color == 1) drawMonochromeBitmapSd(p, bmpHeader, x, y, invert);
|
||||
if (bmpHeader.color == 4) drawGrayscaleBitmap4Sd(p, bmpHeader, x, y, invert);
|
||||
if (bmpHeader.color == 8) drawGrayscaleBitmap8Sd(p, bmpHeader, x, y, invert);
|
||||
if (bmpHeader.color == 24) drawGrayscaleBitmap24Sd(p, bmpHeader, x, y, invert);
|
||||
if (bmpHeader.color == 1) drawMonochromeBitmap(p, bmpHeader, x, y);
|
||||
if (bmpHeader.color == 24) drawGrayscaleBitmap24(p, bmpHeader, x, y);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Inkplate::drawBitmapFromSD(char* fileName, int x, int y, bool invert) {
|
||||
int Inkplate::drawBitmapFromSD(char* fileName, int x, int y) {
|
||||
if(sdCardOk == 0) return 0;
|
||||
SdFile dat;
|
||||
if (dat.open(fileName, O_RDONLY)) {
|
||||
return drawBitmapFromSD(&dat, x, y, invert);
|
||||
return drawBitmapFromSD(&dat, x, y);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int Inkplate::drawBitmapFromWeb(WiFiClient* s, int x, int y, int len, bool invert) {
|
||||
struct bitmapHeader bmpHeader;
|
||||
readBmpHeaderWeb(s, &bmpHeader);
|
||||
if (bmpHeader.signature != 0x4D42 || bmpHeader.compression != 0 || !(bmpHeader.color == 1 || bmpHeader.color == 4 || bmpHeader.color == 8 || bmpHeader.color == 24)) return 0;
|
||||
|
||||
if ((bmpHeader.color == 4 || bmpHeader.color == 8 || bmpHeader.color == 24 || bmpHeader.color == 32) && getDisplayMode() != INKPLATE_3BIT) {
|
||||
selectDisplayMode(INKPLATE_3BIT);
|
||||
}
|
||||
|
||||
if (bmpHeader.color == 1 && getDisplayMode() != INKPLATE_1BIT) {
|
||||
selectDisplayMode(INKPLATE_1BIT);
|
||||
}
|
||||
|
||||
if (bmpHeader.color == 1) drawMonochromeBitmapWeb(s, bmpHeader, x, y, len, invert);
|
||||
if (bmpHeader.color == 4) drawGrayscaleBitmap4Web(s, bmpHeader, x, y, len, invert);
|
||||
if (bmpHeader.color == 8) drawGrayscaleBitmap8Web(s, bmpHeader, x, y, len, invert);
|
||||
if (bmpHeader.color == 24) drawGrayscaleBitmap24Web(s, bmpHeader, x, y, len, invert);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Inkplate::drawBitmapFromWeb(char* url, int x, int y, bool invert) {
|
||||
if (WiFi.status() != WL_CONNECTED) return 0;
|
||||
int ret = 0;
|
||||
|
||||
bool sleep = WiFi.getSleep();
|
||||
WiFi.setSleep(false);
|
||||
|
||||
HTTPClient http;
|
||||
http.getStream().setNoDelay(true);
|
||||
http.getStream().setTimeout(1);
|
||||
http.begin(url);
|
||||
|
||||
int httpCode = http.GET();
|
||||
if (httpCode == 200) {
|
||||
int32_t len = http.getSize();
|
||||
if (len > 0) {
|
||||
WiFiClient * dat = http.getStreamPtr();
|
||||
ret = drawBitmapFromWeb(dat, x, y, len, invert);
|
||||
}
|
||||
}
|
||||
|
||||
http.end();
|
||||
WiFi.setSleep(sleep);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Inkplate::sdCardInit() {
|
||||
spi2.begin(14, 12, 13, 15);
|
||||
sdCardOk = sd.begin(15, SD_SCK_MHZ(25));
|
||||
|
@ -819,7 +768,7 @@ uint16_t Inkplate::read16(uint8_t* c) {
|
|||
return (*(c) | (*(c + 1) << 8));
|
||||
}
|
||||
|
||||
void Inkplate::readBmpHeaderSd(SdFile *_f, struct bitmapHeader *_h) {
|
||||
void Inkplate::readBmpHeader(SdFile *_f, struct bitmapHeader *_h) {
|
||||
uint8_t header[100];
|
||||
_f->rewind();
|
||||
_f->read(header, 100);
|
||||
|
@ -834,21 +783,7 @@ void Inkplate::readBmpHeaderSd(SdFile *_f, struct bitmapHeader *_h) {
|
|||
return;
|
||||
}
|
||||
|
||||
void Inkplate::readBmpHeaderWeb(WiFiClient *_s, struct bitmapHeader *_h) {
|
||||
uint8_t header[34];
|
||||
_s->read(header, 34);
|
||||
_h->signature = read16(header + 0);
|
||||
_h->fileSize = read32(header + 2);
|
||||
_h->startRAW = read32(header + 10);
|
||||
_h->dibHeaderSize = read32(header + 14);
|
||||
_h->width = read32(header + 18);
|
||||
_h->height = read32(header + 22);
|
||||
_h->color = read16(header + 28);
|
||||
_h->compression = read32(header + 30);
|
||||
return;
|
||||
}
|
||||
|
||||
int Inkplate::drawMonochromeBitmapSd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert) {
|
||||
int Inkplate::drawMonochromeBitmap(SdFile *f, struct bitmapHeader bmpHeader, int x, int y) {
|
||||
int w = bmpHeader.width;
|
||||
int h = bmpHeader.height;
|
||||
uint8_t paddingBits = w % 32;
|
||||
|
@ -859,18 +794,14 @@ int Inkplate::drawMonochromeBitmapSd(SdFile *f, struct bitmapHeader bmpHeader, i
|
|||
for (j = 0; j < h; j++) {
|
||||
for (i = 0; i < w; i++) {
|
||||
uint32_t pixelRow = f->read() << 24 | f->read() << 16 | f->read() << 8 | f->read();
|
||||
if (invert)
|
||||
pixelRow = ~pixelRow;
|
||||
for (int n = 0; n < 32; n++) {
|
||||
drawPixel((i * 32) + n + x, h - 1 - j + y, !(pixelRow & (1ULL << (31 - n))));
|
||||
drawPixel((i * 32) + n + x, h - j + y, !(pixelRow & (1ULL << (31 - n))));
|
||||
}
|
||||
}
|
||||
if (paddingBits) {
|
||||
uint32_t pixelRow = f->read() << 24 | f->read() << 16 | f->read() << 8 | f->read();
|
||||
if (invert)
|
||||
pixelRow = ~pixelRow;
|
||||
for (int n = 0; n < paddingBits; n++) {
|
||||
drawPixel((i * 32) + n + x, h - 1 - j + y, !(pixelRow & (1ULL << (31 - n))));
|
||||
drawPixel((i * 32) + n + x, h - j + y, !(pixelRow & (1ULL << (31 - n))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -878,62 +809,7 @@ int Inkplate::drawMonochromeBitmapSd(SdFile *f, struct bitmapHeader bmpHeader, i
|
|||
return 1;
|
||||
}
|
||||
|
||||
int Inkplate::drawGrayscaleBitmap4Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert) {
|
||||
int w = bmpHeader.width;
|
||||
int h = bmpHeader.height;
|
||||
uint8_t paddingBits = w % 8;
|
||||
w /= 8;
|
||||
|
||||
f->seekSet(bmpHeader.startRAW);
|
||||
int i, j;
|
||||
for (j = 0; j < h; j++) {
|
||||
for (i = 0; i < w; i++) {
|
||||
uint32_t pixelRow = f->read() << 24 | f->read() << 16 | f->read() << 8 | f->read();
|
||||
if (invert)
|
||||
pixelRow = ~pixelRow;
|
||||
for (int n = 0; n < 8; n++) {
|
||||
drawPixel((i * 8) + n + x, h - 1 - j + y, (pixelRow & (0xFULL << (28 - n*4))) >> (28 - n*4 + 1));
|
||||
}
|
||||
}
|
||||
if (paddingBits) {
|
||||
uint32_t pixelRow = f->read() << 24 | f->read() << 16 | f->read() << 8 | f->read();
|
||||
if (invert)
|
||||
pixelRow = ~pixelRow;
|
||||
for (int n = 0; n < paddingBits; n++) {
|
||||
drawPixel((i * 8) + n + x, h - 1 - j + y, ((pixelRow & (0xFULL << (28 - n*4)))) >> (28 - n*4 + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
f->close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Inkplate::drawGrayscaleBitmap8Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert) {
|
||||
int w = bmpHeader.width;
|
||||
int h = bmpHeader.height;
|
||||
char padding = w % 4;
|
||||
f->seekSet(bmpHeader.startRAW);
|
||||
int i, j;
|
||||
for (j = 0; j < h; j++) {
|
||||
for (i = 0; i < w; i++) {
|
||||
uint8_t px = 0;
|
||||
if (invert)
|
||||
px = 255-f->read();
|
||||
else
|
||||
px = f->read();
|
||||
drawPixel(i + x, h - 1 - j + y, px>>5);
|
||||
}
|
||||
if (padding) {
|
||||
for (int p = 0; p < 4-padding; p++) {
|
||||
f->read();
|
||||
}
|
||||
}
|
||||
}
|
||||
f->close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Inkplate::drawGrayscaleBitmap24Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert) {
|
||||
int Inkplate::drawGrayscaleBitmap24(SdFile *f, struct bitmapHeader bmpHeader, int x, int y) {
|
||||
int w = bmpHeader.width;
|
||||
int h = bmpHeader.height;
|
||||
char padding = w % 4;
|
||||
|
@ -947,14 +823,10 @@ int Inkplate::drawGrayscaleBitmap24Sd(SdFile *f, struct bitmapHeader bmpHeader,
|
|||
//display.drawPixel(i + x, h - j + y, (uint8_t)(px*7));
|
||||
|
||||
//So then, we are convertng it to grayscale using good old average and gamma correction (from LUT). With this metod, it is still slow (full size image takes 4 seconds), but much beter than prev mentioned method.
|
||||
uint8_t px = 0;
|
||||
if (invert)
|
||||
px = ((255-f->read()) * 2126 / 10000) + ((255-f->read()) * 7152 / 10000) + ((255-f->read()) * 722 / 10000);
|
||||
else
|
||||
px = (f->read() * 2126 / 10000) + (f->read() * 7152 / 10000) + (f->read() * 722 / 10000);
|
||||
uint8_t px = (f->read() * 2126 / 10000) + (f->read() * 7152 / 10000) + (f->read() * 722 / 10000);
|
||||
//drawPixel(i + x, h - j + y, gammaLUT[px]);
|
||||
drawPixel(i + x, h - 1 - j + y, px>>5);
|
||||
//drawPixel(i + x, h - j + y, px/32);
|
||||
drawPixel(i + x, h - j + y, px>>5);
|
||||
//drawPixel(i + x, h - j + y, px/32);
|
||||
}
|
||||
if (padding) {
|
||||
for (int p = 0; p < padding; p++) {
|
||||
|
@ -966,190 +838,6 @@ int Inkplate::drawGrayscaleBitmap24Sd(SdFile *f, struct bitmapHeader bmpHeader,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int Inkplate::drawMonochromeBitmapWeb(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert) {
|
||||
int w = bmpHeader.width;
|
||||
int h = bmpHeader.height;
|
||||
uint8_t paddingBits = w % 32;
|
||||
int total = len - 34;
|
||||
w /= 32;
|
||||
|
||||
uint8_t* buf = (uint8_t*) ps_malloc(total);
|
||||
if (buf == NULL)
|
||||
return 0;
|
||||
|
||||
int pnt = 0;
|
||||
while (pnt < total) {
|
||||
int toread = s->available();
|
||||
if (toread > 0) {
|
||||
int read = s->read(buf+pnt, toread);
|
||||
if (read > 0)
|
||||
pnt += read;
|
||||
}
|
||||
}
|
||||
|
||||
int i, j, k = bmpHeader.startRAW - 34;
|
||||
for (j = 0; j < h; j++) {
|
||||
for (i = 0; i < w; i++) {
|
||||
uint32_t pixelRow = buf[k++] << 24 | buf[k++] << 16 | buf[k++] << 8 | buf[k++];
|
||||
if (invert)
|
||||
pixelRow = ~pixelRow;
|
||||
for (int n = 0; n < 32; n++) {
|
||||
drawPixel((i * 32) + n + x, h - 1 - j + y, !(pixelRow & (1ULL << (31 - n))));
|
||||
}
|
||||
}
|
||||
if (paddingBits) {
|
||||
uint32_t pixelRow = buf[k++] << 24 | buf[k++] << 16 | buf[k++] << 8 | buf[k++];
|
||||
if (invert)
|
||||
pixelRow = ~pixelRow;
|
||||
for (int n = 0; n < paddingBits; n++) {
|
||||
drawPixel((i * 32) + n + x, h - 1 - j + y, !(pixelRow & (1ULL << (31 - n))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Inkplate::drawGrayscaleBitmap4Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert) {
|
||||
int w = bmpHeader.width;
|
||||
int h = bmpHeader.height;
|
||||
char paddingBits = w % 8;
|
||||
int total = len - 34;
|
||||
w /= 8;
|
||||
|
||||
uint8_t* buf = (uint8_t*) ps_malloc(total);
|
||||
if (buf == NULL)
|
||||
return 0;
|
||||
|
||||
int pnt = 0;
|
||||
while (pnt < total) {
|
||||
int toread = s->available();
|
||||
if (toread > 0) {
|
||||
int read = s->read(buf+pnt, toread);
|
||||
if (read > 0)
|
||||
pnt += read;
|
||||
}
|
||||
}
|
||||
|
||||
int i, j, k = bmpHeader.startRAW - 34;
|
||||
for (j = 0; j < h; j++) {
|
||||
for (i = 0; i < w; i++) {
|
||||
uint32_t pixelRow = buf[k++] << 24 | buf[k++] << 16 | buf[k++] << 8 | buf[k++];
|
||||
if (invert)
|
||||
pixelRow = ~pixelRow;
|
||||
for (int n = 0; n < 8; n++) {
|
||||
drawPixel((i * 8) + n + x, h - 1 - j + y, (pixelRow & (0xFULL << (28 - n*4))) >> (28 - n*4 + 1));
|
||||
}
|
||||
}
|
||||
if (paddingBits) {
|
||||
uint32_t pixelRow = buf[k++] << 24 | buf[k++] << 16 | buf[k++] << 8 | buf[k++];
|
||||
if (invert)
|
||||
pixelRow = ~pixelRow;
|
||||
for (int n = 0; n < paddingBits; n++) {
|
||||
drawPixel((i * 8) + n + x, h - 1 - j + y, ((pixelRow & (0xFULL << (28 - n*4)))) >> (28 - n*4 + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Inkplate::drawGrayscaleBitmap8Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert) {
|
||||
int w = bmpHeader.width;
|
||||
int h = bmpHeader.height;
|
||||
char padding = w % 4;
|
||||
int total = len - 34;
|
||||
|
||||
uint8_t* buf = (uint8_t*) ps_malloc(total);
|
||||
if (buf == NULL)
|
||||
return 0;
|
||||
|
||||
int pnt = 0;
|
||||
while (pnt < total) {
|
||||
int toread = s->available();
|
||||
if (toread > 0) {
|
||||
int read = s->read(buf+pnt, toread);
|
||||
if (read > 0)
|
||||
pnt += read;
|
||||
}
|
||||
}
|
||||
|
||||
int i, j, k = bmpHeader.startRAW - 34;
|
||||
for (j = 0; j < h; j++) {
|
||||
for (i = 0; i < w; i++) {
|
||||
uint8_t px = 0;
|
||||
if (invert)
|
||||
px = 255-buf[k++];
|
||||
else
|
||||
px = buf[k++];
|
||||
drawPixel(i + x, h - 1 - j + y, px>>5);
|
||||
}
|
||||
if (padding) {
|
||||
for (int p = 0; p < 4-padding; p++) {
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Inkplate::drawGrayscaleBitmap24Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert) {
|
||||
int w = bmpHeader.width;
|
||||
int h = bmpHeader.height;
|
||||
char padding = w % 4;
|
||||
int total = len - 34;
|
||||
|
||||
uint8_t* buf = (uint8_t*) ps_malloc(total);
|
||||
if (buf == NULL)
|
||||
return 0;
|
||||
|
||||
int pnt = 0;
|
||||
while (pnt < total) {
|
||||
int toread = s->available();
|
||||
if (toread > 0) {
|
||||
int read = s->read(buf+pnt, toread);
|
||||
if (read > 0)
|
||||
pnt += read;
|
||||
}
|
||||
}
|
||||
|
||||
int i, j, k = bmpHeader.startRAW - 34;
|
||||
for (j = 0; j < h; j++) {
|
||||
for (i = 0; i < w; i++) {
|
||||
//This is the proper way of converting True Color (24 Bit RGB) bitmap file into grayscale, but it takes waaay too much time (full size picture takes about 17s to decode!)
|
||||
//float px = (0.2126 * (readByteFromSD(&file) / 255.0)) + (0.7152 * (readByteFromSD(&file) / 255.0)) + (0.0722 * (readByteFromSD(&file) / 255.0));
|
||||
//px = pow(px, 1.5);
|
||||
//display.drawPixel(i + x, h - j + y, (uint8_t)(px*7));
|
||||
|
||||
//So then, we are convertng it to grayscale using good old average and gamma correction (from LUT). With this metod, it is still slow (full size image takes 4 seconds), but much beter than prev mentioned method.
|
||||
uint8_t px = 0;
|
||||
if (invert)
|
||||
px = ((255-buf[k++]) * 2126 / 10000) + ((255-buf[k++]) * 7152 / 10000) + ((255-buf[k++]) * 722 / 10000);
|
||||
else
|
||||
px = (buf[k++] * 2126 / 10000) + (buf[k++] * 7152 / 10000) + (buf[k++] * 722 / 10000);
|
||||
//drawPixel(i + x, h - j + y, gammaLUT[px]);
|
||||
drawPixel(i + x, h - 1 - j + y, px>>5);
|
||||
//drawPixel(i + x, h - j + y, px/32);
|
||||
}
|
||||
if (padding) {
|
||||
for (int p = 0; p < padding; p++) {
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Inkplate::precalculateGamma(uint8_t* c, float gamma) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
c[i] = int(round((pow(i / 255.0, gamma)) * 15));
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "SPI.h"
|
||||
#include "Adafruit_MCP23017.h"
|
||||
#include "SdFat.h"
|
||||
#include "WiFiClient.h"
|
||||
|
||||
#define INKPLATE_GAMMA 1.45
|
||||
#define E_INK_WIDTH 800
|
||||
|
@ -131,10 +130,8 @@ class Inkplate : public Adafruit_GFX {
|
|||
void einkOn(void);
|
||||
void selectDisplayMode(uint8_t _mode);
|
||||
uint8_t getDisplayMode();
|
||||
int drawBitmapFromSD(SdFile* p, int x, int y, bool invert = false);
|
||||
int drawBitmapFromSD(char* fileName, int x, int y, bool invert = false);
|
||||
int drawBitmapFromWeb(WiFiClient* s, int x, int y, int len, bool invert = false);
|
||||
int drawBitmapFromWeb(char* url, int x, int y, bool invert = false);
|
||||
int drawBitmapFromSD(SdFile* p, int x, int y);
|
||||
int drawBitmapFromSD(char* fileName, int x, int y);
|
||||
int sdCardInit();
|
||||
SdFat getSdFat();
|
||||
SPIClass getSPI();
|
||||
|
@ -166,16 +163,9 @@ class Inkplate : public Adafruit_GFX {
|
|||
void display3b();
|
||||
uint32_t read32(uint8_t* c);
|
||||
uint16_t read16(uint8_t* c);
|
||||
void readBmpHeaderSd(SdFile *_f, struct bitmapHeader *_h);
|
||||
void readBmpHeaderWeb(WiFiClient *_s, struct bitmapHeader *_h);
|
||||
int drawMonochromeBitmapSd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert);
|
||||
int drawGrayscaleBitmap4Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert);
|
||||
int drawGrayscaleBitmap8Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert);
|
||||
int drawGrayscaleBitmap24Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert);
|
||||
int drawMonochromeBitmapWeb(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert);
|
||||
int drawGrayscaleBitmap4Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert);
|
||||
int drawGrayscaleBitmap8Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert);
|
||||
int drawGrayscaleBitmap24Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert);
|
||||
void readBmpHeader(SdFile *_f, struct bitmapHeader *_h);
|
||||
int drawMonochromeBitmap(SdFile *f, struct bitmapHeader bmpHeader, int x, int y);
|
||||
int drawGrayscaleBitmap24(SdFile *f, struct bitmapHeader bmpHeader, int x, int y);
|
||||
void precalculateGamma(uint8_t* c, float gamma);
|
||||
};
|
||||
|
||||
|
|
|
@ -53,24 +53,12 @@ There are many examples in the library that you demonstrate how to use any of th
|
|||
|
||||
3.2. Screen Cleaning - clean the screen in case of image burn-in
|
||||
|
||||
### Using Inkplate 6 with another microcontroller
|
||||
As promised in an [early update](https://www.crowdsupply.com/e-radionica/inkplate-6/updates/successfully-funded-also-third-party-master-controllers-and-partial-updates), Inkplate 6's screen contents can be updated using 3rd controller (such as Raspberry Pi or another microcontroller). The "Slave Mode" (unpopular name right now, we are aware and will change) enables this. All brand new Inkplates come pre-programmed with slave mode and can be used right away.
|
||||
|
||||
It is based on UART (serial) communication - connect the Inkplate to "master" board either via USB cable or directly via ESP32 RX and TX pins. Using standard UART at 115200 baud, you can send commands to change screen contents. For example, send *#H(000,000,"/img.bmp")** to show image img.bmp from SD card on the screen. Find very basic documentation for using it [here](https://github.com/e-radionicacom/Inkplate-6-Arduino-library/blob/master/examples/3.%20Others/1-Inkplate_Slave_Mode/Inkplate_slave_mode_documentation.txt).
|
||||
|
||||
### Battery power
|
||||
Inkplate 6 has two options for powering it. First one is obvious - USB port at side of the board. Just plug any micro USB cable and you are good to go. Second option is battery. Supported batteries are standard Li-Ion/Li-Poly batteries with 3.7V nominal voltage. Connector for the battery is standard 2.00mm pitch JST connector. The onboard charger will charge the battery with 500mA when USB is plugged at the same time. You can use battery of any size or capacity if you don't have a enclosure. If you are using our enclosure, battery size shouldn't exceed 90mm x 50mm (3.5 x 1.95 inch) and 5.5mm (0.2 inch) in height.
|
||||
|
||||
### Micropython
|
||||
If you are looking for micropython support, it is still work in progress - we are new with it! :) When it's ready, we will let you know with new project update.
|
||||
|
||||
### Where to buy & other
|
||||
### Misc
|
||||
Inkplate 6 is available for purchase via:
|
||||
- [e-radionica.com](https://e-radionica.com/en/inkplate.html)
|
||||
- [Crowd Supply](https://www.crowdsupply.com/e-radionica/inkplate-6)
|
||||
- [Mouser](https://hr.mouser.com/Search/Refine?Keyword=inkplate)
|
||||
|
||||
Inkplate 6 is open-source. If you are looking for hardware design of the board, check the [Hardware repo](https://github.com/e-radionicacom/Inkplate-6-hardware). You will find 3D printable [enclosure](https://github.com/e-radionicacom/Inkplate-6-hardware/tree/master/3D%20printable%20case) there, as well as [detailed dimensions](https://github.com/e-radionicacom/Inkplate-6-hardware/tree/master/Technical%20drawings). In this repo you will find code for driving the ED060SC7 e-paper display used by Inkplate.
|
||||
|
||||
For all questions and issues, please contact us via [temporary e-mail address](mailto:inkplate@e-radionica.com). As soon as forum has been set up, e-mail support will be discontinued.
|
||||
For all questions and issues, please open an issue or thread on [our forums](http://forum.e-radionica.com/en/).
|
||||
For sales & collaboration, please reach us via [e-mail](mailto:kontakt@e-radionica.com).
|
||||
|
|
0
examples/1. Basic Inkplate Functionality/1-Inkplate_basic_monochrome/1-Inkplate_basic_monochrome.ino
Normal file → Executable file
0
examples/1. Basic Inkplate Functionality/1-Inkplate_basic_monochrome/1-Inkplate_basic_monochrome.ino
Normal file → Executable file
4
examples/1. Basic Inkplate Functionality/2-Inkplate_basic_grayscale/2-Inkplate_basic_grayscale.ino
Normal file → Executable file
4
examples/1. Basic Inkplate Functionality/2-Inkplate_basic_grayscale/2-Inkplate_basic_grayscale.ino
Normal file → Executable file
|
@ -7,7 +7,7 @@
|
|||
|
||||
This example will show you how you can draw some simple graphics using
|
||||
Adafruit GFX functions. Yes, Inkplate library is 100% compatible with GFX lib!
|
||||
Learn more about Adafruit GFX: https://learn.adafruit.com/adafruit-gfx-graphics-library
|
||||
Learn more about Adafruit GFX: https://learn.adafruit.com/adafruit-gfx-graphics-library )
|
||||
Inkplate will be used in grayscale mode which is 3 bit, so you can have up to 8 different colors (black, 6 gray colors and white)
|
||||
Color is represented by number, where number 0 means black and number 7 means white, while everything in between are shades of gray.
|
||||
|
||||
|
@ -29,7 +29,7 @@ void setup() {
|
|||
display.clearDisplay(); //Clear any data that may have been in (software) frame buffer.
|
||||
//(NOTE! This does not clean image on screen, it only clears it in the frame buffer inside ESP32).
|
||||
display.clean(); //Clear everything that has previously been on a screen
|
||||
display.setTextColor(0,7); display.setCursor(150, 320); display.setTextSize(4); display.print("Welcome to Inkplate 6!"); display.display(); //Write hello message
|
||||
display.setTextColor(0,7,); display.setCursor(150, 320); display.setTextSize(4); display.print("Welcome to Inkplate 6!"); display.display(); //Write hello message
|
||||
delay(5000); //Wait a little bit
|
||||
}
|
||||
|
||||
|
|
0
examples/1. Basic Inkplate Functionality/2-Inkplate_basic_grayscale/image.h
Normal file → Executable file
0
examples/1. Basic Inkplate Functionality/2-Inkplate_basic_grayscale/image.h
Normal file → Executable file
2
examples/1. Basic Inkplate Functionality/3-Inkplate-basic_partial_update/3-Inkplate-basic_partial_update.ino
Normal file → Executable file
2
examples/1. Basic Inkplate Functionality/3-Inkplate-basic_partial_update/3-Inkplate-basic_partial_update.ino
Normal file → Executable file
|
@ -39,7 +39,7 @@ void loop() {
|
|||
display.clearDisplay(); //Clear content in frame buffer
|
||||
display.setCursor(offset, 300); //Set new position for text
|
||||
display.print(text); //Write text at new position
|
||||
if(n>9) { //Check if you need to do full refresh or you can do partial update
|
||||
if(n>9) { //Check if you need to do full refresh or you can do partial update
|
||||
display.display(); //Do a full refresh
|
||||
n = 0;
|
||||
}else{
|
||||
|
|
2
examples/1. Basic Inkplate Functionality/4-Inkplate-basic_custom_font/4-Inkplate-basic_custom_font.ino
Normal file → Executable file
2
examples/1. Basic Inkplate Functionality/4-Inkplate-basic_custom_font/4-Inkplate-basic_custom_font.ino
Normal file → Executable file
|
@ -39,7 +39,7 @@ void setup() {
|
|||
display.setFont(&DSEG14Classic_Regular20pt7b); //Select second font
|
||||
display.setCursor(0, 250); //Set print position on X = 0, Y = 250
|
||||
display.println("Some old-school 14 segment"); //Print text
|
||||
display.println("display font on e-paper");
|
||||
display.println("display font on e-papaer");
|
||||
display.print("display");
|
||||
|
||||
display.setFont(); //Use original 5x7 pixel fonts
|
||||
|
|
0
examples/1. Basic Inkplate Functionality/4-Inkplate-basic_custom_font/DSEG14Classic_Regular20pt7b.h
Normal file → Executable file
0
examples/1. Basic Inkplate Functionality/4-Inkplate-basic_custom_font/DSEG14Classic_Regular20pt7b.h
Normal file → Executable file
0
examples/1. Basic Inkplate Functionality/4-Inkplate-basic_custom_font/Not_Just_Groovy20pt7b.h
Normal file → Executable file
0
examples/1. Basic Inkplate Functionality/4-Inkplate-basic_custom_font/Not_Just_Groovy20pt7b.h
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/1-Inkplate_WiFi_HTTP_request/1-Inkplate_WiFi_HTTP_request.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/1-Inkplate_WiFi_HTTP_request/1-Inkplate_WiFi_HTTP_request.ino
Normal file → Executable file
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
10_Inkplate_Download_And_Show example 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 .bmp files that have color depth of 1 bit (monochrome bitmap), 4 bit, 8 bit and
|
||||
24 bit AND have resoluton smaller than 800x600 or otherwise it won't fit on screen.
|
||||
|
||||
This example will show you how you can download a .bmp 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/
|
||||
23 July 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 (Monochrome)
|
||||
|
||||
const char* ssid = "YourWiFiSSID"; //Your WiFi SSID
|
||||
const char* password = "YourPass"; //Your WiFi password
|
||||
|
||||
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
|
||||
|
||||
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();
|
||||
|
||||
//Draw the first image from web.
|
||||
//Monochromatic bitmap with 1 bit depth. Images like this load quickest.
|
||||
//NOTE: Both drawBitmapFromWeb methods allow for an optional fourth "invert" parameter. Setting this parameter to true
|
||||
//will flip all colors on the image, making black white and white black. This may be necessary when exporting bitmaps from
|
||||
//certain softwares.
|
||||
//Photo taken by: Roberto Fernandez
|
||||
if(!display.drawBitmapFromWeb("https://varipass.org/neowise_mono.bmp", 0, 0, true)) {
|
||||
//If is something failed (wrong filename or wrong bitmap format), write error message on the screen.
|
||||
//REMEMBER! You can only use Windows Bitmap file with color depth of 1, 4, 8 or 24 bits with no compression!
|
||||
display.println("Image open error");
|
||||
display.display();
|
||||
}
|
||||
display.display();
|
||||
|
||||
//Draw the second image from web, this time using a HTTPClient to fetch the response manually.
|
||||
//Full color 24 bit images are large and take a long time to load, will take around 20 secs.
|
||||
HTTPClient http;
|
||||
//Set parameters to speed up the download process.
|
||||
http.getStream().setNoDelay(true);
|
||||
http.getStream().setTimeout(1);
|
||||
|
||||
//Photo taken by: Roberto Fernandez
|
||||
http.begin("https://varipass.org/neowise.bmp");
|
||||
|
||||
//Check response code.
|
||||
int httpCode = http.GET();
|
||||
if (httpCode == 200) {
|
||||
//Get the response length and make sure it is not 0.
|
||||
int32_t len = http.getSize();
|
||||
if (len > 0) {
|
||||
if(!display.drawBitmapFromWeb(http.getStreamPtr(), 0, 0, len)) {
|
||||
//If is something failed (wrong filename or wrong bitmap format), write error message on the screen.
|
||||
//REMEMBER! You can only use Windows Bitmap file with color depth of 1, 4, 8 or 24 bits with no compression!
|
||||
display.println("Image open error");
|
||||
display.display();
|
||||
}
|
||||
display.display();
|
||||
}
|
||||
else {
|
||||
display.println("Invalid response length");
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
else {
|
||||
display.println("HTTP error");
|
||||
display.display();
|
||||
}
|
||||
|
||||
http.end();
|
||||
|
||||
WiFi.mode(WIFI_OFF);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//Nothing...
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
Before Width: | Height: | Size: 59 KiB |
0
examples/2. Advanced Inkplate Features/2-Inkplate_Low_Power/2-Inkplate_Low_Power.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/2-Inkplate_Low_Power/2-Inkplate_Low_Power.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/2-Inkplate_Low_Power/picture1.h
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/2-Inkplate_Low_Power/picture1.h
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/2-Inkplate_Low_Power/picture2.h
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/2-Inkplate_Low_Power/picture2.h
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/2-Inkplate_Low_Power/picture3.h
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/2-Inkplate_Low_Power/picture3.h
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/3-Inkplate_Battery_Voltage_And_Temperature/3-Inkplate_Battery_Voltage_And_Temperature.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/3-Inkplate_Battery_Voltage_And_Temperature/3-Inkplate_Battery_Voltage_And_Temperature.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/3-Inkplate_Battery_Voltage_And_Temperature/symbols.h
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/3-Inkplate_Battery_Voltage_And_Temperature/symbols.h
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/4-Inkplate_Touchpads/4-Inkplate_Touchpads.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/4-Inkplate_Touchpads/4-Inkplate_Touchpads.ino
Normal file → Executable file
7
examples/2. Advanced Inkplate Features/5-Inkplate_SD_BMP_pictures/5-Inkplate_SD_BMP_pictures.ino
Normal file → Executable file
7
examples/2. Advanced Inkplate Features/5-Inkplate_SD_BMP_pictures/5-Inkplate_SD_BMP_pictures.ino
Normal file → Executable file
|
@ -9,7 +9,7 @@
|
|||
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 .bmp files that have color depth of 1 bit (monochrome bitmap), 4 bit, 8 bit and
|
||||
You can open .bmp files that have color depth of 1 bit (monochrome bitmap) and
|
||||
24 bit AND have resoluton smaller than 800x600 or otherwise it won't fit on screen.
|
||||
|
||||
This example will show you how you can read .bmp files (pictures) from SD card and
|
||||
|
@ -36,12 +36,9 @@ void setup() {
|
|||
display.partialUpdate();
|
||||
|
||||
//If card is properly init, try to load image and display it on e-paper at position X=0, Y=0
|
||||
//NOTE: Both drawBitmapFromSD methods allow for an optional fourth "invert" parameter. Setting this parameter to true
|
||||
//will flip all colors on the image, making black white and white black. This may be necessary when exporting bitmaps from
|
||||
//certain softwares.
|
||||
if(!display.drawBitmapFromSD("image1.bmp", 0, 0)) {
|
||||
//If is something failed (wrong filename or wrong bitmap format), write error message on the screen.
|
||||
//REMEMBER! You can only use Windows Bitmap file with color depth of 1, 4, 8 or 24 bits with no compression!
|
||||
//REMEMBER! You can only use Windows Bitmap file with color depth of 1 or 24 bits with no compression!
|
||||
display.println("Image open error");
|
||||
display.display();
|
||||
}
|
||||
|
|
0
examples/2. Advanced Inkplate Features/5-Inkplate_SD_BMP_pictures/image1.bmp
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/5-Inkplate_SD_BMP_pictures/image1.bmp
Normal file → Executable file
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
0
examples/2. Advanced Inkplate Features/5-Inkplate_SD_BMP_pictures/image2.bmp
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/5-Inkplate_SD_BMP_pictures/image2.bmp
Normal file → Executable file
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
2
examples/2. Advanced Inkplate Features/6-Inkplate_SD_TXT_file/6-Inkplate_SD_TXT_file.ino
Normal file → Executable file
2
examples/2. Advanced Inkplate Features/6-Inkplate_SD_TXT_file/6-Inkplate_SD_TXT_file.ino
Normal file → Executable file
|
@ -41,7 +41,7 @@ void setup() {
|
|||
} else {
|
||||
display.clearDisplay(); //Clear everything that is stored in frame buffer of epaper
|
||||
display.setCursor(0,0); //Set print position at the begining of the screen
|
||||
char text[201]; //Array where data from SD card is stored (max 200 chars here)
|
||||
char text[200]; //Array where data from SD card is stored (max 200 chars here)
|
||||
int len = file.fileSize(); //Read how big is file that we are opening
|
||||
if(len>200) len = 200; //If it's more than 200 bytes (200 chars), limit to max 200 bytes
|
||||
file.read(text, len); //Read data from file and save it in text array
|
||||
|
|
0
examples/2. Advanced Inkplate Features/6-Inkplate_SD_TXT_file/text.txt
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/6-Inkplate_SD_TXT_file/text.txt
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/7-Inkplate_easyC/7-Inkplate_easyC.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/7-Inkplate_easyC/7-Inkplate_easyC.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/8-Inkplate_MCP23017_expander/8-Inkplate_MCP23017_expander.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/8-Inkplate_MCP23017_expander/8-Inkplate_MCP23017_expander.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/9-Inkplate_Web_Server/9-Inkplate_Web_Server.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/9-Inkplate_Web_Server/9-Inkplate_Web_Server.ino
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/9-Inkplate_Web_Server/htmlCode.h
Normal file → Executable file
0
examples/2. Advanced Inkplate Features/9-Inkplate_Web_Server/htmlCode.h
Normal file → Executable file
|
@ -17,8 +17,6 @@
|
|||
|
||||
UART settings are: 115200 baud, standard parity, ending with "\n\r" (both)
|
||||
You can send commands via USB port or by directly connecting to ESP32 TX and RX pins.
|
||||
Don't forget you need to send #L(1)* after each command to show it on the display
|
||||
(equal to display.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/
|
||||
|
|
26
examples/3. Others/1-Inkplate_Slave_Mode/Inkplate_slave_mode_documentation.txt
Normal file → Executable file
26
examples/3. Others/1-Inkplate_Slave_Mode/Inkplate_slave_mode_documentation.txt
Normal file → Executable file
|
@ -1,14 +1,12 @@
|
|||
Slave mode for Inkplate 6 by e-radionica.com
|
||||
Slave mode is uploaded to each Inkplate 6. It enables you to use the board
|
||||
without reprogramming. You just need to send commands via UART and it will
|
||||
show contents on its screen.
|
||||
You can send commands via USB port or by directly connecting to ESP32 TX and RX pins.
|
||||
|
||||
Don't forget you need to send #L(1)* after each command to show it on the display (equal to display.display()).
|
||||
|
||||
Settings are:
|
||||
115200 baud, standard parity, ending with \n\r
|
||||
|
||||
Slave mode for Inkplate 6 by e-radionica.com
|
||||
Slave mode is uploaded to each Inkplate 6. It enables you to use the board
|
||||
without reprogramming. You just need to send commands via UART and it will
|
||||
show contents on its screen.
|
||||
You can send commands via USB port or by directly connecting to ESP32 TX and RX pins.
|
||||
|
||||
Settings are:
|
||||
115200 baud, standard parity, ending with \n\r
|
||||
|
||||
echo: #?*
|
||||
Check if the Inkplate receives commands on UART
|
||||
response: OK
|
||||
|
@ -134,8 +132,8 @@ example #G(003)*
|
|||
drawBitmap: #H(XXX,YYY,"PATH")*
|
||||
XXX - X position of bitmap on display
|
||||
YYY - Y position of bitmap on display
|
||||
PATH - path to bitmap image on SD card, where path should be sent as HEX Char (same as for print command). Example: /image1.bmp should be sent as 2f696d616765312e626d70
|
||||
example: #H(000,000,"2f696d616765312e626d70")* where 2f696d616765312e626d70 means /image1.bmp
|
||||
PATH - path to bitmap image on SD card
|
||||
example: #H(000,000,"/bitmapName.bmp")*
|
||||
response: #H(1)* - Image loaded succesfully
|
||||
#H(0)* - Image load failed
|
||||
#H(-1)* - SD Card Init Error
|
||||
|
@ -172,4 +170,4 @@ panelSupply(einkOff/on):#Q(S)*
|
|||
S - State of panel power supply (S = 1 -> panel has power supply, S = 0 -> panel power supply has benn turned off)
|
||||
|
||||
getPanelState: #R(?)*
|
||||
response: #R(1)* - panel has power supply or #R(0)* - panel supply has been turned off
|
||||
response: #R(1)* - panel has power supply or #R(0)* - panel supply has been turned off
|
0
examples/3. Others/2-Inkplate_Clean_Screen/2-Inkplate_Clean_Screen.ino
Normal file → Executable file
0
examples/3. Others/2-Inkplate_Clean_Screen/2-Inkplate_Clean_Screen.ino
Normal file → Executable file
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
3-Inkplate_VariPass_Graphs example 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/
|
||||
|
||||
This example will show you how you can use the API on the VariPass website to download and display
|
||||
a sensor graph on the e-paper display.
|
||||
|
||||
VariPass is a website which allows you to host various online "variables" which you can write to
|
||||
and read from using the VariPass API. This allows you to store sensor logs and later retrieve them
|
||||
for graphing, analysis, etc.
|
||||
This example uses an already public variable as an example. The graph is fed every minute with data
|
||||
from Thorinair's (https://github.com/Thorinair/) geiger counter, so each startup of the Inkplate will
|
||||
display updated values.
|
||||
|
||||
To learn more about VariPass and how you can use it for your own projects, please visit: https://varipass.org/
|
||||
If you want to easily integrate the read/write functionality in your project, use the official library:
|
||||
https://github.com/Thorinair/VariPass-for-ESP8266-ESP32
|
||||
|
||||
Want to learn more about Inkplate? Visit www.inkplate.io
|
||||
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
|
||||
23 July 2020 by e-radionica.com
|
||||
*/
|
||||
|
||||
#include "Inkplate.h" //Include Inkplate library to the sketch
|
||||
#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 (Monochrome)
|
||||
|
||||
const char* ssid = "YourWiFiSSID"; //Your WiFi SSID
|
||||
const char* password = "YourPass"; //Your WiFi password
|
||||
|
||||
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
|
||||
|
||||
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();
|
||||
|
||||
//Use a HTTP get request to fetch the graph from VariPass.
|
||||
//The API expects a few parameters in the URL to allow it to work.
|
||||
// action - Should be set to "sgraph" or "graph" in order to generate a compatible image.
|
||||
// id - ID of the variable. It is enough to specify just the ID if the variable is public,
|
||||
// but a "key" parameter should also be specified if not.
|
||||
// width - Width of the generated graph, here set to half the Inkplate's width.
|
||||
// height - Height of the generated graph, here set to half the Inkplate's height.
|
||||
// eink - Should be set to true to generate a monochrome 1 bit bitmap better suitable for Inkplate.
|
||||
// For more detailed explanation and more parameters, please visit the docs page: https://varipass.org/docs/
|
||||
if(!display.drawBitmapFromWeb("https://api.varipass.org/?action=sgraph&id=kbg3eQfA&width=400&height=300&eink=true", 200, 150)) {
|
||||
display.println("Image open error");
|
||||
display.partialUpdate();
|
||||
}
|
||||
display.partialUpdate();
|
||||
|
||||
WiFi.mode(WIFI_OFF);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//Nothing...
|
||||
}
|
Loading…
Reference in New Issue