Browse Source

refactoring

v0.9.4
Guy Turcotte 2 years ago
parent
commit
12d58dab3f
  1. 9
      examples/Others/Inkplate_VariPass_Graphs/src/main.cpp
  2. 18
      include/graphical/image.hpp

9
examples/Others/Inkplate_VariPass_Graphs/src/main.cpp

@ -43,10 +43,15 @@ void delay(int msec) { vTaskDelay(msec / portTICK_PERIOD_MS); }
void mainTask(void * param)
{
int w, h;
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
w = display.width();
h = display.height();
display.print("Connecting to WiFi...");
display.partialUpdate();
@ -68,8 +73,8 @@ void mainTask(void * param)
// eink - Should be set to true to generate a BW 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.drawImage("https://api.varipass.org/?action=sgraph&id=kbg3eQfA&width=400&height=300&eink=true",
200, 150))
if (!display.drawBitmapFromWeb("https://api.varipass.org/?action=sgraph&id=kbg3eQfA&width=400&height=300&eink=true",
(w / 2) - 200, (h / 2) - 150))
{
ESP_LOGE(TAG, "Not able to retrieve and draw image from web address.");
display.println("Image open error");

18
include/graphical/image.hpp

@ -63,7 +63,7 @@ class Image : virtual public Adafruit_GFX
virtual void selectDisplayMode(DisplayMode _mode) = 0;
virtual DisplayMode getDisplayMode() = 0;
virtual int16_t width() = 0;
virtual int16_t width() = 0;
virtual int16_t height() = 0;
bool drawImage(const char *path, int x, int y, bool dither = 1, bool invert = 0);
@ -74,16 +74,16 @@ class Image : virtual public Adafruit_GFX
bool drawImage(const char* path, const Format& format, const Position& position, const bool dither = 1, const bool invert = 0);
bool drawBitmapFromFile(const char *fileName, int x, int y, bool dither = 0, bool invert = 0);
bool drawBitmapFromFile(FILE *p, int x, int y, bool dither = 0, bool invert = 0);
bool drawBitmapFromWeb(const char *url, int x, int y, bool dither = 0, bool invert = 0);
bool drawJpegFromFile(const char *fileName, int x, int y, bool dither = 0, bool invert = 0);
bool drawPngFromFile(const char *fileName, int x, int y, bool dither = 0, bool invert = 0);
bool drawJpegFromFile(const char *fileName, int x, int y, bool dither = 0, bool invert = 0);
bool drawJpegFromFile(FILE *p, int x, int y, bool dither = 0, bool invert = 0);
bool drawJpegFromWeb(const char *url, int x, int y, bool dither = 0, bool invert = 0);
bool drawBitmapFromFile(FILE *p, int x, int y, bool dither = 0, bool invert = 0);
bool drawJpegFromFile(FILE *p, int x, int y, bool dither = 0, bool invert = 0);
bool drawPngFromFile(FILE *p, int x, int y, bool dither = 0, bool invert = 0);
bool drawPngFromFile(const char *fileName, int x, int y, bool dither = 0, bool invert = 0);
bool drawPngFromFile(FILE *p, int x, int y, bool dither = 0, bool invert = 0);
bool drawPngFromWeb(const char *url, int x, int y, bool dither = 0, bool invert = 0);
bool drawBitmapFromWeb(const char *url, int x, int y, bool dither = 0, bool invert = 0);
bool drawJpegFromWeb(const char *url, int x, int y, bool dither = 0, bool invert = 0);
bool drawPngFromWeb(const char *url, int x, int y, bool dither = 0, bool invert = 0);
// Defined in Adafruit-GFX-Library, but should fit here
// void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);

Loading…
Cancel
Save