Skip to content

Commit c71dc30

Browse files
committed
Fixed warnings and minor speed improvement for partial update
1 parent b405d7e commit c71dc30

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

src/FastEPD.inl

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#ifndef __BB_EP__
2626
#define __BB_EP__
27+
#pragma GCC optimize("O2")
2728

2829
// For measuring the performance of each stage of updates
2930
//#define SHOW_TIME
@@ -173,7 +174,7 @@ int bbepSetCustomMatrix(FASTEPDSTATE *pState, const uint8_t *pMatrix, size_t mat
173174
// width, height, bus_speed, flags, data[8], bus_width, ioPWR, ioSPV, ioCKV, ioSPH, ioOE, ioLE,
174175
// ioCL, ioPWR_Good, ioSDA, ioSCL, ioShiftSTR/Wakeup, ioShiftMask/vcom, ioDCDummy, graymatrix, sizeof(graymatrix), iLinePadding
175176
const BBPANELDEF panelDefs[] = {
176-
{0}, // BB_PANEL_NONE
177+
{0,0,0,0,{0},0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0}, // BB_PANEL_NONE
177178
{960, 540, 20000000, BB_PANEL_FLAG_NONE, {6,14,7,12,9,11,8,10}, 8, 46, 17, 18, 13, 45, 15,
178179
16, BB_NOT_USED, BB_NOT_USED, BB_NOT_USED, BB_NOT_USED, BB_NOT_USED, 47, u8M5Matrix, sizeof(u8M5Matrix), 0}, // BB_PANEL_M5PAPERS3
179180

@@ -189,7 +190,7 @@ const BBPANELDEF panelDefs[] = {
189190
{0, 0, 20000000, BB_PANEL_FLAG_NONE, {9,10,11,12,13,14,21,47,5,6,7,15,16,17,18,8}, 16, 11, 45, 48, 41, 8, 42,
190191
4, 14, 39, 40, BB_NOT_USED, 0, 46, u8GrayMatrix, sizeof(u8GrayMatrix), 16}, // BB_PANEL_EPDIY_V7_16
191192

192-
{0, 0, 20000000, BB_PANEL_FLAG_NONE, {5,6,7,15,16,17,18,8}, 8, 11, 45, 48, 41, 9, 42,
193+
{0, 0, 26666666, BB_PANEL_FLAG_NONE, {5,6,7,15,16,17,18,8}, 8, 11, 45, 48, 41, 9, 42,
193194
4, 14, 39, 40, BB_NOT_USED, 0, 0, u8M5Matrix, sizeof(u8M5Matrix), 0}, // BB_PANEL_V7_RAW
194195
// D8 15 D0 D7 STV,CKV,XSTL,OE,XLE
195196
{1872, 1404, 20000000, BB_PANEL_FLAG_MIRROR_X, {8,18,17,16,15,7,6,5,47,21,14,13,12,11,10,9}, 16, 11, 41, 42, 45, 8, 48,
@@ -232,7 +233,7 @@ uint8_t Inkplate5V2ExtIO(uint8_t iOp, uint8_t iPin, uint8_t iVal);
232233
// List of predefined callback functions for the panels supported by bb_epdiy
233234
// BB_EINK_POWER, BB_IO_INIT, BB_ROW_CONTROL
234235
const BBPANELPROCS panelProcs[] = {
235-
{0}, // BB_PANEL_NONE
236+
{NULL,NULL,NULL,NULL,NULL}, // BB_PANEL_NONE
236237
{PaperS3EinkPower, PaperS3IOInit, PaperS3RowControl, NULL, NULL}, // BB_PANEL_M5PAPERS3
237238
{EPDiyV7EinkPower, EPDiyV7IOInit, EPDiyV7RowControl, EPDiyV7IODeInit, EPDiyV7ExtIO}, // BB_PANEL_EPDIY_V7
238239
{Inkplate6PlusEinkPower, Inkplate6PlusIOInit, Inkplate6PlusRowControl, NULL, NULL}, // BB_PANEL_INKPLATE6PLUS
@@ -247,6 +248,7 @@ const BBPANELPROCS panelProcs[] = {
247248
uint8_t ioRegs[24]; // MCP23017 copy of I/O register state so that we can just write new bits
248249
static uint16_t LUTW_16[256];
249250
static uint16_t LUTB_16[256];
251+
static uint16_t LUTBW_16[256];
250252
// Lookup tables for grayscale mode
251253
static uint32_t *pGrayLower = NULL, *pGrayUpper = NULL;
252254
volatile bool dma_is_done = true;
@@ -272,8 +274,8 @@ static esp_lcd_i80_bus_config_t s3_bus_config = {
272274
.data_gpio_nums = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
273275
.bus_width = 0,
274276
.max_transfer_bytes = MAX_TX_SIZE,
275-
// .psram_trans_align = 0, // 0 = use default values
276-
// .sram_trans_align = 0,
277+
.psram_trans_align = 0, // 0 = use default values
278+
.sram_trans_align = 0,
277279
};
278280
static esp_lcd_panel_io_i80_config_t s3_io_config = {
279281
.cs_gpio_num = 0,
@@ -779,9 +781,9 @@ uint8_t u8Value = 0; // I/O bits for the PCA9535
779781
} else { // power off
780782
gpio_set_level((gpio_num_t)pState->panelDef.ioOE, 0); // OE off
781783
gpio_set_level((gpio_num_t)10, 0); // EP_MODE/GMOD off
782-
gpio_set_level((gpio_num_t)14, 1); // WAKEUP on
783-
gpio_set_level((gpio_num_t)11, 1); // PWRUP on
784-
gpio_set_level((gpio_num_t)12, 1); // VCOM CTRL on
784+
gpio_set_level((gpio_num_t)12, 0); // VCOM CTRL off
785+
gpio_set_level((gpio_num_t)11, 0); // PWRUP off
786+
gpio_set_level((gpio_num_t)14, 0); // WAKEUP off
785787
vTaskDelay(1); // only leave WAKEUP on
786788
gpio_set_level((gpio_num_t)14, 0);// now turn everything off
787789
pState->pwr_on = 0;
@@ -1325,28 +1327,34 @@ int bbepSetPanelSize(FASTEPDSTATE *pState, int width, int height, int flags, int
13251327
} // for j
13261328
// Create the lookup tables for 1-bit mode. Allow for inverted and mirrored
13271329
for (int i=0; i<256; i++) {
1328-
uint16_t b, w, u16W, u16B;
1329-
u16W = u16B = 0;
1330+
uint16_t b, w, bw, u16W, u16B, u16BW;
1331+
u16W = u16B = u16BW = 0;
13301332
for (int j=0; j<8; j++) {
13311333
// a 1 means do nothing and 0 means move towards black or white (depending on the LUT)
13321334
if (pState->iFlags & BB_PANEL_FLAG_MIRROR_X) {
13331335
if (!(i & (1<<(7-j)))) {
13341336
w = 2; b = 1;
1337+
bw = 1;
13351338
} else {
13361339
w = 3; b = 3;
1340+
bw = 2;
13371341
}
13381342
} else {
13391343
if (!(i & (0x80>>(7-j)))) {
13401344
w = 2; b = 1;
1345+
bw = 1;
13411346
} else {
13421347
w = 3; b = 3;
1348+
bw = 2;
13431349
}
13441350
}
13451351
u16W |= (w << (j * 2));
13461352
u16B |= (b << (j * 2));
1353+
u16BW |= (bw << (j * 2));
13471354
} // for j
13481355
LUTW_16[i] = __builtin_bswap16(u16W);
13491356
LUTB_16[i] = __builtin_bswap16(u16B);
1357+
LUTBW_16[i] = __builtin_bswap16(u16BW);
13501358
} // for i
13511359
return BBEP_SUCCESS;
13521360
} /* setPanelSize() */
@@ -1903,25 +1911,29 @@ int bbepPartialUpdate(FASTEPDSTATE *pState, bool bKeepOn, int iStartLine, int iE
19031911
pCur += (pState->native_width / 8) - 1;
19041912
pPrev += (pState->native_width / 8) - 1;
19051913
for (n = 0; n < pState->native_width / 16; n++) {
1906-
cur = *pCur--; prev = *pPrev--;
1914+
cur = *pCur--; prev = *pPrev;
1915+
*pPrev-- = cur; // new->old
19071916
diffw = prev & ~cur;
19081917
diffb = ~prev & cur;
19091918
*(uint16_t *)&d[0] = LUTW_16[diffw] & LUTB_16[diffb];
19101919

1911-
cur = *pCur--; prev = *pPrev--;
1920+
cur = *pCur--; prev = *pPrev;
1921+
*pPrev-- = cur; // new->old
19121922
diffw = prev & ~cur;
19131923
diffb = ~prev & cur;
19141924
*(uint16_t *)&d[2] = LUTW_16[diffw] & LUTB_16[diffb];
19151925
d += 4;
19161926
}
19171927
} else {
19181928
for (n = 0; n < pState->native_width / 16; n++) {
1919-
cur = *pCur++; prev = *pPrev++;
1929+
cur = *pCur++; prev = *pPrev;
1930+
*pPrev++ = cur; // new->old
19201931
diffw = prev & ~cur;
19211932
diffb = ~prev & cur;
19221933
*(uint16_t *)&d[0] = LUTW_16[diffw] & LUTB_16[diffb];
19231934

1924-
cur = *pCur++; prev = *pPrev++;
1935+
cur = *pCur++; prev = *pPrev;
1936+
*pPrev++ = cur; // new->old
19251937
diffw = prev & ~cur;
19261938
diffb = ~prev & cur;
19271939
*(uint16_t *)&d[2] = LUTW_16[diffw] & LUTB_16[diffb];
@@ -1967,16 +1979,13 @@ int bbepPartialUpdate(FASTEPDSTATE *pState, bool bKeepOn, int iStartLine, int iE
19671979
dp += iDelta;
19681980
iDMAOff ^= (pState->native_width/4);
19691981
}
1970-
// delayMicroseconds(230);
19711982
} // for each pass
19721983

19731984
// This clear to neutral step is necessary; do not remove
19741985
bbepClear(pState, BB_CLEAR_NEUTRAL, 1, NULL);
19751986
if (!bKeepOn) {
19761987
bbepEinkPower(pState, 0);
19771988
}
1978-
int offset = iStartLine * (pState->native_width/8);
1979-
memcpy(&pState->pPrevious[offset], &pState->pCurrent[offset], (pState->native_width/8) * (iEndLine - iStartLine+1));
19801989

19811990
#ifdef SHOW_TIME
19821991
l = millis() - l;

src/arduino_io.inl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#ifdef BIT_BANG
2828
static uint8_t u8SDA_Pin, u8SCL_Pin;
29-
static int iDelay = 1;
29+
static int iDelay = 0; //1;
3030
#endif
3131
#include <freertos/FreeRTOS.h>
3232
#include <freertos/task.h>
@@ -277,6 +277,7 @@ int bbepI2CInit(uint8_t sda, uint8_t scl)
277277
Wire.setTimeout(100);
278278
#else
279279
i2c_config_t conf;
280+
ESP_ERROR_CHECK(i2c_driver_delete());
280281
conf.mode = I2C_MODE_MASTER;
281282
conf.sda_io_num = sda;
282283
conf.scl_io_num = scl;

src/bb_ep_gfx.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,8 @@ int bbepWriteStringCustom(FASTEPDSTATE *pBBEP, const void *pFont, int x, int y,
889889
int width, height, angle;
890890
BB_FONT *pBBF;
891891
BB_FONT_SMALL *pBBFS;
892-
BB_GLYPH *pGlyph;
893-
BB_GLYPH_SMALL *pGlyphSmall;
892+
BB_GLYPH *pGlyph = NULL;
893+
BB_GLYPH_SMALL *pGlyphSmall = NULL;
894894
uint8_t *pBits, u8EndMask;
895895
uint8_t szExtMsg[256]; // translated extended ASCII message text
896896
uint8_t c, first, last;

0 commit comments

Comments
 (0)