Skip to content

Commit 8f5e387

Browse files
committed
Update checks to Inkplate 5v2 and 6
1 parent 17a91c9 commit 8f5e387

File tree

5 files changed

+65
-55
lines changed

5 files changed

+65
-55
lines changed

src/boards/Inkplate5V2/Inkplate5V2Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int EPDDriver::initDriver(Inkplate *_inkplatePtr)
103103
_inkplate = _inkplatePtr;
104104

105105
// Initialize the image processing functionalities
106-
beginImage(_inkplatePtr);
106+
image.begin(_inkplatePtr);
107107

108108
// Initialize the all GPIOs
109109
gpioInit();

src/boards/Inkplate5V2/Inkplate5V2Driver.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
class Inkplate;
3535

3636

37-
class EPDDriver : public Image, public Esp
37+
class EPDDriver : public Esp
3838
{
3939
public:
4040
void writePixelInternal(int16_t x, int16_t y, uint16_t color);
@@ -64,6 +64,8 @@ class EPDDriver : public Image, public Esp
6464

6565
RTC rtc;
6666

67+
Image image;
68+
6769
uint8_t _beginDone = 0;
6870
uint8_t _displayMode;
6971

src/boards/Inkplate6/Inkplate6Driver.cpp

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,18 @@ void EPDDriver::writePixelInternal(int16_t x, int16_t y, uint16_t color)
2727
if (x0 > E_INK_WIDTH - 1 || y0 > E_INK_HEIGHT - 1 || x0 < 0 || y0 < 0)
2828
return;
2929

30+
// set x, y depending on selected rotation
3031
switch (_inkplate->getRotation())
3132
{
32-
case 1:
33+
case 1: // 90 degree left
3334
_swap_int16_t(x0, y0);
3435
x0 = E_INK_HEIGHT - x0 - 1;
3536
break;
36-
case 2:
37+
case 2: // 180 degree, or upside down
3738
x0 = E_INK_WIDTH - x0 - 1;
3839
y0 = E_INK_HEIGHT - y0 - 1;
3940
break;
40-
case 3:
41+
case 3: // 90 degree right
4142
_swap_int16_t(x0, y0);
4243
y0 = E_INK_WIDTH - y0 - 1;
4344
break;
@@ -80,24 +81,18 @@ int EPDDriver::initDriver(Inkplate *_inkplatePtr)
8081
if (_beginDone == 1)
8182
return 0;
8283

84+
Wire.begin();
85+
8386
// Save the given inkplate pointer for internal use
8487
_inkplate = _inkplatePtr;
8588

8689
// Initialize the image processing functionalities
87-
beginImage(_inkplatePtr);
90+
image.begin(_inkplatePtr);
8891

8992
// Initialize the GPIOs
9093
gpioInit();
9194

9295

93-
if (!initializeFramebuffers())
94-
{
95-
return 0;
96-
}
97-
98-
// Calculate color LUTs to optimize drawing to the screen
99-
calculateLUTs();
100-
10196
// Use only myI2S
10297
myI2S = &I2S1;
10398

@@ -110,10 +105,36 @@ int EPDDriver::initDriver(Inkplate *_inkplatePtr)
110105
return 0;
111106
}
112107

113-
114108
// Init the I2S driver. It will setup a I2S driver.
115109
I2SInit(myI2S);
116110

111+
// CONTROL PINS
112+
pinMode(0, OUTPUT);
113+
pinMode(2, OUTPUT);
114+
pinMode(32, OUTPUT);
115+
pinMode(33, OUTPUT);
116+
internalIO.pinMode(OE, OUTPUT);
117+
internalIO.pinMode(GMOD, OUTPUT);
118+
internalIO.pinMode(SPV, OUTPUT);
119+
120+
internalIO.pinMode(10, OUTPUT);
121+
internalIO.pinMode(11, OUTPUT);
122+
internalIO.pinMode(12, OUTPUT);
123+
internalIO.digitalWrite(10, LOW);
124+
internalIO.digitalWrite(11, LOW);
125+
internalIO.digitalWrite(12, LOW);
126+
// Battery voltage Switch MOSFET
127+
internalIO.pinMode(9, OUTPUT);
128+
internalIO.digitalWrite(9, LOW);
129+
130+
131+
if (!initializeFramebuffers())
132+
{
133+
return 0;
134+
}
135+
136+
// Calculate color LUTs to optimize drawing to the screen
137+
calculateLUTs();
117138
_beginDone = 1;
118139
return 1;
119140
}
@@ -601,6 +622,7 @@ void EPDDriver::einkOff()
601622
VCOM_CLEAR;
602623
OE_CLEAR;
603624
GMOD_CLEAR;
625+
LE_CLEAR;
604626
CKV_CLEAR;
605627
SPH_CLEAR;
606628
SPV_CLEAR;
@@ -779,11 +801,7 @@ void EPDDriver::clean(uint8_t c, uint8_t rep)
779801
*/
780802
void EPDDriver::hscan_start(uint32_t _d)
781803
{
782-
SPH_CLEAR;
783-
GPIO.out_w1ts = (_d) | CL;
784-
GPIO.out_w1tc = DATA | CL;
785-
SPH_SET;
786-
CKV_SET;
804+
787805
}
788806

789807
uint8_t EPDDriver::getDisplayMode()
@@ -820,6 +838,9 @@ void EPDDriver::gpioInit()
820838
// Initialize I2C communication with the TPS chip
821839
pmicBegin();
822840

