diff --git a/EPD/EPD_driver.c b/EPD/EPD_driver.c index cba346e..656c748 100644 --- a/EPD/EPD_driver.c +++ b/EPD/EPD_driver.c @@ -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 diff --git a/EPD/EPD_driver.h b/EPD/EPD_driver.h index 5e44c2a..3a1887f 100644 --- a/EPD/EPD_driver.h +++ b/EPD/EPD_driver.h @@ -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) diff --git a/EPD/SSD1619.c b/EPD/SSD1619.c index 53c0f7e..86e6545 100644 --- a/EPD/SSD1619.c +++ b/EPD/SSD1619.c @@ -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, }; diff --git a/EPD/UC8176.c b/EPD/UC8176.c index 18f2c7e..3fb95be 100644 --- a/EPD/UC8176.c +++ b/EPD/UC8176.c @@ -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, }; diff --git a/html/index.html b/html/index.html index cae241e..a37c894 100644 --- a/html/index.html +++ b/html/index.html @@ -21,13 +21,10 @@
diff --git a/html/js/main.js b/html/js/main.js index 0a7d36c..dd09f4a 100644 --- a/html/js/main.js +++ b/html/js/main.js @@ -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('  找到 GATT Server'); epdService = await gattServer.getPrimaryService('62750001-d828-918d-fb46-b6c11c675aec'); - addLog(' 找到 EPD Service'); + addLog('  找到 EPD Service'); epdCharacteristic = await epdService.getCharacteristic('62750002-d828-918d-fb46-b6c11c675aec'); - addLog(' 找到 Characteristic'); + addLog('  找到 Characteristic'); } catch (e) { console.error(e); if (e.message) addLog("connect: " + e.message);