commit
e3cf71ef4b
2406
Inkplate.cpp
2406
Inkplate.cpp
File diff suppressed because it is too large
Load Diff
43
Inkplate.h
43
Inkplate.h
|
@ -160,19 +160,19 @@ public:
|
|||
uint8_t *_partial;
|
||||
uint8_t *D_memory4Bit;
|
||||
uint8_t *_pBuffer;
|
||||
const uint8_t LUT2[16] = {B10101010, B10101001, B10100110, B10100101, B10011010, B10011001, B10010110, B10010101, B01101010, B01101001, B01100110, B01100101, B01011010, B01011001, B01010110, B01010101};
|
||||
const uint8_t LUTW[16] = {B11111111, B11111110, B11111011, B11111010, B11101111, B11101110, B11101011, B11101010, B10111111, B10111110, B10111011, B10111010, B10101111, B10101110, B10101011, B10101010};
|
||||
const uint8_t LUTB[16] = {B11111111, B11111101, B11110111, B11110101, B11011111, B11011101, B11010111, B11010101, B01111111, B01111101, B01110111, B01110101, B01011111, B01011101, B01010111, B01010101};
|
||||
const uint8_t pixelMaskLUT[8] = {B00000001, B00000010, B00000100, B00001000, B00010000, B00100000, B01000000, B10000000};
|
||||
const uint8_t pixelMaskGLUT[2] = {B00001111, B11110000};
|
||||
const uint8_t discharge[16] = {B11111111, B11111100, B11110011, B11110000, B11001111, B11001100, B11000011, B11000000, B00111111, B00111100, B00110011, B00110000, B00001111, B00001100, B00000011, B00000000};
|
||||
const uint8_t LUT2[16] ={ B10101010, B10101001, B10100110, B10100101, B10011010, B10011001, B10010110, B10010101, B01101010, B01101001, B01100110, B01100101, B01011010, B01011001, B01010110, B01010101 };
|
||||
const uint8_t LUTW[16] ={ B11111111, B11111110, B11111011, B11111010, B11101111, B11101110, B11101011, B11101010, B10111111, B10111110, B10111011, B10111010, B10101111, B10101110, B10101011, B10101010 };
|
||||
const uint8_t LUTB[16] ={ B11111111, B11111101, B11110111, B11110101, B11011111, B11011101, B11010111, B11010101, B01111111, B01111101, B01110111, B01110101, B01011111, B01011101, B01010111, B01010101 };
|
||||
const uint8_t pixelMaskLUT[8] ={ B00000001, B00000010, B00000100, B00001000, B00010000, B00100000, B01000000, B10000000 };
|
||||
const uint8_t pixelMaskGLUT[2] ={ B00001111, B11110000 };
|
||||
const uint8_t discharge[16] ={ B11111111, B11111100, B11110011, B11110000, B11001111, B11001100, B11000011, B11000000, B00111111, B00111100, B00110011, B00110000, B00001111, B00001100, B00000011, B00000000 };
|
||||
//BLACK->WHITE
|
||||
//THIS IS OKAYISH WAVEFORM FOR GRAYSCALE. IT CAN BE MUCH BETTER.
|
||||
const uint8_t waveform3Bit[8][7] = {{0, 0, 0, 0, 1, 1, 1}, {0, 0, 1, 1, 1, 2, 1}, {0, 1, 1, 2, 1, 2, 1}, {0, 0, 1, 1, 2, 1, 2}, {1, 1, 1, 2, 2, 1, 2}, {0, 0, 1, 1, 1, 2, 2}, {0, 1, 1, 2, 1, 2, 2}, {0, 0, 0, 0, 0, 0, 2}};
|
||||
const uint8_t waveform3Bit[8][7] ={ { 0, 0, 0, 0, 1, 1, 1 }, { 0, 0, 1, 1, 1, 2, 1 }, { 0, 1, 1, 2, 1, 2, 1 }, { 0, 0, 1, 1, 2, 1, 2 }, { 1, 1, 1, 2, 2, 1, 2 }, { 0, 0, 1, 1, 1, 2, 2 }, { 0, 1, 1, 2, 1, 2, 2 }, { 0, 0, 0, 0, 0, 0, 2 } };
|
||||
//const uint8_t waveform3Bit[8][12] = {{3,3,3,1,1,1,1,1,1,1,2,0}, {3,3,3,3,1,1,1,1,1,1,2,0}, {3,3,3,3,3,1,1,1,1,1,2,0}, {3,3,3,3,3,3,1,1,1,1,2,0}, {3,3,3,3,3,3,3,1,1,1,2,0}, {3,3,3,3,3,3,3,2,1,1,2,0}, {3,3,3,3,3,3,3,3,3,1,2,0}, {3,3,3,3,3,3,3,3,3,3,2,0}};
|
||||
//const uint8_t waveform3Bit[16][12] = {{0,0,0,0,0,0,1,2,1,1,0,3},{0,0,1,1,1,2,2,2,1,1,0,3},{0,0,0,1,1,2,2,2,1,1,0,3}, {0,0,0,1,2,1,2,1,2,1,3}, {0,0,2,1,2,1,2,1,2,1,3}, {0,0,1,2,2,1,1,1,1,2,0,3}, {0,0,0,2,1,1,1,1,0,2,0,3}, {0,0,2,1,2,2,1,1,1,2,0,3}, {0,0,0,2,2,2,1,1,1,2,0,3}, {0,0,0,0,0,0,2,1,1,2,0,3}, {0,0,0,0,0,2,2,1,1,2,0,3}, {0,0,0,0,0,1,1,1,2,2,0,3}, {0,0,0,0,1,2,1,2,1,2,0,3}, {0,0,0,0,1,1,2,2,1,2,0,3},{0,0,0,0,1,1,1,2,2,2,0,3}, {0,0,0,0,0,0,0,0,0,2,0,3}};
|
||||
//PVI waveform for cleaning screen, not sure if it is correct, but it cleans screen properly.
|
||||
const uint32_t waveform[50] = {0x00000008, 0x00000008, 0x00200408, 0x80281888, 0x60a81898, 0x60a8a8a8, 0x60a8a8a8, 0x6068a868, 0x6868a868, 0x6868a868, 0x68686868, 0x6a686868, 0x5a686868, 0x5a686868, 0x5a586a68, 0x5a5a6a68, 0x5a5a6a68, 0x55566a68, 0x55565a64, 0x55555654, 0x55555556, 0x55555556, 0x55555556, 0x55555516, 0x55555596, 0x15555595, 0x95955595, 0x95959595, 0x95949495, 0x94949495, 0x94949495, 0xa4949494, 0x9494a4a4, 0x84a49494, 0x84948484, 0x84848484, 0x84848484, 0x84848484, 0xa5a48484, 0xa9a4a4a8, 0xa9a8a8a8, 0xa5a9a9a4, 0xa5a5a5a4, 0xa1a5a5a1, 0xa9a9a9a9, 0xa9a9a9a9, 0xa9a9a9a9, 0xa9a9a9a9, 0x15151515, 0x11111111};
|
||||
const uint32_t waveform[50] ={ 0x00000008, 0x00000008, 0x00200408, 0x80281888, 0x60a81898, 0x60a8a8a8, 0x60a8a8a8, 0x6068a868, 0x6868a868, 0x6868a868, 0x68686868, 0x6a686868, 0x5a686868, 0x5a686868, 0x5a586a68, 0x5a5a6a68, 0x5a5a6a68, 0x55566a68, 0x55565a64, 0x55555654, 0x55555556, 0x55555556, 0x55555556, 0x55555516, 0x55555596, 0x15555595, 0x95955595, 0x95959595, 0x95949495, 0x94949495, 0x94949495, 0xa4949494, 0x9494a4a4, 0x84a49494, 0x84948484, 0x84848484, 0x84848484, 0x84848484, 0xa5a48484, 0xa9a4a4a8, 0xa9a8a8a8, 0xa5a9a9a4, 0xa5a5a5a4, 0xa1a5a5a1, 0xa9a9a9a9, 0xa9a9a9a9, 0xa9a9a9a9, 0xa9a9a9a9, 0x15151515, 0x11111111 };
|
||||
|
||||
struct bitmapHeader
|
||||
{
|
||||
|
@ -188,6 +188,7 @@ public:
|
|||
|
||||
Inkplate(uint8_t _mode);
|
||||
void begin(void);
|
||||
uint16_t getPixel(int16_t x0, int16_t y0);
|
||||
void drawPixel(int16_t x0, int16_t y0, uint16_t color);
|
||||
void clearDisplay();
|
||||
void display();
|
||||
|
@ -198,10 +199,10 @@ public:
|
|||
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, bool dither = false, bool invert = false);
|
||||
int drawBitmapFromSD(char *fileName, int x, int y, bool dither = false, bool invert = false);
|
||||
int drawBitmapFromWeb(WiFiClient *s, int x, int y, int len, bool dither = false, bool invert = false);
|
||||
int drawBitmapFromWeb(char *url, int x, int y, bool dither = false, bool invert = false);
|
||||
void drawThickLine(int x1, int y1, int x2, int y2, int color, float thickness);
|
||||
void drawGradientLine(int x1, int y1, int x2, int y2, int color1, int color2, float thickness = -1);
|
||||
int sdCardInit();
|
||||
|
@ -223,6 +224,8 @@ public:
|
|||
|
||||
private:
|
||||
uint8_t gammaLUT[256];
|
||||
uint8_t pixelBuffer[800 * 3 + 5];
|
||||
uint8_t ditherBuffer[800 * 3 + 5][2];
|
||||
int8_t _temperature;
|
||||
uint8_t _panelOn = 0;
|
||||
uint8_t _rotation = 0;
|
||||
|
@ -235,16 +238,20 @@ private:
|
|||
void display3b();
|
||||
uint32_t read32(uint8_t *c);
|
||||
uint16_t read16(uint8_t *c);
|
||||
void ditherStart(uint8_t *pixelBuffer, uint8_t* bufferPtr, int w, bool invert, uint8_t bits);
|
||||
void ditherLoadNextLine(uint8_t *pixelBuffer, uint8_t* bufferPtr, int w, bool invert, uint8_t bits);
|
||||
uint8_t ditherGetPixel(int i, int j, int w, int h);
|
||||
uint8_t ditherSwap(int w);
|
||||
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 drawGrayscaleBitmap4Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool dither, bool invert);
|
||||
int drawGrayscaleBitmap8Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool dither, bool invert);
|
||||
int drawGrayscaleBitmap24Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool dither, 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);
|
||||
int drawGrayscaleBitmap4Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool dither, bool invert);
|
||||
int drawGrayscaleBitmap8Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool dither, bool invert);
|
||||
int drawGrayscaleBitmap24Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool dither, bool invert);
|
||||
void precalculateGamma(uint8_t *c, float gamma);
|
||||
};
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,26 @@
|
|||
.. Inkplate 6 documentation master file, created by
|
||||
sphinx-quickstart on Mon Aug 3 13:10:28 2020.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
*************
|
||||
.begin method
|
||||
*************
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
|
||||
*************
|
||||
What is this?
|
||||
*************
|
||||
|
||||
Used to intiate Inkplate
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
|
@ -10,6 +10,7 @@ Welcome to Inkplate 6's documentation!
|
|||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
begin
|
||||
|
||||
*************
|
||||
What is this?
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>.begin method — Inkplate 6 documentation</title>
|
||||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||||
<script src="_static/jquery.js"></script>
|
||||
<script src="_static/underscore.js"></script>
|
||||
<script src="_static/doctools.js"></script>
|
||||
<script src="_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
<link rel="prev" title="Welcome to Inkplate 6’s documentation!" href="index.html" />
|
||||
|
||||
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
|
||||
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
|
||||
|
||||
</head><body>
|
||||
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
|
||||
|
||||
<div class="body" role="main">
|
||||
|
||||
<div class="section" id="begin-method">
|
||||
<h1>.begin method<a class="headerlink" href="#begin-method" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="what-is-this">
|
||||
<h1>What is this?<a class="headerlink" href="#what-is-this" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Used to intiate Inkplate</p>
|
||||
<div class="section" id="indices-and-tables">
|
||||
<h2>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h2>
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
|
||||
<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
|
||||
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h1 class="logo"><a href="index.html">Inkplate 6</a></h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Navigation</h3>
|
||||
<p class="caption"><span class="caption-text">Contents:</span></p>
|
||||
<ul class="current">
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">.begin method</a><ul class="simple">
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="#what-is-this">What is this?</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="index.html">Documentation overview</a><ul>
|
||||
<li>Previous: <a href="index.html" title="previous chapter">Welcome to Inkplate 6’s documentation!</a></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
©2020, e-radionica.com.
|
||||
|
||||
|
|
||||
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.1.2</a>
|
||||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
||||
|
||||
|
|
||||
<a href="_sources/begin.rst.txt"
|
||||
rel="nofollow">Page source</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -55,6 +55,11 @@
|
|||
|
||||
|
||||
<h3>Navigation</h3>
|
||||
<p class="caption"><span class="caption-text">Contents:</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="begin.html">.begin method</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="begin.html#what-is-this">What is this?</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<script src="_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
<link rel="next" title=".begin method" href="begin.html" />
|
||||
|
||||
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
|
||||
|
||||
|
@ -34,6 +35,16 @@
|
|||
<div class="section" id="welcome-to-inkplate-6-s-documentation">
|
||||
<h1>Welcome to Inkplate 6’s documentation!<a class="headerlink" href="#welcome-to-inkplate-6-s-documentation" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
<p class="caption"><span class="caption-text">Contents:</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="begin.html">.begin method</a><ul class="simple">
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="begin.html#what-is-this">What is this?</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="begin.html#indices-and-tables">Indices and tables</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="what-is-this">
|
||||
<h2>What is this?<a class="headerlink" href="#what-is-this" title="Permalink to this headline">¶</a></h2>
|
||||
|
@ -70,11 +81,17 @@
|
|||
|
||||
|
||||
<h3>Navigation</h3>
|
||||
<p class="caption"><span class="caption-text">Contents:</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="begin.html">.begin method</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="begin.html#what-is-this">What is this?</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="#">Documentation overview</a><ul>
|
||||
<li>Next: <a href="begin.html" title="next chapter">.begin method</a></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Binary file not shown.
|
@ -74,6 +74,11 @@
|
|||
|
||||
|
||||
<h3>Navigation</h3>
|
||||
<p class="caption"><span class="caption-text">Contents:</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="begin.html">.begin method</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="begin.html#what-is-this">What is this?</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
<h3>Related Topics</h3>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Search.setIndex({docnames:["index"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,sphinx:56},filenames:["index.rst"],objects:{},objnames:{},objtypes:{},terms:{"function":0,For:0,aaaa:[],all:0,can:0,code:0,descript:0,exampl:0,file:0,find:0,first:0,header:0,here:0,includ:0,index:0,kako:[],librari:0,like:0,modul:0,need:0,our:0,ovo:[],page:0,print:[],radi:[],rang:[],search:0,test:[],top:0,work:0,you:0,your:0,znam:[]},titles:["Welcome to Inkplate 6\u2019s documentation!"],titleterms:{document:0,indic:0,inkplat:0,tabl:0,thi:0,welcom:0,what:0}})
|
||||
Search.setIndex({docnames:["begin","index"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,sphinx:56},filenames:["begin.rst","index.rst"],objects:{},objnames:{},objtypes:{},terms:{"function":1,For:1,Used:0,aaaa:[],all:1,begin:1,can:1,code:1,content:1,descript:1,exampl:1,file:1,find:1,first:1,header:1,here:1,includ:1,index:[0,1],inkplat:0,intiat:0,kako:[],librari:1,like:1,method:1,modul:[0,1],need:1,our:1,ovo:[],page:[0,1],print:[],radi:[],rang:[],search:[0,1],test:[],top:1,work:1,you:1,your:1,znam:[]},titles:[".begin method","Welcome to Inkplate 6\u2019s documentation!"],titleterms:{begin:0,document:1,indic:[0,1],inkplat:1,method:0,tabl:[0,1],thi:[0,1],welcom:1,what:[0,1]}})
|
|
@ -0,0 +1,26 @@
|
|||
.. Inkplate 6 documentation master file, created by
|
||||
sphinx-quickstart on Mon Aug 3 13:10:28 2020.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
*************
|
||||
.begin method
|
||||
*************
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
|
||||
*************
|
||||
What is this?
|
||||
*************
|
||||
|
||||
Used to intiate Inkplate
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
|
@ -10,6 +10,7 @@ Welcome to Inkplate 6's documentation!
|
|||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
begin
|
||||
|
||||
*************
|
||||
What is this?
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
2_Basic_grayscale example for e-radionica.com Inkplate 6
|
||||
For this example you will need only USB cable and Inkplate 6
|
||||
Select "Inkplate 6(ESP32)" from Tools -> Board menu.
|
||||
Don't have "Inkplate 6(ESP32)" option? Follow our tutorial and add it:
|
||||
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 draw some simple graphics using
|
||||
|
||||
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
|
||||
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.
|
||||
Color is represented by number, where number 0 means black and number 7 means white, while everything in between are shades of gray.
|
||||
|
||||
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,278 +26,278 @@ Inkplate display(INKPLATE_3BIT); //Create object on Inkplate library and set lib
|
|||
|
||||
void setup()
|
||||
{
|
||||
display.begin(); //Init library (you should call this function ONLY ONCE)
|
||||
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
|
||||
delay(5000); //Wait a little bit
|
||||
display.begin(); //Init library (you should call this function ONLY ONCE)
|
||||
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
|
||||
delay(5000); //Wait a little bit
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Example will demostrate funcionality one by one. You always first set everything in the frame buffer and afterwards you show
|
||||
//it on the screen using display.display().
|
||||
//Example will demostrate funcionality one by one. You always first set everything in the frame buffer and afterwards you show
|
||||
//it on the screen using display.display().
|
||||
|
||||
//Let'sstart by drawing pixel at x = 100 and y = 50 location
|
||||
display.clearDisplay(); //Clear everytning that is inside frame buffer in ESP32
|
||||
display.drawPixel(100, 50, 0); //Draw one black pixel at X = 100, Y = 50 position in 0 (BLACK) color
|
||||
displayCurrentAction("Drawing a pixel"); //Function which writes small text at bottom left indicating what's currently done
|
||||
//NOTE: you do not need displayCurrentAction function to use Inkplate!
|
||||
display.display(); //Send image to display. You need to call this one each time you want to transfer frame buffer to the screen.
|
||||
delay(DELAY_MS); //Wait a little bit
|
||||
//Let'sstart by drawing pixel at x = 100 and y = 50 location
|
||||
display.clearDisplay(); //Clear everytning that is inside frame buffer in ESP32
|
||||
display.drawPixel(100, 50, 0); //Draw one black pixel at X = 100, Y = 50 position in 0 (BLACK) color
|
||||
displayCurrentAction("Drawing a pixel"); //Function which writes small text at bottom left indicating what's currently done
|
||||
//NOTE: you do not need displayCurrentAction function to use Inkplate!
|
||||
display.display(); //Send image to display. You need to call this one each time you want to transfer frame buffer to the screen.
|
||||
delay(DELAY_MS); //Wait a little bit
|
||||
|
||||
//Now, let's draw some random pixels!
|
||||
display.clearDisplay(); //Clear everything that is inside frame buffer in ESP32
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{ //Write 1000 random colored pixels at random locations
|
||||
display.drawPixel(random(0, 799), random(0, 599), random(0, 7)); //We are setting color of the pixels using numbers from 0 to 7,
|
||||
} //where 0 mens black, 7 white and gray is in between
|
||||
displayCurrentAction("Drawing 600 random pixels in random colors");
|
||||
display.display(); //Write everything from frame buffer to screen
|
||||
delay(DELAY_MS); //Wait
|
||||
//Now, let's draw some random pixels!
|
||||
display.clearDisplay(); //Clear everything that is inside frame buffer in ESP32
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{ //Write 1000 random colored pixels at random locations
|
||||
display.drawPixel(random(0, 799), random(0, 599), random(0, 7)); //We are setting color of the pixels using numbers from 0 to 7,
|
||||
} //where 0 mens black, 7 white and gray is in between
|
||||
displayCurrentAction("Drawing 600 random pixels in random colors");
|
||||
display.display(); //Write everything from frame buffer to screen
|
||||
delay(DELAY_MS); //Wait
|
||||
|
||||
//Draw two diagonal lines accros screen
|
||||
display.clearDisplay();
|
||||
display.drawLine(0, 0, 799, 599, 0); //All of those drawing fuctions originate from Adafruit GFX library, so maybe you are already familiar
|
||||
display.drawLine(799, 0, 0, 599, 0); //with those. Arguments are: start X, start Y, ending X, ending Y, color.
|
||||
displayCurrentAction("Drawing two diagonal lines");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//And again, let's draw some random lines on screen!
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
display.drawLine(random(0, 799), random(0, 599), random(0, 799), random(0, 599), random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing 50 random lines in random colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Let's draw some random thick lines on screen!
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
display.drawThickLine(random(0, 799), random(0, 599), random(0, 799), random(0, 599), random(0, 7), (float)random(1, 20));
|
||||
}
|
||||
displayCurrentAction("Drawing 50 random lines in random colors and thickness");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Let's draw some random gradient thick lines on screen!
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
int startColor = random(0, 7);
|
||||
int endColor = random(startColor, 7);
|
||||
display.drawGradientLine(random(0, 799), random(0, 599), random(0, 799), random(0, 599), startColor, endColor, (float)random(1, 20));
|
||||
}
|
||||
displayCurrentAction("Drawing 50 random gradient lines in random colors and thickness");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Now draw one horizontal...
|
||||
display.clearDisplay();
|
||||
display.drawFastHLine(100, 100, 600, 0); //Arguments are: starting X, starting Y, length, color
|
||||
displayCurrentAction("Drawing one horizontal line");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//... and one vertical line
|
||||
display.clearDisplay();
|
||||
display.drawFastVLine(100, 100, 400, 0); //Arguments are: starting X, starting Y, length, color
|
||||
displayCurrentAction("Drawing one vertical line");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Now, let' make a grid using only horizontal and vertical lines in random colors!
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 800; i += 8)
|
||||
{
|
||||
display.drawFastVLine(i, 0, 600, (i / 8) & 0x0F);
|
||||
}
|
||||
for (int i = 0; i < 600; i += 4)
|
||||
{
|
||||
display.drawFastHLine(0, i, 800, (i / 8) & 0x0F);
|
||||
}
|
||||
displayCurrentAction("Drawing a grid using horizontal and vertical lines in different colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw rectangle at X = 200, Y = 200 and size of 400x300 pixels
|
||||
display.clearDisplay();
|
||||
display.drawRect(200, 200, 400, 300, 0); //Arguments are: start X, start Y, size X, size Y, color
|
||||
displayCurrentAction("Drawing rectangle");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw rectangles on random location, size 100x150 pixels in random color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
display.drawRect(random(0, 799), random(0, 599), 100, 150, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many rectangles in random colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw filled black rectangle at X = 200, Y = 200, size of 400x300 pixels in gray color
|
||||
display.clearDisplay();
|
||||
display.fillRect(200, 200, 400, 300, 4); //Arguments are: start X, start Y, size X, size Y, color
|
||||
displayCurrentAction("Drawing gray rectangle");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw filled random colored rectangles on random location, size of 30x30 pixels in radnom color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
display.fillRect(random(0, 799), random(0, 599), 30, 30, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many filled rectangles randomly in random colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw circle at center of a screen with radius of 75 pixels
|
||||
display.clearDisplay();
|
||||
display.drawCircle(400, 300, 75, 0); //Arguments are: start X, start Y, radius, color
|
||||
displayCurrentAction("Drawing a circle");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw some random colored circles at random location with radius of 25 pixels in random color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
display.drawCircle(random(0, 799), random(0, 599), 25, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many circles randomly in random colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw black filled circle at center of a screen with radius of 75 pixels
|
||||
display.clearDisplay();
|
||||
display.fillCircle(400, 300, 75, 0); //Arguments are: start X, start Y, radius, color
|
||||
displayCurrentAction("Drawing black-filled circle");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw some random colored filled circles at random location with radius of 15 pixels
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
display.fillCircle(random(0, 799), random(0, 599), 15, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many filled circles randomly in random colors");
|
||||
display.display(); //To show stuff on screen, you always need to call display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw rounded rectangle at X = 200, Y = 200 and size of 400x300 pixels and radius of 10 pixels
|
||||
display.clearDisplay();
|
||||
display.drawRoundRect(200, 200, 400, 300, 10, 0); //Arguments are: start X, start Y, size X, size Y, radius, color
|
||||
displayCurrentAction("Drawing rectangle with rounded edges");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw rounded rectangles on random location, size 100x150 pixels, radius of 5 pixels in radnom color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
display.drawRoundRect(random(0, 799), random(0, 599), 100, 150, 5, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many rounded edges rectangles");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw filled random colored rectangle at X = 200, Y = 200, size of 400x300 pixels and radius of 10 pixels
|
||||
display.clearDisplay();
|
||||
display.fillRoundRect(200, 200, 400, 300, 10, 0); //Arguments are: start X, start Y, size X, size Y, radius, color
|
||||
displayCurrentAction("Drawing filled rectangle with rounded edges");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw filled random colored rectangle on random location, size of 30x30 pixels, radius of 3 pixels in radnom color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
display.fillRoundRect(random(0, 799), random(0, 599), 30, 30, 3, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many filled rectangle with rounded edges in random colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw simple triangle
|
||||
display.clearDisplay();
|
||||
display.drawTriangle(250, 400, 550, 400, 400, 100, 0); //Arguments are: X1, Y1, X2, Y2, X3, Y3, color
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw filled triangle inside simple triangle (so no display.clearDisplay() this time)
|
||||
display.fillTriangle(300, 350, 500, 350, 400, 150, 0); //Arguments are: X1, Y1, X2, Y2, X3, Y3, color
|
||||
displayCurrentAction("Drawing filled triangle inside exsisting one");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Display some grayscale image on screen. We are going to display e-radionica logo on display at location X = 100, Y = 100
|
||||
//Image size is 500x332 pixels.
|
||||
display.clearDisplay();
|
||||
display.drawBitmap3Bit(100, 100, picture1, 500, 332); //Arguments are: start X, start Y, array variable name, size X, size Y
|
||||
displayCurrentAction("Drawing a bitmap image");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Write some text on screen with different sizes and color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
display.setTextColor(i);
|
||||
display.setTextSize(i + 1); //textSize parameter starts at 0 and goes up to 10 (larger won't fit Inkplate 6 screen)
|
||||
display.setCursor(200, (i * i * 8)); //setCursor works as same as on LCD displays - sets "the cursor" at the place you want to write someting next
|
||||
display.print("INKPLATE6!"); //The actual text you want to show on e-paper as String
|
||||
}
|
||||
displayCurrentAction("Text in different sizes and shadings");
|
||||
display.display(); //To show stuff on screen, you always need to call display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Write same text on different location, but now invert colors (text is white, text background is black)
|
||||
display.setTextColor(7, 0); //First argument is text color, while second argument is background color. In greyscale,
|
||||
for (int i = 0; i < 6; i++)
|
||||
{ //you are able to choose from 8 different colors (0-7)
|
||||
display.setTextSize(i + 1);
|
||||
display.setCursor(200, 300 + (i * i * 8));
|
||||
display.print("INKPLATE6!");
|
||||
}
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Write text and rotate it by 90 deg. forever
|
||||
int r = 0;
|
||||
display.setTextSize(8);
|
||||
display.setTextColor(7, 0);
|
||||
while (true)
|
||||
{
|
||||
display.setCursor(100, 100);
|
||||
//Draw two diagonal lines accros screen
|
||||
display.clearDisplay();
|
||||
display.setRotation(r); //Set rotation will sent rotation for the entire display, so you can use it sideways or upside-down
|
||||
display.print("INKPLATE6");
|
||||
display.drawLine(0, 0, 799, 599, 0); //All of those drawing fuctions originate from Adafruit GFX library, so maybe you are already familiar
|
||||
display.drawLine(799, 0, 0, 599, 0); //with those. Arguments are: start X, start Y, ending X, ending Y, color.
|
||||
displayCurrentAction("Drawing two diagonal lines");
|
||||
display.display();
|
||||
r++;
|
||||
delay(DELAY_MS);
|
||||
}
|
||||
|
||||
//Did you know that you can change between monochrome and greyscale mode anytime?
|
||||
//Just call Inkplate display(INKPLATE_1BIT) or Inkplate display(INKPLATE_3BIT)
|
||||
//And again, let's draw some random lines on screen!
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
display.drawLine(random(0, 799), random(0, 599), random(0, 799), random(0, 599), random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing 50 random lines in random colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Let's draw some random thick lines on screen!
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
display.drawThickLine(random(0, 799), random(0, 599), random(0, 799), random(0, 599), random(0, 7), (float)random(1, 20));
|
||||
}
|
||||
displayCurrentAction("Drawing 50 random lines in random colors and thickness");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Let's draw some random gradient thick lines on screen!
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
int startColor = random(0, 7);
|
||||
int endColor = random(startColor, 7);
|
||||
display.drawGradientLine(random(0, 799), random(0, 599), random(0, 799), random(0, 599), startColor, endColor, (float)random(1, 20));
|
||||
}
|
||||
displayCurrentAction("Drawing 50 random gradient lines in random colors and thickness");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Now draw one horizontal...
|
||||
display.clearDisplay();
|
||||
display.drawFastHLine(100, 100, 600, 0); //Arguments are: starting X, starting Y, length, color
|
||||
displayCurrentAction("Drawing one horizontal line");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//... and one vertical line
|
||||
display.clearDisplay();
|
||||
display.drawFastVLine(100, 100, 400, 0); //Arguments are: starting X, starting Y, length, color
|
||||
displayCurrentAction("Drawing one vertical line");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Now, let' make a grid using only horizontal and vertical lines in random colors!
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 800; i += 8)
|
||||
{
|
||||
display.drawFastVLine(i, 0, 600, (i / 8) & 0x0F);
|
||||
}
|
||||
for (int i = 0; i < 600; i += 4)
|
||||
{
|
||||
display.drawFastHLine(0, i, 800, (i / 8) & 0x0F);
|
||||
}
|
||||
displayCurrentAction("Drawing a grid using horizontal and vertical lines in different colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw rectangle at X = 200, Y = 200 and size of 400x300 pixels
|
||||
display.clearDisplay();
|
||||
display.drawRect(200, 200, 400, 300, 0); //Arguments are: start X, start Y, size X, size Y, color
|
||||
displayCurrentAction("Drawing rectangle");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw rectangles on random location, size 100x150 pixels in random color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
display.drawRect(random(0, 799), random(0, 599), 100, 150, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many rectangles in random colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw filled black rectangle at X = 200, Y = 200, size of 400x300 pixels in gray color
|
||||
display.clearDisplay();
|
||||
display.fillRect(200, 200, 400, 300, 4); //Arguments are: start X, start Y, size X, size Y, color
|
||||
displayCurrentAction("Drawing gray rectangle");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw filled random colored rectangles on random location, size of 30x30 pixels in radnom color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
display.fillRect(random(0, 799), random(0, 599), 30, 30, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many filled rectangles randomly in random colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw circle at center of a screen with radius of 75 pixels
|
||||
display.clearDisplay();
|
||||
display.drawCircle(400, 300, 75, 0); //Arguments are: start X, start Y, radius, color
|
||||
displayCurrentAction("Drawing a circle");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw some random colored circles at random location with radius of 25 pixels in random color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
display.drawCircle(random(0, 799), random(0, 599), 25, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many circles randomly in random colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw black filled circle at center of a screen with radius of 75 pixels
|
||||
display.clearDisplay();
|
||||
display.fillCircle(400, 300, 75, 0); //Arguments are: start X, start Y, radius, color
|
||||
displayCurrentAction("Drawing black-filled circle");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw some random colored filled circles at random location with radius of 15 pixels
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
display.fillCircle(random(0, 799), random(0, 599), 15, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many filled circles randomly in random colors");
|
||||
display.display(); //To show stuff on screen, you always need to call display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw rounded rectangle at X = 200, Y = 200 and size of 400x300 pixels and radius of 10 pixels
|
||||
display.clearDisplay();
|
||||
display.drawRoundRect(200, 200, 400, 300, 10, 0); //Arguments are: start X, start Y, size X, size Y, radius, color
|
||||
displayCurrentAction("Drawing rectangle with rounded edges");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw rounded rectangles on random location, size 100x150 pixels, radius of 5 pixels in radnom color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
display.drawRoundRect(random(0, 799), random(0, 599), 100, 150, 5, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many rounded edges rectangles");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw filled random colored rectangle at X = 200, Y = 200, size of 400x300 pixels and radius of 10 pixels
|
||||
display.clearDisplay();
|
||||
display.fillRoundRect(200, 200, 400, 300, 10, 0); //Arguments are: start X, start Y, size X, size Y, radius, color
|
||||
displayCurrentAction("Drawing filled rectangle with rounded edges");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw filled random colored rectangle on random location, size of 30x30 pixels, radius of 3 pixels in radnom color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
display.fillRoundRect(random(0, 799), random(0, 599), 30, 30, 3, random(0, 7));
|
||||
}
|
||||
displayCurrentAction("Drawing many filled rectangle with rounded edges in random colors");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw simple triangle
|
||||
display.clearDisplay();
|
||||
display.drawTriangle(250, 400, 550, 400, 400, 100, 0); //Arguments are: X1, Y1, X2, Y2, X3, Y3, color
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Draw filled triangle inside simple triangle (so no display.clearDisplay() this time)
|
||||
display.fillTriangle(300, 350, 500, 350, 400, 150, 0); //Arguments are: X1, Y1, X2, Y2, X3, Y3, color
|
||||
displayCurrentAction("Drawing filled triangle inside exsisting one");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Display some grayscale image on screen. We are going to display e-radionica logo on display at location X = 100, Y = 100
|
||||
//Image size is 500x332 pixels.
|
||||
display.clearDisplay();
|
||||
display.drawBitmap3Bit(100, 100, picture1, 500, 332); //Arguments are: start X, start Y, array variable name, size X, size Y
|
||||
displayCurrentAction("Drawing a bitmap image");
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Write some text on screen with different sizes and color
|
||||
display.clearDisplay();
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
display.setTextColor(i);
|
||||
display.setTextSize(i + 1); //textSize parameter starts at 0 and goes up to 10 (larger won't fit Inkplate 6 screen)
|
||||
display.setCursor(200, (i * i * 8)); //setCursor works as same as on LCD displays - sets "the cursor" at the place you want to write someting next
|
||||
display.print("INKPLATE6!"); //The actual text you want to show on e-paper as String
|
||||
}
|
||||
displayCurrentAction("Text in different sizes and shadings");
|
||||
display.display(); //To show stuff on screen, you always need to call display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Write same text on different location, but now invert colors (text is white, text background is black)
|
||||
display.setTextColor(7, 0); //First argument is text color, while second argument is background color. In greyscale,
|
||||
for (int i = 0; i < 6; i++)
|
||||
{ //you are able to choose from 8 different colors (0-7)
|
||||
display.setTextSize(i + 1);
|
||||
display.setCursor(200, 300 + (i * i * 8));
|
||||
display.print("INKPLATE6!");
|
||||
}
|
||||
display.display();
|
||||
delay(DELAY_MS);
|
||||
|
||||
//Write text and rotate it by 90 deg. forever
|
||||
int r = 0;
|
||||
display.setTextSize(8);
|
||||
display.setTextColor(7, 0);
|
||||
while (true)
|
||||
{
|
||||
display.setCursor(100, 100);
|
||||
display.clearDisplay();
|
||||
display.setRotation(r); //Set rotation will sent rotation for the entire display, so you can use it sideways or upside-down
|
||||
display.print("INKPLATE6");
|
||||
display.display();
|
||||
r++;
|
||||
delay(DELAY_MS);
|
||||
}
|
||||
|
||||
//Did you know that you can change between monochrome and greyscale mode anytime?
|
||||
//Just call Inkplate display(INKPLATE_1BIT) or Inkplate display(INKPLATE_3BIT)
|
||||
}
|
||||
|
||||
//Small function that will write on the screen what function is currently in demonstration.
|
||||
void displayCurrentAction(String text)
|
||||
{
|
||||
display.setTextSize(2);
|
||||
display.setCursor(2, 580);
|
||||
display.print(text);
|
||||
display.setTextSize(2);
|
||||
display.setCursor(2, 580);
|
||||
display.print(text);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include "Inkplate.h"
|
||||
|
||||
void setup() {
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
|
@ -2,13 +2,13 @@
|
|||
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:
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -21,81 +21,82 @@
|
|||
#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
|
||||
const char* ssid = ""; //Your WiFi SSID
|
||||
const char* password = ""; //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.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.print("Connecting to WiFi...");
|
||||
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();
|
||||
//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 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)) {
|
||||
//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 fifth "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.
|
||||
//Forth parameter will dither the image.
|
||||
//Photo taken by: Roberto Fernandez
|
||||
if (!display.drawBitmapFromWeb("https://varipass.org/neowise_mono.bmp", 0, 0, false, 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!
|
||||
//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();
|
||||
}
|
||||
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("Invalid response length");
|
||||
display.display();
|
||||
display.println("HTTP error");
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
else {
|
||||
display.println("HTTP error");
|
||||
display.display();
|
||||
}
|
||||
|
||||
http.end();
|
||||
|
||||
WiFi.mode(WIFI_OFF);
|
||||
http.end();
|
||||
|
||||
WiFi.mode(WIFI_OFF);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//Nothing...
|
||||
//Nothing...
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
5_Inkplate_SD_BMP example for e-radionica Inkplate6
|
||||
For this example you will need a micro USB cable, Inkplate6 and a SD card loaded with
|
||||
For this example you will need a micro USB cable, Inkplate6 and a SD card loaded with
|
||||
image1.bmp and image2.bmp 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:
|
||||
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 .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), 4 bit, 8 bit and
|
||||
24 bit AND 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 .bmp files (pictures) from SD card and
|
||||
This example will show you how you can read .bmp files (pictures) from SD card and
|
||||
display that image on e-paper display.
|
||||
|
||||
Want to learn more about Inkplate? Visit www.inkplate.io
|
||||
|
@ -27,42 +27,46 @@ Inkplate display(INKPLATE_1BIT); //Create an object on Inkplate library and a
|
|||
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
|
||||
Serial.begin(115200);
|
||||
|
||||
//Init SD card. Display if SD card is init propery or not.
|
||||
if (display.sdCardInit()) {
|
||||
display.println("SD Card OK! Reading image...");
|
||||
display.partialUpdate();
|
||||
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
|
||||
|
||||
//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!
|
||||
display.println("Image open error");
|
||||
display.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=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, 1)) {
|
||||
//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!
|
||||
//You can turn of dithering for somewhat faster image load by changing the last 1 to 0, or removing the 1 argument completely
|
||||
display.println("Image open error");
|
||||
display.display();
|
||||
}
|
||||
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);
|
||||
}
|
||||
delay(5000);
|
||||
|
||||
//Now try to load image using SdFat library class (for more advanced users) and display image on epaper.
|
||||
if(file.open("image2.bmp", O_RDONLY)) {
|
||||
display.drawBitmapFromSD(&file, 0, 0);
|
||||
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);
|
||||
}
|
||||
delay(5000);
|
||||
|
||||
//Now try to load image using SdFat library class (for more advanced users) and display image on epaper.
|
||||
if (file.open("image2.bmp", O_RDONLY)) {
|
||||
display.drawBitmapFromSD(&file, 0, 0);
|
||||
display.display();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//Nothing...
|
||||
//Nothing...
|
||||
}
|
||||
|
|
|
@ -55,11 +55,18 @@ Inkplate display(INKPLATE_1BIT);
|
|||
Network network;
|
||||
|
||||
// Contants used for drawing icons
|
||||
char abbrs[32][16] = {"sn", "sl", "h", "t", "hr", "lr", "s", "hc", "lc", "c"};
|
||||
const uint8_t *logos[16] = {icon_sn, icon_sl, icon_h, icon_t, icon_hr, icon_lr, icon_s, icon_hc, icon_lc, icon_c};
|
||||
char abbrs[32][16] ={ "sn", "sl", "h", "t", "hr", "lr", "s", "hc", "lc", "c" };
|
||||
const uint8_t *logos[16] ={ icon_sn, icon_sl, icon_h, icon_t, icon_hr, icon_lr, icon_s, icon_hc, icon_lc, icon_c };
|
||||
const uint8_t *s_logos[16] ={ icon_s_sn, icon_s_sl, icon_s_h, icon_s_t, icon_s_hr, icon_s_lr, icon_s_s, icon_s_hc, icon_s_lc, icon_s_c };
|
||||
|
||||
|
||||
char abbr1[16];
|
||||
char abbr2[16];
|
||||
char abbr3[16];
|
||||
char abbr4[16];
|
||||
|
||||
// Variables for storing temperature
|
||||
char temps[8][4] = {
|
||||
char temps[8][4] ={
|
||||
"0F",
|
||||
"0F",
|
||||
"0F",
|
||||
|
@ -67,7 +74,7 @@ char temps[8][4] = {
|
|||
};
|
||||
|
||||
// Variables for storing days of the week
|
||||
char days[8][4] = {
|
||||
char days[8][4] ={
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
|
@ -138,7 +145,7 @@ void loop()
|
|||
// Get all relevant data, see Network.cpp for info
|
||||
network.getTime(currentTime);
|
||||
network.getDays(days[0], days[1], days[2], days[3]);
|
||||
network.getData(city, temps[0], temps[1], temps[2], temps[3], currentTemp, currentWind, currentTime, currentWeather, currentWeatherAbbr);
|
||||
network.getData(city, temps[0], temps[1], temps[2], temps[3], currentTemp, currentWind, currentTime, currentWeather, currentWeatherAbbr, abbr1, abbr2, abbr3, abbr4);
|
||||
|
||||
// Draw data, see functions below for info
|
||||
drawWeather();
|
||||
|
@ -153,6 +160,8 @@ void loop()
|
|||
else
|
||||
display.partialUpdate();
|
||||
|
||||
|
||||
|
||||
// Go to sleep before checking again
|
||||
esp_sleep_enable_timer_wakeup(1000L * DELAY_MS);
|
||||
(void)esp_light_sleep_start();
|
||||
|
@ -220,38 +229,66 @@ void drawTemps()
|
|||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE, BLACK);
|
||||
|
||||
display.setCursor(1 * rectSpacing + 0 * rectWidth + textMargin, 300 + textMargin + 70);
|
||||
display.setCursor(1 * rectSpacing + 0 * rectWidth + textMargin, 300 + textMargin + 40);
|
||||
display.println(days[0]);
|
||||
|
||||
display.setCursor(2 * rectSpacing + 1 * rectWidth + textMargin, 300 + textMargin + 70);
|
||||
display.setCursor(2 * rectSpacing + 1 * rectWidth + textMargin, 300 + textMargin + 40);
|
||||
display.println(days[1]);
|
||||
|
||||
display.setCursor(3 * rectSpacing + 2 * rectWidth + textMargin, 300 + textMargin + 70);
|
||||
display.setCursor(3 * rectSpacing + 2 * rectWidth + textMargin, 300 + textMargin + 40);
|
||||
display.println(days[2]);
|
||||
|
||||
display.setCursor(4 * rectSpacing + 3 * rectWidth + textMargin, 300 + textMargin + 70);
|
||||
display.setCursor(4 * rectSpacing + 3 * rectWidth + textMargin, 300 + textMargin + 40);
|
||||
display.println(days[3]);
|
||||
|
||||
// Drawing temperature values into black rectangles
|
||||
//Drawing temperature values into black rectangles
|
||||
display.setFont(&Roboto_Light_48);
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE, BLACK);
|
||||
|
||||
display.setCursor(1 * rectSpacing + 0 * rectWidth + textMargin, 300 + textMargin + 160);
|
||||
display.setCursor(1 * rectSpacing + 0 * rectWidth + textMargin, 300 + textMargin + 120);
|
||||
display.print(temps[0]);
|
||||
display.println(F("C"));
|
||||
|
||||
display.setCursor(2 * rectSpacing + 1 * rectWidth + textMargin, 300 + textMargin + 160);
|
||||
display.setCursor(2 * rectSpacing + 1 * rectWidth + textMargin, 300 + textMargin + 120);
|
||||
display.print(temps[1]);
|
||||
display.println(F("C"));
|
||||
|
||||
display.setCursor(3 * rectSpacing + 2 * rectWidth + textMargin, 300 + textMargin + 160);
|
||||
display.setCursor(3 * rectSpacing + 2 * rectWidth + textMargin, 300 + textMargin + 120);
|
||||
display.print(temps[2]);
|
||||
display.println(F("C"));
|
||||
|
||||
display.setCursor(4 * rectSpacing + 3 * rectWidth + textMargin, 300 + textMargin + 160);
|
||||
display.setCursor(4 * rectSpacing + 3 * rectWidth + textMargin, 300 + textMargin + 120);
|
||||
display.print(temps[3]);
|
||||
display.println(F("C"));
|
||||
|
||||
for (int i = 0; i < 18; ++i)
|
||||
{
|
||||
//If found draw specified icon
|
||||
if (strcmp(abbr1, abbrs[i]) == 0)
|
||||
display.drawBitmap(1 * rectSpacing + 0 * rectWidth + textMargin, 300 + textMargin + 150, s_logos[i], 48, 48, WHITE, BLACK);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 18; ++i)
|
||||
{
|
||||
//If found draw specified icon
|
||||
if (strcmp(abbr2, abbrs[i]) == 0)
|
||||
display.drawBitmap(2 * rectSpacing + 1 * rectWidth + textMargin, 300 + textMargin + 150, s_logos[i], 48, 48, WHITE, BLACK);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 18; ++i)
|
||||
{
|
||||
//If found draw specified icon
|
||||
if (strcmp(abbr3, abbrs[i]) == 0)
|
||||
display.drawBitmap(3 * rectSpacing + 2 * rectWidth + textMargin, 300 + textMargin + 150, s_logos[i], 48, 48, WHITE, BLACK);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 18; ++i)
|
||||
{
|
||||
//If found draw specified icon
|
||||
if (strcmp(abbr4, abbrs[i]) == 0)
|
||||
display.drawBitmap(4 * rectSpacing + 3 * rectWidth + textMargin, 300 + textMargin + 150, s_logos[i], 48, 48, WHITE, BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
// Current weather drawing function
|
|
@ -3,20 +3,15 @@
|
|||
#include "Network.h"
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <WiFiMulti.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
// WiFiMulti object declaration
|
||||
WiFiMulti WiFiMulti;
|
||||
|
||||
// Static Json from ArduinoJson library
|
||||
StaticJsonDocument<6000> doc;
|
||||
|
||||
// Declared week days
|
||||
char weekDays[8][8] = {
|
||||
char weekDays[8][8] ={
|
||||
"Mon",
|
||||
"Tue",
|
||||
"Wed",
|
||||
|
@ -30,25 +25,27 @@ void Network::begin(char *city)
|
|||
{
|
||||
// Initiating wifi, like in BasicHttpClient example
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFiMulti.addAP(ssid, pass);
|
||||
WiFi.begin(ssid, pass);
|
||||
|
||||
Serial.print(F("Waiting for WiFi to connect..."));
|
||||
while ((WiFiMulti.run() != WL_CONNECTED))
|
||||
{
|
||||
// Printing a dot to Serial monitor every second while waiting to connect
|
||||
Serial.print(F("."));
|
||||
delay(1000);
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
WiFi.reconnect();
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println(F("Waiting for WiFi to reconnect..."));
|
||||
while ((WiFi.status() != WL_CONNECTED))
|
||||
{
|
||||
// Prints a dot every second that wifi isn't connected
|
||||
Serial.print(F("."));
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
Serial.println(F(" connected"));
|
||||
|
||||
// Find internet time
|
||||
setTime();
|
||||
|
||||
// Search for given cities woeid
|
||||
findCity(city);
|
||||
|
||||
// reduce power by making WiFi module sleep
|
||||
WiFi.setSleep(1);
|
||||
}
|
||||
|
||||
// Gets time from ntp server
|
||||
|
@ -87,11 +84,22 @@ void formatWind(char *str, float wind)
|
|||
dtostrf(wind, 2, 0, str);
|
||||
}
|
||||
|
||||
void Network::getData(char *city, char *temp1, char *temp2, char *temp3, char *temp4, char *currentTemp, char *currentWind, char *currentTime, char *currentWeather, char *currentWeatherAbbr)
|
||||
void Network::getData(char *city, char *temp1, char *temp2, char *temp3, char *temp4, char *currentTemp, char *currentWind, char *currentTime, char *currentWeather, char *currentWeatherAbbr, char* abbr1, char* abbr2, char* abbr3, char* abbr4)
|
||||
{
|
||||
// Return if wifi isn't connected
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
return;
|
||||
// Reconnect if wifi isn't connected
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
WiFi.reconnect();
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println(F("Waiting for WiFi to reconnect..."));
|
||||
while ((WiFi.status() != WL_CONNECTED))
|
||||
{
|
||||
// Prints a dot every second that wifi isn't connected
|
||||
Serial.print(F("."));
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
// Wake up if sleeping and save inital state
|
||||
bool sleep = WiFi.getSleep();
|
||||
|
@ -138,6 +146,11 @@ void Network::getData(char *city, char *temp1, char *temp2, char *temp3, char *t
|
|||
strcpy(currentWeather, doc["consolidated_weather"][0]["weather_state_name"].as<char *>());
|
||||
strcpy(currentWeatherAbbr, doc["consolidated_weather"][0]["weather_state_abbr"].as<char *>());
|
||||
|
||||
strcpy(abbr1, doc["consolidated_weather"][0]["weather_state_abbr"].as<char *>());
|
||||
strcpy(abbr2, doc["consolidated_weather"][1]["weather_state_abbr"].as<char *>());
|
||||
strcpy(abbr3, doc["consolidated_weather"][2]["weather_state_abbr"].as<char *>());
|
||||
strcpy(abbr4, doc["consolidated_weather"][3]["weather_state_abbr"].as<char *>());
|
||||
|
||||
formatTemp(temp1, doc["consolidated_weather"][0][F("the_temp")].as<float>());
|
||||
formatTemp(temp2, doc["consolidated_weather"][1][F("the_temp")].as<float>());
|
||||
formatTemp(temp3, doc["consolidated_weather"][2][F("the_temp")].as<float>());
|
||||
|
@ -201,9 +214,20 @@ void Network::getDays(char *day, char *day1, char *day2, char *day3)
|
|||
|
||||
void Network::findCity(char *city)
|
||||
{
|
||||
// If not connected to wifi, return
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
return;
|
||||
// If not connected to wifi reconnect wifi
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
WiFi.reconnect();
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println(F("Waiting for WiFi to reconnect..."));
|
||||
while ((WiFi.status() != WL_CONNECTED))
|
||||
{
|
||||
// Prints a dot every second that wifi isn't connected
|
||||
Serial.print(F("."));
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
// Wake wifi module and save initial state
|
||||
bool sleep = WiFi.getSleep();
|
|
@ -24,7 +24,7 @@ public:
|
|||
// Functions we can access in main file
|
||||
void begin(char *city);
|
||||
void getTime(char *timeStr);
|
||||
void getData(char *city, char *temp1, char *temp2, char *temp3, char *temp4, char *currentTemp, char *currentWind, char *currentTime, char *currentWeather, char *currentWeatherAbbr);
|
||||
void getData(char *city, char *temp1, char *temp2, char *temp3, char *temp4, char *currentTemp, char *currentWind, char *currentTime, char *currentWeather, char *currentWeatherAbbr, char* abbr1, char* abbr2, char* abbr3, char* abbr4);
|
||||
void getDays(char *day, char *day1, char *day2, char *day3);
|
||||
|
||||
// Used to store loaction woeid (world id), set in findCity()
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -15,16 +15,16 @@ if not os.path.isdir("./binary_icons"):
|
|||
|
||||
for file in os.listdir("./icons"):
|
||||
im = Image.open("./icons/" + file)
|
||||
im = im.resize((152, 152))
|
||||
im = im.resize((48, 48))
|
||||
alp = im.split()[-1]
|
||||
s = [0 for x in range(152 * 152)]
|
||||
for y in range(152):
|
||||
for x in range(152):
|
||||
s = [0 for x in range(48 * 48)]
|
||||
for y in range(48):
|
||||
for x in range(48):
|
||||
# print(im.getpixel((x, y)))
|
||||
if alp.getpixel((x, y)) > 128:
|
||||
s[(x + 152 * y) // 8] |= 1 << (7 - (x + 152 * y) % 8)
|
||||
s[(x + 48 * y) // 8] |= 1 << (7 - (x + 48 * y) % 8)
|
||||
|
||||
with open("./binary_icons/icon_" + file[:-4] + ".h", "w") as f:
|
||||
print("const uint8_t icon_" + file[:-4] + "[] PROGMEM = {", file=f)
|
||||
with open("./binary_icons/icon_s_" + file[:-4] + ".h", "w") as f:
|
||||
print("const uint8_t icon_s_" + file[:-4] + "[] PROGMEM = {", file=f)
|
||||
print(",".join(list(map(hex, s))), file=f)
|
||||
print("};", file=f)
|
|
@ -12,4 +12,15 @@
|
|||
#include "binary_icons/icon_sn.h"
|
||||
#include "binary_icons/icon_t.h"
|
||||
|
||||
#include "binary_icons/icon_s_c.h"
|
||||
#include "binary_icons/icon_s_h.h"
|
||||
#include "binary_icons/icon_s_hc.h"
|
||||
#include "binary_icons/icon_s_hr.h"
|
||||
#include "binary_icons/icon_s_lc.h"
|
||||
#include "binary_icons/icon_s_lr.h"
|
||||
#include "binary_icons/icon_s_s.h"
|
||||
#include "binary_icons/icon_s_sl.h"
|
||||
#include "binary_icons/icon_s_sn.h"
|
||||
#include "binary_icons/icon_s_t.h"
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue