Many fixes.
This commit is contained in:
parent
f012be658b
commit
d5826251bf
2014
Inkplate.cpp
2014
Inkplate.cpp
File diff suppressed because it is too large
Load Diff
16
Inkplate.h
16
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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -55,11 +55,11 @@ 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 };
|
||||
|
||||
// Variables for storing temperature
|
||||
char temps[8][4] = {
|
||||
char temps[8][4] ={
|
||||
"0F",
|
||||
"0F",
|
||||
"0F",
|
||||
|
@ -67,7 +67,7 @@ char temps[8][4] = {
|
|||
};
|
||||
|
||||
// Variables for storing days of the week
|
||||
char days[8][4] = {
|
||||
char days[8][4] ={
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
|
@ -153,6 +153,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();
|
||||
|
|
|
@ -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
|
||||
|
@ -89,9 +86,20 @@ void formatWind(char *str, float wind)
|
|||
|
||||
void Network::getData(char *city, char *temp1, char *temp2, char *temp3, char *temp4, char *currentTemp, char *currentWind, char *currentTime, char *currentWeather, char *currentWeatherAbbr)
|
||||
{
|
||||
// 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();
|
||||
|
@ -201,9 +209,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();
|
||||
|
|
|
@ -63,8 +63,8 @@ Inkplate display(INKPLATE_1BIT);
|
|||
Network network;
|
||||
|
||||
//Contants used for drawing icons
|
||||
char abbrs[32][32] = {"01d", "02d", "03d", "04d", "09d", "10d", "11d", "13d", "50d", "01n", "02n", "03n", "04n", "09n", "10n", "11n", "13n", "50n"};
|
||||
const uint8_t *logos[18] = {
|
||||
char abbrs[32][32] ={ "01d", "02d", "03d", "04d", "09d", "10d", "11d", "13d", "50d", "01n", "02n", "03n", "04n", "09n", "10n", "11n", "13n", "50n" };
|
||||
const uint8_t *logos[18] ={
|
||||
icon_01d,
|
||||
icon_02d,
|
||||
icon_03d,
|
||||
|
@ -85,7 +85,7 @@ const uint8_t *logos[18] = {
|
|||
icon_50n,
|
||||
};
|
||||
|
||||
const uint8_t *s_logos[18] = {
|
||||
const uint8_t *s_logos[18] ={
|
||||
icon_s_01d,
|
||||
icon_s_02d,
|
||||
icon_s_03d,
|
||||
|
@ -107,7 +107,7 @@ const uint8_t *s_logos[18] = {
|
|||
};
|
||||
|
||||
//Variables for storing temperature
|
||||
char temps[8][4] = {
|
||||
char temps[8][4] ={
|
||||
"0F",
|
||||
"0F",
|
||||
"0F",
|
||||
|
@ -115,7 +115,7 @@ char temps[8][4] = {
|
|||
};
|
||||
|
||||
//Variables for storing hour strings
|
||||
char hours[8][4] = {
|
||||
char hours[8][4] ={
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
|
|
|
@ -3,15 +3,11 @@
|
|||
#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<32000> doc;
|
||||
|
||||
|
@ -19,10 +15,10 @@ 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))
|
||||
while ((WiFi.status() != WL_CONNECTED))
|
||||
{
|
||||
//Printing a dot to Serial monitor every second while waiting to connect
|
||||
Serial.print(F("."));
|
||||
|
@ -76,10 +72,20 @@ void formatWind(char *str, float wind)
|
|||
bool 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)
|
||||
{
|
||||
bool f = 0;
|
||||
// If not connected to wifi reconnect wifi
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
WiFi.reconnect();
|
||||
|
||||
//Return if wifi isn't connected
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
return 0;
|
||||
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();
|
||||
|
|
|
@ -92,7 +92,7 @@ char minimum[16];
|
|||
char maximum[16];
|
||||
|
||||
//All months in a year, for finding current date
|
||||
char *months[] = {
|
||||
char *months[] ={
|
||||
"Jan"
|
||||
"Feb",
|
||||
"Mar",
|
||||
|
@ -108,27 +108,27 @@ char *months[] = {
|
|||
};
|
||||
|
||||
//Out UI elements data
|
||||
textElement elements[] = {
|
||||
{50, 130, &Roboto_Light_160, currencyAbbr, 0},
|
||||
{390, 80, &Roboto_Light_40, date, 0},
|
||||
{190, 185, &Roboto_Light_40, fromToDate, 0},
|
||||
{570, 140, &Roboto_Light_40, "Current price:", 0},
|
||||
{790, 190, &Roboto_Light_40, current, 1},
|
||||
{630, 275, &Roboto_Light_40, "Minimum:", 0},
|
||||
{790, 320, &Roboto_Light_40, minimum, 1},
|
||||
{625, 420, &Roboto_Light_40, "Maximum:", 0},
|
||||
{790, 466, &Roboto_Light_40, maximum, 1},
|
||||
textElement elements[] ={
|
||||
{ 50, 130, &Roboto_Light_160, currencyAbbr, 0 },
|
||||
{ 390, 80, &Roboto_Light_40, date, 0 },
|
||||
{ 190, 185, &Roboto_Light_40, fromToDate, 0 },
|
||||
{ 570, 140, &Roboto_Light_40, "Current price:", 0 },
|
||||
{ 790, 190, &Roboto_Light_40, current, 1 },
|
||||
{ 630, 275, &Roboto_Light_40, "Minimum:", 0 },
|
||||
{ 790, 320, &Roboto_Light_40, minimum, 1 },
|
||||
{ 625, 420, &Roboto_Light_40, "Maximum:", 0 },
|
||||
{ 790, 466, &Roboto_Light_40, maximum, 1 },
|
||||
|
||||
{18, 570, &Roboto_Light_36, dates, 0},
|
||||
{122, 570, &Roboto_Light_36, dates + 8, 0},
|
||||
{227, 570, &Roboto_Light_36, dates + 16, 0},
|
||||
{342, 570, &Roboto_Light_36, dates + 24, 0},
|
||||
{466, 570, &Roboto_Light_36, dates + 32, 0},
|
||||
{ 18, 570, &Roboto_Light_36, dates, 0 },
|
||||
{ 122, 570, &Roboto_Light_36, dates + 8, 0 },
|
||||
{ 227, 570, &Roboto_Light_36, dates + 16, 0 },
|
||||
{ 342, 570, &Roboto_Light_36, dates + 24, 0 },
|
||||
{ 466, 570, &Roboto_Light_36, dates + 32, 0 },
|
||||
|
||||
{450, 240, &Roboto_Light_36, prices, 0},
|
||||
{450, 322, &Roboto_Light_36, prices + 16, 0},
|
||||
{450, 401, &Roboto_Light_36, prices + 32, 0},
|
||||
{450, 483, &Roboto_Light_36, prices + 48, 0},
|
||||
{ 450, 240, &Roboto_Light_36, prices, 0 },
|
||||
{ 450, 322, &Roboto_Light_36, prices + 16, 0 },
|
||||
{ 450, 401, &Roboto_Light_36, prices + 32, 0 },
|
||||
{ 450, 483, &Roboto_Light_36, prices + 48, 0 },
|
||||
};
|
||||
|
||||
// Our functions declared below setup and loop
|
||||
|
@ -270,9 +270,9 @@ void drawGraph()
|
|||
//Draw a gradient line from every pixel to bottom line in graph line
|
||||
for (int j = 0; j < (x2 - x1 - textMargin) / 31 + 1; ++j)
|
||||
display.drawGradientLine(prev_x + j,
|
||||
(int)round((double)prev_y + dy * (double)j),
|
||||
prev_x + j,
|
||||
y1, 3, 7);
|
||||
(int)round((double)prev_y + dy * (double)j),
|
||||
prev_x + j,
|
||||
y1, 3, 7);
|
||||
}
|
||||
|
||||
//Set previous x and y
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "Network.h"
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <WiFiMulti.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
|
||||
|
@ -18,9 +17,6 @@ extern char *currency;
|
|||
//Get our Inkplate object from main file to draw debug info on
|
||||
extern Inkplate display;
|
||||
|
||||
//WiFiMulti object declaration
|
||||
WiFiMulti WiFiMulti;
|
||||
|
||||
//Static Json from ArduinoJson library
|
||||
StaticJsonDocument<30000> doc;
|
||||
|
||||
|
@ -28,10 +24,10 @@ void Network::begin()
|
|||
{
|
||||
//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))
|
||||
while ((WiFi.status() != WL_CONNECTED))
|
||||
{
|
||||
Serial.print(F("."));
|
||||
delay(1000);
|
||||
|
@ -70,9 +66,20 @@ bool Network::getData(double *data)
|
|||
{
|
||||
bool f = 0;
|
||||
|
||||
//Return if wifi isn't connected
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
return 0;
|
||||
// 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 up if sleeping and save inital state
|
||||
bool sleep = WiFi.getSleep();
|
||||
|
|
|
@ -111,8 +111,6 @@ void setup()
|
|||
|
||||
delay(5000);
|
||||
network.begin();
|
||||
//Our begin function
|
||||
network.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
@ -238,7 +236,7 @@ void drawGrid()
|
|||
void getToFrom(char *dst, char *from, char *to, int *day, int *timeStamp)
|
||||
{
|
||||
//ANSI C time struct
|
||||
struct tm ltm = {0}, ltm2 = {0};
|
||||
struct tm ltm ={ 0 }, ltm2 ={ 0 };
|
||||
char temp[128], temp2[128];
|
||||
strncpy(temp, from, 16);
|
||||
temp[16] = 0;
|
||||
|
@ -369,7 +367,7 @@ bool drawEvent(entry *event, int day, int beginY, int maxHeigth, int *heigthNeed
|
|||
|
||||
display.setCursor(x1 + 5, display.getCursorY());
|
||||
|
||||
char line[128] = {0};
|
||||
char line[128] ={ 0 };
|
||||
|
||||
for (int i = 0; i < strlen(event->location); ++i)
|
||||
{
|
||||
|
@ -465,14 +463,14 @@ void drawData()
|
|||
|
||||
//Sort entries by time
|
||||
qsort(entries,
|
||||
entriesNum,
|
||||
sizeof(entry),
|
||||
cmp);
|
||||
entriesNum,
|
||||
sizeof(entry),
|
||||
cmp);
|
||||
|
||||
//Events displayed and overflown counters
|
||||
int columns[3] = {0};
|
||||
bool clogged[3] = {0};
|
||||
int cloggedCount[3] = {0};
|
||||
int columns[3] ={ 0 };
|
||||
bool clogged[3] ={ 0 };
|
||||
int cloggedCount[3] ={ 0 };
|
||||
|
||||
//Displaying events one by one
|
||||
for (int i = 0; i < entriesNum; ++i)
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
#include "Network.h"
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <WiFiMulti.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
|
||||
// WiFiMulti object declaration
|
||||
WiFiMulti WiFiMulti;
|
||||
|
||||
void Network::begin()
|
||||
{
|
||||
// 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))
|
||||
while ((WiFi.status() != WL_CONNECTED))
|
||||
{
|
||||
// Prints a dot every second that wifi isn't connected
|
||||
Serial.print(F("."));
|
||||
|
@ -46,14 +43,20 @@ bool Network::getData(char *data)
|
|||
{
|
||||
// Variable to store fail
|
||||
bool f = 0;
|
||||
// If not connected to wifi reconnect wifi
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
WiFi.reconnect();
|
||||
|
||||
// Return if wifi isn't connected
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
return 0;
|
||||
delay(5000);
|
||||
|
||||
// Wake up if sleeping and save inital state
|
||||
bool sleep = WiFi.getSleep();
|
||||
WiFi.setSleep(false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Http object used to make get request
|
||||
HTTPClient http;
|
||||
|
@ -68,23 +71,23 @@ bool Network::getData(char *data)
|
|||
|
||||
// Actually do request
|
||||
int httpCode = http.GET();
|
||||
|
||||
if (httpCode == 200)
|
||||
{
|
||||
long n = 0;
|
||||
while (http.getStream().available())
|
||||
data[n++] = http.getStream().read();
|
||||
data[n++]= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(httpCode);
|
||||
f = 1;
|
||||
}
|
||||
|
||||
// end http
|
||||
http.end();
|
||||
|
||||
// Return to initial state
|
||||
WiFi.setSleep(sleep);
|
||||
|
||||
return !f;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue