mirror of
https://github.com/tsl0922/EPD-nRF5.git
synced 2025-12-17 17:28:13 +08:00
inverse red ram with register
This commit is contained in:
@@ -319,14 +319,12 @@ extern epd_model_t epd_uc8176_420_bw;
|
|||||||
extern epd_model_t epd_uc8176_420_bwr;
|
extern epd_model_t epd_uc8176_420_bwr;
|
||||||
extern epd_model_t epd_ssd1619_420_bwr;
|
extern epd_model_t epd_ssd1619_420_bwr;
|
||||||
extern epd_model_t epd_ssd1619_420_bw;
|
extern epd_model_t epd_ssd1619_420_bw;
|
||||||
extern epd_model_t epd_uc8276_420_bwr;
|
|
||||||
|
|
||||||
static epd_model_t *epd_models[] = {
|
static epd_model_t *epd_models[] = {
|
||||||
&epd_uc8176_420_bw,
|
&epd_uc8176_420_bw,
|
||||||
&epd_uc8176_420_bwr,
|
&epd_uc8176_420_bwr,
|
||||||
&epd_ssd1619_420_bwr,
|
&epd_ssd1619_420_bwr,
|
||||||
&epd_ssd1619_420_bw,
|
&epd_ssd1619_420_bw,
|
||||||
&epd_uc8276_420_bwr,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// EPD model
|
// EPD model
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ typedef enum
|
|||||||
EPD_UC8176_420_BWR = 3,
|
EPD_UC8176_420_BWR = 3,
|
||||||
EPD_SSD1619_420_BWR = 2,
|
EPD_SSD1619_420_BWR = 2,
|
||||||
EPD_SSD1619_420_BW = 4,
|
EPD_SSD1619_420_BW = 4,
|
||||||
EPD_UC8276_420_BWR = 5,
|
|
||||||
} epd_model_id_t;
|
} epd_model_id_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -55,7 +54,6 @@ typedef struct
|
|||||||
uint16_t width;
|
uint16_t width;
|
||||||
uint16_t height;
|
uint16_t height;
|
||||||
bool bwr;
|
bool bwr;
|
||||||
bool invert_color;
|
|
||||||
} epd_model_t;
|
} epd_model_t;
|
||||||
|
|
||||||
#define LOW (0x0)
|
#define LOW (0x0)
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ static void SSD1619_Refresh(void)
|
|||||||
{
|
{
|
||||||
epd_model_t *EPD = epd_get();
|
epd_model_t *EPD = epd_get();
|
||||||
|
|
||||||
|
EPD_WriteCommand(CMD_DISP_CTRL1);
|
||||||
|
EPD_WriteByte(0x80); // Inverse RED RAM
|
||||||
|
EPD_WriteByte(0x00); // Single chip application
|
||||||
|
|
||||||
NRF_LOG_DEBUG("[EPD]: refresh begin\n");
|
NRF_LOG_DEBUG("[EPD]: refresh begin\n");
|
||||||
NRF_LOG_DEBUG("[EPD]: temperature: %d\n", SSD1619_Read_Temp());
|
NRF_LOG_DEBUG("[EPD]: temperature: %d\n", SSD1619_Read_Temp());
|
||||||
SSD1619_Update(0xF7);
|
SSD1619_Update(0xF7);
|
||||||
@@ -130,7 +134,7 @@ void SSD1619_Clear(void)
|
|||||||
EPD_WriteCommand(CMD_WRITE_RAM2);
|
EPD_WriteCommand(CMD_WRITE_RAM2);
|
||||||
for (uint16_t j = 0; j < Height; j++) {
|
for (uint16_t j = 0; j < Height; j++) {
|
||||||
for (uint16_t i = 0; i < Width; i++) {
|
for (uint16_t i = 0; i < Width; i++) {
|
||||||
EPD_WriteByte(EPD->invert_color ? 0x00 : 0xFF);
|
EPD_WriteByte(0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,8 +160,7 @@ void SSD1619_Write_Image(uint8_t *black, uint8_t *color, uint16_t x, uint16_t y,
|
|||||||
for (uint16_t i = 0; i < h; i++) {
|
for (uint16_t i = 0; i < h; i++) {
|
||||||
for (uint16_t j = 0; j < w / 8; j++) {
|
for (uint16_t j = 0; j < w / 8; j++) {
|
||||||
if (EPD->bwr) {
|
if (EPD->bwr) {
|
||||||
uint8_t data = color ? color[j + i * wb] : 0xFF;
|
EPD_WriteByte(color ? color[j + i * wb] : 0xFF);
|
||||||
EPD_WriteByte(EPD->invert_color ? ~data : data);
|
|
||||||
} else {
|
} else {
|
||||||
EPD_WriteByte(black[j + i * wb]);
|
EPD_WriteByte(black[j + i * wb]);
|
||||||
}
|
}
|
||||||
@@ -189,7 +192,6 @@ const epd_model_t epd_ssd1619_420_bwr = {
|
|||||||
.width = 400,
|
.width = 400,
|
||||||
.height = 300,
|
.height = 300,
|
||||||
.bwr = true,
|
.bwr = true,
|
||||||
.invert_color = true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// SSD1619 400x300 Black/White
|
// SSD1619 400x300 Black/White
|
||||||
@@ -199,5 +201,4 @@ const epd_model_t epd_ssd1619_420_bw = {
|
|||||||
.width = 400,
|
.width = 400,
|
||||||
.height = 300,
|
.height = 300,
|
||||||
.bwr = false,
|
.bwr = false,
|
||||||
.invert_color = false,
|
|
||||||
};
|
};
|
||||||
|
|||||||
22
EPD/UC8176.c
22
EPD/UC8176.c
@@ -131,10 +131,8 @@ void UC8176_Init()
|
|||||||
EPD_WriteCommand(CMD_PSR);
|
EPD_WriteCommand(CMD_PSR);
|
||||||
EPD_WriteByte(psr);
|
EPD_WriteByte(psr);
|
||||||
|
|
||||||
if (!EPD->bwr) {
|
|
||||||
EPD_WriteCommand(CMD_CDI);
|
EPD_WriteCommand(CMD_CDI);
|
||||||
EPD_WriteByte(0x97);
|
EPD_WriteByte(EPD->bwr ? 0x77 : 0x97);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UC8176_Write_RAM(uint8_t cmd, uint8_t value)
|
static void UC8176_Write_RAM(uint8_t cmd, uint8_t value)
|
||||||
@@ -157,9 +155,8 @@ parameter:
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void UC8176_Clear(void)
|
void UC8176_Clear(void)
|
||||||
{
|
{
|
||||||
epd_model_t *EPD = epd_get();
|
|
||||||
UC8176_Write_RAM(CMD_DTM1, 0xFF);
|
UC8176_Write_RAM(CMD_DTM1, 0xFF);
|
||||||
UC8176_Write_RAM(CMD_DTM2, EPD->invert_color ? 0x00 : 0xFF);
|
UC8176_Write_RAM(CMD_DTM2, 0xFF);
|
||||||
UC8176_Refresh();
|
UC8176_Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,8 +200,7 @@ void UC8176_Write_Image(uint8_t *black, uint8_t *color, uint16_t x, uint16_t y,
|
|||||||
for (uint16_t i = 0; i < h; i++) {
|
for (uint16_t i = 0; i < h; i++) {
|
||||||
for (uint16_t j = 0; j < w / 8; j++) {
|
for (uint16_t j = 0; j < w / 8; j++) {
|
||||||
if (EPD->bwr) {
|
if (EPD->bwr) {
|
||||||
uint8_t data = color ? color[j + i * wb] : 0xFF;
|
EPD_WriteByte(color ? color[j + i * wb] : 0xFF);
|
||||||
EPD_WriteByte(EPD->invert_color ? ~data : data);
|
|
||||||
} else {
|
} else {
|
||||||
EPD_WriteByte(black[j + i * wb]);
|
EPD_WriteByte(black[j + i * wb]);
|
||||||
}
|
}
|
||||||
@@ -243,7 +239,6 @@ const epd_model_t epd_uc8176_420_bw = {
|
|||||||
.width = 400,
|
.width = 400,
|
||||||
.height = 300,
|
.height = 300,
|
||||||
.bwr = false,
|
.bwr = false,
|
||||||
.invert_color = false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// UC8176 400x300 Black/White/Red
|
// UC8176 400x300 Black/White/Red
|
||||||
@@ -253,15 +248,4 @@ const epd_model_t epd_uc8176_420_bwr = {
|
|||||||
.width = 400,
|
.width = 400,
|
||||||
.height = 300,
|
.height = 300,
|
||||||
.bwr = true,
|
.bwr = true,
|
||||||
.invert_color = false,
|
|
||||||
};
|
|
||||||
|
|
||||||
// UC8276 400x300 Black/White/Red
|
|
||||||
const epd_model_t epd_uc8276_420_bwr = {
|
|
||||||
.id = EPD_UC8276_420_BWR,
|
|
||||||
.drv = &epd_drv_uc8176,
|
|
||||||
.width = 400,
|
|
||||||
.height = 300,
|
|
||||||
.bwr = true,
|
|
||||||
.invert_color = true,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,13 +21,10 @@
|
|||||||
<div class="flex-group debug">
|
<div class="flex-group debug">
|
||||||
<label for="epddriver">驱动</label>
|
<label for="epddriver">驱动</label>
|
||||||
<select id="epddriver" onchange="filterDitheringOptions()">
|
<select id="epddriver" onchange="filterDitheringOptions()">
|
||||||
<option value="01">UC8176(黑白屏)</option>
|
<option value="01">UC8176/UC8276(黑白屏)</option>
|
||||||
<option value="03">UC8176(三色屏)</option>
|
<option value="03">UC8176/UC8276(三色屏)</option>
|
||||||
<option value="05">UC8276(三色屏)</option>
|
<option value="04">SSD1619/SSD1683(黑白屏)</option>
|
||||||
<option value="04">SSD1619(黑白屏)</option>
|
<option value="02">SSD1619/SSD1683(三色屏)</option>
|
||||||
<option value="02">SSD1619(三色屏)</option>
|
|
||||||
<option value="04">SSD1683(黑白屏)</option>
|
|
||||||
<option value="02">SSD1683(三色屏)</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-group debug">
|
<div class="flex-group debug">
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ async function sendimg() {
|
|||||||
status.parentElement.style.display = "block";
|
status.parentElement.style.display = "block";
|
||||||
|
|
||||||
if (mode.startsWith('bwr')) {
|
if (mode.startsWith('bwr')) {
|
||||||
const invert = (driver === '02') || (driver === '05');
|
const invert = (appVersion < 0x16) ? (driver === '02') : false;
|
||||||
await epdWrite(driver === "02" ? 0x24 : 0x10, canvas2bytes(canvas, 'bw'));
|
await epdWrite(driver === "02" ? 0x24 : 0x10, canvas2bytes(canvas, 'bw'));
|
||||||
await epdWrite(driver === "02" ? 0x26 : 0x13, canvas2bytes(canvas, 'red', invert));
|
await epdWrite(driver === "02" ? 0x26 : 0x13, canvas2bytes(canvas, 'red', invert));
|
||||||
} else {
|
} else {
|
||||||
@@ -219,11 +219,11 @@ async function connect() {
|
|||||||
try {
|
try {
|
||||||
addLog("正在连接: " + bleDevice.name);
|
addLog("正在连接: " + bleDevice.name);
|
||||||
gattServer = await bleDevice.gatt.connect();
|
gattServer = await bleDevice.gatt.connect();
|
||||||
addLog(' 找到 GATT Server');
|
addLog(' 找到 GATT Server');
|
||||||
epdService = await gattServer.getPrimaryService('62750001-d828-918d-fb46-b6c11c675aec');
|
epdService = await gattServer.getPrimaryService('62750001-d828-918d-fb46-b6c11c675aec');
|
||||||
addLog(' 找到 EPD Service');
|
addLog(' 找到 EPD Service');
|
||||||
epdCharacteristic = await epdService.getCharacteristic('62750002-d828-918d-fb46-b6c11c675aec');
|
epdCharacteristic = await epdService.getCharacteristic('62750002-d828-918d-fb46-b6c11c675aec');
|
||||||
addLog(' 找到 Characteristic');
|
addLog(' 找到 Characteristic');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
if (e.message) addLog("connect: " + e.message);
|
if (e.message) addLog("connect: " + e.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user