inverse red ram with register

This commit is contained in:
Shuanglei Tao
2025-05-10 21:36:02 +08:00
parent 883d2f918a
commit 2bd2a142eb
6 changed files with 18 additions and 40 deletions

View File

@@ -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_ssd1619_420_bwr;
extern epd_model_t epd_ssd1619_420_bw;
extern epd_model_t epd_uc8276_420_bwr;
static epd_model_t *epd_models[] = {
&epd_uc8176_420_bw,
&epd_uc8176_420_bwr,
&epd_ssd1619_420_bwr,
&epd_ssd1619_420_bw,
&epd_uc8276_420_bwr,
};
// EPD model

View File

@@ -45,7 +45,6 @@ typedef enum
EPD_UC8176_420_BWR = 3,
EPD_SSD1619_420_BWR = 2,
EPD_SSD1619_420_BW = 4,
EPD_UC8276_420_BWR = 5,
} epd_model_id_t;
typedef struct
@@ -55,7 +54,6 @@ typedef struct
uint16_t width;
uint16_t height;
bool bwr;
bool invert_color;
} epd_model_t;
#define LOW (0x0)

View File

@@ -104,6 +104,10 @@ static void SSD1619_Refresh(void)
{
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]: temperature: %d\n", SSD1619_Read_Temp());
SSD1619_Update(0xF7);
@@ -130,7 +134,7 @@ void SSD1619_Clear(void)
EPD_WriteCommand(CMD_WRITE_RAM2);
for (uint16_t j = 0; j < Height; j++) {
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 j = 0; j < w / 8; j++) {
if (EPD->bwr) {
uint8_t data = color ? color[j + i * wb] : 0xFF;
EPD_WriteByte(EPD->invert_color ? ~data : data);
EPD_WriteByte(color ? color[j + i * wb] : 0xFF);
} else {
EPD_WriteByte(black[j + i * wb]);
}
@@ -189,7 +192,6 @@ const epd_model_t epd_ssd1619_420_bwr = {
.width = 400,
.height = 300,
.bwr = true,
.invert_color = true,
};
// SSD1619 400x300 Black/White
@@ -199,5 +201,4 @@ const epd_model_t epd_ssd1619_420_bw = {
.width = 400,
.height = 300,
.bwr = false,
.invert_color = false,
};

View File

@@ -131,10 +131,8 @@ void UC8176_Init()
EPD_WriteCommand(CMD_PSR);
EPD_WriteByte(psr);
if (!EPD->bwr) {
EPD_WriteCommand(CMD_CDI);
EPD_WriteByte(0x97);
}
EPD_WriteCommand(CMD_CDI);
EPD_WriteByte(EPD->bwr ? 0x77 : 0x97);
}
static void UC8176_Write_RAM(uint8_t cmd, uint8_t value)
@@ -157,9 +155,8 @@ parameter:
******************************************************************************/
void UC8176_Clear(void)
{
epd_model_t *EPD = epd_get();
UC8176_Write_RAM(CMD_DTM1, 0xFF);
UC8176_Write_RAM(CMD_DTM2, EPD->invert_color ? 0x00 : 0xFF);
UC8176_Write_RAM(CMD_DTM2, 0xFF);
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 j = 0; j < w / 8; j++) {
if (EPD->bwr) {
uint8_t data = color ? color[j + i * wb] : 0xFF;
EPD_WriteByte(EPD->invert_color ? ~data : data);
EPD_WriteByte(color ? color[j + i * wb] : 0xFF);
} else {
EPD_WriteByte(black[j + i * wb]);
}
@@ -243,7 +239,6 @@ const epd_model_t epd_uc8176_420_bw = {
.width = 400,
.height = 300,
.bwr = false,
.invert_color = false,
};
// UC8176 400x300 Black/White/Red
@@ -253,15 +248,4 @@ const epd_model_t epd_uc8176_420_bwr = {
.width = 400,
.height = 300,
.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,
};

View File

@@ -21,13 +21,10 @@
<div class="flex-group debug">
<label for="epddriver">驱动</label>
<select id="epddriver" onchange="filterDitheringOptions()">
<option value="01">UC8176黑白屏</option>
<option value="03">UC8176三色屏</option>
<option value="05">UC8276三色屏)</option>
<option value="04">SSD1619(黑白屏)</option>
<option value="02">SSD1619三色屏</option>
<option value="04">SSD1683黑白屏</option>
<option value="02">SSD1683三色屏</option>
<option value="01">UC8176/UC8276(黑白屏)</option>
<option value="03">UC8176/UC8276(三色屏)</option>
<option value="04">SSD1619/SSD1683黑白屏)</option>
<option value="02">SSD1619/SSD1683三色屏)</option>
</select>
</div>
<div class="flex-group debug">

View File

@@ -124,7 +124,7 @@ async function sendimg() {
status.parentElement.style.display = "block";
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" ? 0x26 : 0x13, canvas2bytes(canvas, 'red', invert));
} else {
@@ -219,11 +219,11 @@ async function connect() {
try {
addLog("正在连接: " + bleDevice.name);
gattServer = await bleDevice.gatt.connect();
addLog(' 找到 GATT Server');
addLog('&nbsp;&nbsp;找到 GATT Server');
epdService = await gattServer.getPrimaryService('62750001-d828-918d-fb46-b6c11c675aec');
addLog(' 找到 EPD Service');
addLog('&nbsp;&nbsp;找到 EPD Service');
epdCharacteristic = await epdService.getCharacteristic('62750002-d828-918d-fb46-b6c11c675aec');
addLog(' 找到 Characteristic');
addLog('&nbsp;&nbsp;找到 Characteristic');
} catch (e) {
console.error(e);
if (e.message) addLog("connect: " + e.message);