Skip to content

Commit 384c552

Browse files
Laurence BankLaurence Bank
authored andcommitted
Improved generic gray matrix for EPDiy V7 PCB
1 parent 8e18060 commit 384c552

File tree

3 files changed

+47
-23
lines changed

3 files changed

+47
-23
lines changed

src/FastEPD.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ int FASTEPD::clearWhite(bool bKeepOn)
209209
if (bbepEinkPower(&_state, 1) != BBEP_SUCCESS) return BBEP_IO_ERROR;
210210
fillScreen(BBEP_WHITE);
211211
backupPlane(); // previous buffer set to the same color
212-
bbepClear(&_state, BB_CLEAR_DARKEN, 5, NULL);
213-
bbepClear(&_state, BB_CLEAR_LIGHTEN, 5, NULL);
212+
// 7 passes is enough to set all of the displays I've used to pure white or black
213+
bbepClear(&_state, BB_CLEAR_DARKEN, 7, NULL);
214+
bbepClear(&_state, BB_CLEAR_LIGHTEN, 7, NULL);
214215
bbepClear(&_state, BB_CLEAR_NEUTRAL, 1, NULL);
215216
if (!bKeepOn) bbepEinkPower(&_state, 0);
216217
return BBEP_SUCCESS;
@@ -221,8 +222,9 @@ int FASTEPD::clearBlack(bool bKeepOn)
221222
if (bbepEinkPower(&_state, 1) != BBEP_SUCCESS) return BBEP_IO_ERROR;
222223
fillScreen(BBEP_BLACK);
223224
backupPlane(); // previous buffer set to the same color
224-
bbepClear(&_state, BB_CLEAR_LIGHTEN, 5, NULL);
225-
bbepClear(&_state, BB_CLEAR_DARKEN, 5, NULL);
225+
// 7 passes is enough to set all of the displays I've used to pure white or black
226+
bbepClear(&_state, BB_CLEAR_LIGHTEN, 7, NULL);
227+
bbepClear(&_state, BB_CLEAR_DARKEN, 7, NULL);
226228
bbepClear(&_state, BB_CLEAR_NEUTRAL, 1, NULL);
227229
if (!bKeepOn) bbepEinkPower(&_state, 0);
228230
return BBEP_SUCCESS;

src/FastEPD.inl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ const uint8_t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 2, 2, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0,
60+
/* 8 */ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 0,
61+
/* 9 */ 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 1, 2, 0, 0, 0, 0,
62+
/* 10 */ 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 0, 1, 0, 0, 0, 0, 0,
63+
/* 11 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 0, 0, 0, 0, 0,
64+
/* 12 */ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
65+
/* 13 */ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 0,
66+
/* 14 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 0, 0, 0, 0,
67+
/* 15 */ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0
6868
};
6969

7070
const uint8_t u8M5Matrix[] = {
@@ -124,7 +124,7 @@ const BBPANELDEF panelDefs[] = {
124124
{800, 600, 13333333, BB_PANEL_FLAG_SLOW_SPH, {4,5,18,19,23,25,26,27}, 8, 4, 2, 32, 33, 0, 2,
125125
0, 7, 21, 22, 3, 5, 15, u8GrayMatrix, sizeof(u8GrayMatrix), 16}, // BB_PANEL_INKPLATE6
126126
{0, 0, 20000000, BB_PANEL_FLAG_NONE, {5,6,7,15,16,17,18,8}, 8, 11, 45, 48, 41, 9, 42,
127-
4, 14, 39, 40, BB_NOT_USED, 0, 0, u8SixInchMatrix, sizeof(u8SixInchMatrix), 0}, // BB_PANEL_V7_RAW
127+
4, 14, 39, 40, BB_NOT_USED, 0, 0, u8M5Matrix, sizeof(u8M5Matrix), 0}, // BB_PANEL_V7_RAW
128128
};
129129
//
130130
// Forward references for panel callback functions

src/arduino_io.inl

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
#ifndef __BB_EP_IO__
2222
#define __BB_EP_IO__
2323

24+
#ifndef ARDUINO
2425
#include "driver/gpio.h"
2526
#include "driver/i2c.h"
2627
#include "esp_timer.h"
2728

2829
// GPIO modes
29-
#ifndef ARDUINO
3030
#define memcpy_P memcpy
3131
#define pgm_read_byte(a) (*(uint8_t *)a)
3232
#define pgm_read_word(a) (*(uint16_t *)a)
@@ -74,7 +74,7 @@ void delay(uint32_t ms)
7474
}
7575
delayMicroseconds((ms % 10) * 1000);
7676
}
77-
#endif
77+
#endif // !ARDUINO
7878

7979
void bbepPinMode(int iPin, int iMode)
8080
{
@@ -100,6 +100,12 @@ void bbepPinMode(int iPin, int iMode)
100100
//
101101
int bbepI2CInit(uint8_t sda, uint8_t scl)
102102
{
103+
#ifdef ARDUINO
104+
Wire.end();
105+
Wire.begin(sda, scl);
106+
Wire.setClock(400000);
107+
Wire.setTimeout(100);
108+
#else
103109
i2c_config_t conf;
104110
conf.mode = I2C_MODE_MASTER;
105111
conf.sda_io_num = sda;
@@ -110,11 +116,19 @@ int bbepI2CInit(uint8_t sda, uint8_t scl)
110116
conf.clk_flags = 0;
111117
ESP_ERROR_CHECK(i2c_param_config(I2C_NUM_0, &conf));
112118
ESP_ERROR_CHECK(i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0));
119+
#endif
113120
return BBEP_SUCCESS;
114121
} /* bbepI2CInit() */
115122

116123
int bbepI2CWrite(unsigned char iAddr, unsigned char *pData, int iLen)
117124
{
125+
#ifdef ARDUINO
126+
int rc = 0;
127+
Wire.beginTransmission(iAddr);
128+
Wire.write(pData, (unsigned char)iLen);
129+
rc = !Wire.endTransmission();
130+
return rc;
131+
#else
118132
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
119133
if (cmd == NULL) {
120134
// ESP_LOGE("bb_epdiy", "insufficient memory for I2C transaction");
@@ -126,12 +140,19 @@ int bbepI2CWrite(unsigned char iAddr, unsigned char *pData, int iLen)
126140
esp_err_t ret = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_PERIOD_MS);
127141
i2c_cmd_link_delete(cmd);
128142
return (ret == ESP_OK);
143+
#endif
129144
}
130145

131146
int bbepI2CRead(unsigned char iAddr, unsigned char *pData, int iLen)
132147
{
133148
int i = 0;
134149

150+
#ifdef ARDUINO
151+
Wire.requestFrom(iAddr, (unsigned char)iLen);
152+
while (i < iLen && Wire.available()) {
153+
pData[i++] = Wire.read();
154+
}
155+
#else
135156
esp_err_t ret;
136157
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
137158
if (cmd == NULL) {
@@ -150,6 +171,7 @@ int i = 0;
150171
i = iLen;
151172
}
152173
i2c_cmd_link_delete(cmd);
174+
#endif
153175
return i;
154176
}
155177
int bbepI2CReadRegister(unsigned char iAddr, unsigned char u8Register, unsigned char *pData, int iLen)

0 commit comments

Comments
 (0)