841+
// Set all pins of seconds I/O expander to outputs, low.
842+
// For some reason, it draw more current in deep sleep when pins are set as
843+
// inputs...
823844
for (int i = 0; i < 15; i++)
824845
{
825846
externalIO.pinMode(i, OUTPUT);
@@ -842,28 +863,9 @@ void EPDDriver::gpioInit()
842863
// And also disable uSD card supply
843864
internalIO.pinMode(SD_PMOS_PIN, INPUT);
844865

845-
// CONTROL PINS
846-
pinMode(0, OUTPUT);
847-
pinMode(2, OUTPUT);
848-
pinMode(32, OUTPUT);
849-
pinMode(33, OUTPUT);
850-
internalIO.pinMode(OE, OUTPUT);
851-
internalIO.pinMode(GMOD, OUTPUT);
852-
internalIO.pinMode(SPV, OUTPUT);
853866

854-
internalIO.pinMode(10, OUTPUT);
855-
internalIO.pinMode(11, OUTPUT);
856-
internalIO.pinMode(12, OUTPUT);
857-
internalIO.digitalWrite(10, LOW);
858-
internalIO.digitalWrite(11, LOW);
859-
internalIO.digitalWrite(12, LOW);
860-
// Battery voltage Switch MOSFET
861-
internalIO.pinMode(9, OUTPUT);
862-
internalIO.digitalWrite(9, LOW);
863867

864-
// Set all pins of seconds I/O expander to outputs, low.
865-
// For some reason, it draw more current in deep sleep when pins are set as
866-
// inputs...
868+
867869
}
868870

869871
/**

src/boards/Inkplate6/Inkplate6Driver.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
class Inkplate;
3535

3636

37-
class EPDDriver : public Image, public Esp
37+
class EPDDriver : public Esp
3838
{
3939
public:
4040
void writePixelInternal(int16_t x, int16_t y, uint16_t color);
@@ -65,6 +65,8 @@ class EPDDriver : public Image, public Esp
6565

6666
RTC rtc;
6767

68+
Image image;
69+
6870
uint8_t _beginDone = 0;
6971
uint8_t _displayMode;
7072

src/graphics/Image/Image.h

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#ifndef __IMAGE_H__
2020
#define __IMAGE_H__
21-
21+
#ifndef USE_COLOR_IMAGE
2222
#include "../../features/SdFat/SdFat.h"
2323
#include "WiFi.h"
2424

@@ -67,16 +67,16 @@ class Image
6767

6868
Inkplate *_inkplate = NULL;
6969

70-
void beginImage(Inkplate *inkplateptr);
70+
void begin(Inkplate *inkplateptr);
7171

72-
bool drawImage(const char *path, int x, int y, bool dither = 1, bool invert = 0);
73-
bool drawImage(const String path, int x, int y, bool dither = 1, bool invert = 0);
74-
bool drawImage(const uint8_t *buf, int x, int y, int16_t w, int16_t h, uint8_t c = 1, uint8_t bg = 0xFF);
75-
bool drawImage(const char *path, const Format &format, const int x, const int y, const bool dither = 1,
72+
bool draw(const char *path, int x, int y, bool dither = 1, bool invert = 0);
73+
bool draw(const String path, int x, int y, bool dither = 1, bool invert = 0);
74+
bool draw(const uint8_t *buf, int x, int y, int16_t w, int16_t h, uint8_t c = 1, uint8_t bg = 0xFF);
75+
bool draw(const char *path, const Format &format, const int x, const int y, const bool dither = 1,
7676
const bool invert = 0);
77-
bool drawImage(const String path, const Format &format, const int x, const int y, const bool dither = 1,
77+
bool draw(const String path, const Format &format, const int x, const int y, const bool dither = 1,
7878
const bool invert = 0);
79-
bool drawImage(const char *path, const Format &format, const Position &position, const bool dither = 1,
79+
bool draw(const char *path, const Format &format, const Position &position, const bool dither = 1,
8080
const bool invert = 0);
8181

8282
bool getFileExtension(char *_filename, char *_extension);
@@ -115,17 +115,20 @@ class Image
115115

116116

117117
private:
118-
uint8_t pixelBuffer[E_INK_WIDTH * 4 + 5];
119-
uint8_t ditherBuffer[2][E_INK_WIDTH + 20];
120-
uint8_t jpegDitherBuffer[18][18];
118+
119+
static uint8_t *pixelBuffer;
120+
static uint8_t (*jpegDitherBuffer)[18];
121+
static uint8_t (*ditherBuffer)[E_INK_WIDTH + 20];
122+
static uint32_t* ditherPalette; // 8 bit colors, in color, 3x8 bit colors
123+
static uint8_t* palette; // 2 3 bit colors per byte, _###_###
124+
125+
uint16_t _lastTileRowY = -1;
126+
121127
static bool drawJpegChunk(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap, bool dither, bool invert);
122128

123129
int16_t blockW = 0, blockH = 0;
124130
int16_t lastY = -1;
125131

126-
uint32_t ditherPalette[256]; // 8 bit colors, in color, 3x8 bit colors
127-
uint8_t palette[128]; // 2 3 bit colors per byte, _###_###
128-
129132
bool legalBmp(bitmapHeader *bmpHeader);
130133

131134
uint8_t ditherGetPixelJpeg(uint8_t px, int i, int j, int x, int y, int w, int h);
@@ -161,4 +164,5 @@ class Image
161164
// -------------------------------------------
162165
};
163166

167+
#endif
164168
#endif

0 commit comments

Comments
 (0)