@@ -33,7 +33,6 @@ static void EPDWriteImage(OBDISP *pOBD, uint8_t ucCMD, uint8_t *pBits, int x, in
3333void EPD213_Begin (OBDISP *pOBD, int x, int y, int w, int h, int bPartial);
3434void EPD293_Begin (OBDISP *pOBD, int x, int y, int w, int h, int bPartial);
3535void EPD154_Begin (OBDISP *pOBD, int x, int y, int w, int h, int bPartial);
36- void EPD29R_Begin (OBDISP *pOBD, int x, int y, int w, int h, int bPartial);
3736void EPD_CMD2 (OBDISP *pOBD, uint8_t cmd, uint8_t param);
3837void obdSetDCMode (OBDISP *pOBD, int iMode);
3938void InvertBytes (uint8_t *pData, uint8_t bLen);
@@ -320,13 +319,17 @@ const uint8_t epd35r_init_sequence_full[] PROGMEM = {
320319 0x03 , 0x4f , 0x7f , 0x01 ,
321320 0x00
322321};
322+
323323// init sequence for GDEW042Z15
324324const uint8_t epd42r2_init_sequence_full[] PROGMEM = {
325- 0x04 , UC8151_BTST, 0x17 ,0x17 ,0x17 , // booster soft-start config - START_10MS | STRENGTH_3 | OFF_6_58US
325+ 0x03 , UC8151_PSR, 0xcf , 0x8d ,
326+ 0x06 , UC8151_PWR, 0x03 , 0x10 , 0x3f , 0x3f , 0x0d ,
326327 0x01 , UC8151_PON, // power on
327328 BUSY_WAIT,
328- 0x02 , 0x00 , 0x0f , // LUT from OTP
329- 0x02 , UC8151_CDI, 0x9c , // inverted, white border
329+ 0x05 , UC8151_TRES, 0x01 , 0x90 , 1 , 0x2c , // resolution
330+ 0x04 , UC8151_BTST, 0x17 ,0x17 ,0x17 , // booster soft-start config - START_10MS | STRENGTH_3 | OFF_6_58US
331+ // 0x02, 0x00, 0x0f, // LUT from OTP
332+ 0x02 , UC8151_CDI, 0x5c , // inverted, white border
330333 0x00
331334};
332335
@@ -340,14 +343,31 @@ const uint8_t EPD213R_104x212_d_init_sequence_full[] PROGMEM = {
340343 0x00
341344};
342345
346+ // initialization sequence for 3.7" 240x416 e-paper
347+ const uint8_t epd37_init_sequence_full[] PROGMEM = {
348+ 0x03 , UC8151_PSR, 0xdf , 0x8d ,
349+ 0x06 , UC8151_PWR, 0x03 , 0x10 , 0x3f , 0x3f , 0x0d ,
350+ 0x01 , UC8151_PON, // power on
351+ BUSY_WAIT,
352+ 0x04 , UC8151_TRES, 0xf0 , 1 , 0xa0 , // resolution
353+
354+ 0x04 , UC8151_BTST, 0x17 ,0x17 ,0x17 , // booster soft-start config - START_10MS | STRENGTH_3 | OFF_6_58US
355+ 0x02 , UC8151_PFS, 0x00 , // FRAMES_1
356+ 0x02 , UC8151_TSE, 0x00 , // TEMP_INTERNAL | OFFSET_0
357+ 0x02 , UC8151_TCON, 0x22 ,
358+ 0x02 , UC8151_CDI, 0xd7 , // inverted, white border
359+ 0x02 , UC8151_PLL, 0x09 , // HZ_50
360+ 0x00 // end of table
361+ };
343362// initialization sequence for 2.9" 296x128 e-paper
344363const uint8_t epd29_init_sequence_full[] PROGMEM = {
345- 0x02 , UC8151_PSR, 0x80 | 0x00 | 0x10 | 0x00 | 0x02 | 0x01 , // RES_128x296, LUT_OTP, FORMAT_BW, SHIFT_LEFT, BOOSTER_ON, RESET_NONE
364+ 0x02 , UC8151_PSR, 0x80 | 0x00 | 0x10 | 0x08 | 0x04 | 0x02 | 0x01 , // RES_128x296, LUT_OTP, FORMAT_BW, SHIFT_LEFT, BOOSTER_ON, RESET_NONE
346365 0x06 , UC8151_PWR, 0x03 , 0x00 , 0x2b , 0x2b , 0x2b ,
347366 0x01 , UC8151_PON, // power on
348367 BUSY_WAIT,
349368 0x04 , UC8151_BTST, 0x17 ,0x17 ,0x17 , // booster soft-start config - START_10MS | STRENGTH_3 | OFF_6_58US
350369 0x02 , UC8151_PFS, 0x00 , // FRAMES_1
370+ 0x04 , UC8151_TRES, 0x80 , 1 , 0x28 , // resolution
351371 0x02 , UC8151_TSE, 0x00 , // TEMP_INTERNAL | OFFSET_0
352372 0x02 , UC8151_TCON, 0x22 ,
353373 0x02 , UC8151_CDI, 0x9c , // inverted, white border
@@ -416,7 +436,8 @@ const uint8_t epd29r_init_sequence[] PROGMEM = {
416436 0x03 , 0x4f , 0x27 , 0x01 , // RAM Y counter
417437 0x00
418438};
419- // for 152x152
439+
440+ // for 152x152 BWR
420441const uint8_t epd29r_init_sequence_152[] PROGMEM = {
421442 0x01 , 0x12 , // soft reset
422443 BUSY_WAIT,
@@ -496,7 +517,7 @@ const uint8_t epd154b_init_sequence_full[] PROGMEM =
496517{
497518 1 , UC8151_PON,
498519 BUSY_WAIT,
499- 2 , UC8151_PSR, 0x1f , // panel setting
520+ 2 , UC8151_PSR, 0xdf , // panel setting
500521 4 , UC8151_TRES, 0x98 , 0 , 0x98 , // resolution
501522 2 , UC8151_CDI, 0x97 , // VCOM
502523 0
@@ -1245,6 +1266,7 @@ void obdSPIInit(OBDISP *pOBD, int iType, int iDC, int iCS, int iReset, int iMOSI
12451266 pOBD->iTimeout = 5000 ; // 5 seconds for most e-ink panels
12461267 pOBD->can_flip = 1 ; // assume can flip 180
12471268 pOBD->ucScreen = NULL ; // start with no backbuffer; user must provide one later
1269+ pOBD->x_offset = 0 ; // e-paper memory column offset
12481270 pOBD->iDCPin = iDC;
12491271 pOBD->iCSPin = iCS;
12501272 pOBD->iRSTPin = iReset;
@@ -1432,20 +1454,26 @@ void obdSPIInit(OBDISP *pOBD, int iType, int iDC, int iCS, int iReset, int iMOSI
14321454 pOBD->iTimeout = 25000 ; // 3-color need a longer timeout (25 seconds)
14331455 return ;
14341456#endif // !WIMPY_MCU
1435- } else if (iType == EPD42R2_400x300 || iType == EPD213R_104x212) {
1436- if (iType == EPD213R_104x212) {
1457+ } else if (iType == EPD42R2_400x300 || iType == EPD213R_104x212 || iType == EPD37Y_240x416) {
1458+ if (iType == EPD37Y_240x416) {
1459+ pOBD->native_width = pOBD->width = 240 ;
1460+ pOBD->native_height = pOBD->height = 416 ;
1461+ pOBD->type = EPD42R2_400x300; // use the same commands
1462+ }else if (iType == EPD213R_104x212) {
14371463 pOBD->native_width = pOBD->width = 104 ;
14381464 pOBD->native_height = pOBD->height = 212 ;
14391465 pOBD->type = EPD42R2_400x300; // use the same commands
14401466 } else {
14411467 pOBD->native_width = pOBD->width = 400 ;
14421468 pOBD->native_height = pOBD->height = 300 ;
14431469 }
1470+ pOBD->pInitFull = epd42r2_init_sequence_full;
14441471 pOBD->can_flip = 0 ;
14451472 pOBD->busy_idle = HIGH;
14461473 pOBD->iFlags |= OBD_3COLOR;
14471474 pOBD->chip_type = OBD_CHIP_UC8151;
14481475 pOBD->iTimeout = 25000 ; // 3-color need a longer timeout (25 seconds)
1476+ EPDSendCMDSequence (pOBD, pOBD->pInitFull );
14491477 } else if (iType == EPD213R_104x212_d) {
14501478 pOBD->native_width = pOBD->width = 104 ;
14511479 pOBD->native_height = pOBD->height = 212 ;
@@ -1467,25 +1495,48 @@ void obdSPIInit(OBDISP *pOBD, int iType, int iDC, int iCS, int iReset, int iMOSI
14671495 pOBD->pInitFull = epd35r_init_sequence_full;
14681496 return ;
14691497 }
1470- else if (iType == EPD29R_128x296 || iType == EPD154R_152x152 || iType == EPD42R_400x300)
1498+ else if (iType == EPD29R_128x296 || iType == EPD154R_152x152 || iType == EPD42R_400x300 || iType == EPD31R_168x296 || iType == EPD154Y_152x152 || iType == EPD29Y_128x296 || iType == EPD213R2_122x250 )
14711499 { // BLACK/WHITE/RED
1472- if (iType == EPD29R_128x296) {
1473- pOBD->native_width = pOBD->width = 128 ;
1474- pOBD->native_height = pOBD->height = 296 ;
1500+ if (iType == EPD31R_168x296) {
1501+ pOBD->native_width = pOBD->width = 168 ;
1502+ pOBD->native_height = pOBD->height = 296 ;
1503+ pOBD->pInitFull = epd29r_init_sequence;
1504+ } else if (iType == EPD29Y_128x296) {
1505+ pOBD->native_width = pOBD->width = 128 ;
1506+ pOBD->native_height = pOBD->height = 296 ;
1507+ pOBD->pInitFull = epd29r_init_sequence;
1508+ pOBD->x_offset = 1 ;
1509+ } else if (iType == EPD29R_128x296) {
1510+ pOBD->native_width = pOBD->width = 128 ;
1511+ pOBD->native_height = pOBD->height = 296 ;
1512+ pOBD->pInitFull = epd29r_init_sequence;
1513+ } else if (iType == EPD154Y_152x152) {
1514+ pOBD->native_width = pOBD->width = 152 ;
1515+ pOBD->native_height = pOBD->height = 152 ;
1516+ pOBD->pInitFull = epd29r_init_sequence_152;
1517+ pOBD->x_offset = 1 ;
14751518 } else if (iType == EPD154R_152x152){
14761519 pOBD->native_width = pOBD->width = 152 ;
14771520 pOBD->native_height = pOBD->height = 152 ;
1521+ pOBD->pInitFull = epd29r_init_sequence_152;
1522+ } else if (iType == EPD213R2_122x250) {
1523+ pOBD->native_width = pOBD->width = 122 ;
1524+ pOBD->native_height = pOBD->height = 250 ;
1525+ pOBD->pInitFull = epd29r_init_sequence;
1526+ pOBD->x_offset = 1 ;
14781527 } else {
14791528 pOBD->native_width = pOBD->width = 400 ;
14801529 pOBD->native_height = pOBD->height = 300 ;
1530+ pOBD->pInitFull = epd42r_init_sequence;
14811531 }
14821532 pOBD->type = EPD29R_128x296; // use the rest of the same code
14831533 pOBD->iTimeout = 25000 ; // 3-color need a longer timeout (25 seconds)
1484- pOBD->iFlags |= OBD_3COLOR;
1534+ pOBD->iFlags |= OBD_3COLOR;
14851535 pOBD->chip_type = OBD_CHIP_SSD16xx;
1486- pOBD->can_flip = 0 ;
1487- pOBD->busy_idle = LOW;
1488- return ;
1536+ pOBD->can_flip = 0 ;
1537+ pOBD->busy_idle = LOW;
1538+ EPDSendCMDSequence (pOBD, pOBD->pInitFull );
1539+ return ;
14891540 }
14901541 else if (iType == EPD102_80x128) // not working yet
14911542 {
@@ -1507,6 +1558,7 @@ void obdSPIInit(OBDISP *pOBD, int iType, int iDC, int iCS, int iReset, int iMOSI
15071558// pOBD->iFlags |= OBD_CS_EVERY_BYTE;
15081559 pOBD->pInitFull = epd154b_init_sequence_full;
15091560 pOBD->pInitFast = epd154b_init_sequence_fast;
1561+ EPDSendCMDSequence (pOBD, pOBD->pInitFull );
15101562 return ;
15111563 }
15121564 else if (iType == EPD154_200x200)
@@ -1520,23 +1572,31 @@ void obdSPIInit(OBDISP *pOBD, int iType, int iDC, int iCS, int iReset, int iMOSI
15201572 pOBD->pInitFull = epd154_init_sequence_full;
15211573 return ;
15221574 }
1523- else if (iType == EPD29_128x296 || iType == EPD213B_104x212)
1575+ else if (iType == EPD29_128x296 || iType == EPD213B_104x212 || iType == EPD37_240x416 )
15241576 {
1525- if (iType == EPD29_128x296) {
1577+ pOBD->iFlags |= OBD_HAS_FAST_UPDATE;
1578+ pOBD->chip_type = OBD_CHIP_UC8151;
1579+ pOBD->can_flip = 0 ; // flip display commands don't exist
1580+ if (iType == EPD37_240x416) {
1581+ pOBD->native_width = pOBD->width = 240 ;
1582+ pOBD->native_height = pOBD->height = 416 ;
1583+ pOBD->busy_idle = HIGH;
1584+ pOBD->pInitFull = epd37_init_sequence_full;
1585+ EPDSendCMDSequence (pOBD, epd37_init_sequence_full);
1586+ pOBD->type = EPD29_128x296; // tell it to use this config
1587+ } else if (iType == EPD29_128x296) {
15261588 pOBD->native_width = pOBD->width = 128 ;
15271589 pOBD->native_height = pOBD->height = 296 ;
15281590 pOBD->busy_idle = HIGH;
15291591 pOBD->pInitFull = epd29_init_sequence_full;
1592+ EPDSendCMDSequence (pOBD, pOBD->pInitFull );
15301593 } else {
15311594 pOBD->native_width = pOBD->width = 104 ;
15321595 pOBD->native_height = pOBD->height = 212 ;
15331596 pOBD->busy_idle = LOW;
1534- pOBD->type = EPD29_128x296; // fool it into using this config
1597+ pOBD->type = EPD29_128x296; // tell it to use this config
1598+ EPD29_Init (pOBD);
15351599 }
1536- pOBD->iFlags |= OBD_HAS_FAST_UPDATE;
1537- pOBD->chip_type = OBD_CHIP_UC8151;
1538- pOBD->can_flip = 0 ; // flip display commands don't exist
1539- EPD29_Init (pOBD);
15401600 return ;
15411601 } else if (iType == EPD47_540x960) {
15421602 pOBD->native_width = pOBD->width = 540 ;
@@ -2923,24 +2983,6 @@ void EPD293_Begin(OBDISP *pOBD, int x, int y, int w, int h, int bPartial)
29232983 }
29242984} /* EPD293_Begin() */
29252985
2926- void EPD29R_Begin (OBDISP *pOBD, int x, int y, int w, int h, int bPartial)
2927- {
2928- (void )x;
2929- (void )y;
2930- (void )w;
2931- (void )h;
2932- if (bPartial) {
2933- } else {
2934- if (pOBD->native_width == 152 ) {
2935- EPDSendCMDSequence (pOBD, epd29r_init_sequence_152);
2936- } else if (pOBD->native_width == 400 ) {
2937- EPDSendCMDSequence (pOBD, epd42r_init_sequence);
2938- } else {
2939- EPDSendCMDSequence (pOBD, epd29r_init_sequence);
2940- }
2941- }
2942- } /* EPD29R_Begin() */
2943-
29442986void EPD47_Begin (OBDISP *pOBD, int x, int y, int w, int h, int bPartial)
29452987{
29462988 (void )x;
@@ -3034,8 +3076,8 @@ static int EPDDumpBuffer(OBDISP *pOBD, int bRefresh)
30343076 }
30353077#endif // !WIMPY_MCU
30363078 if (pOBD->type == EPD42R2_400x300) {
3037- EPDSendCMDSequence (pOBD, epd42r2_init_sequence_full );
3038- EPD27_SetLut (pOBD, false );
3079+ EPDSendCMDSequence (pOBD, pOBD-> pInitFull );
3080+ // EPD27_SetLut(pOBD, false);
30393081#ifndef WIMPY_MCU
30403082 if (pOBD->ucScreen ) {
30413083 EPDWriteImage (pOBD, 0x10 , NULL , 0 , 0 , pOBD->width , pOBD->height , 0 ); // black/white plane
@@ -3128,7 +3170,7 @@ static int EPDDumpBuffer(OBDISP *pOBD, int bRefresh)
31283170 }
31293171 }
31303172 if (pOBD->type == EPD29_128x296) {
3131- EPD29_Begin (pOBD, 0 , 0 , pOBD->width , pOBD-> height , false );
3173+ EPDSendCMDSequence (pOBD, pOBD->pInitFull );
31323174#ifndef WIMPY_MCU
31333175 if (pOBD->ucScreen ) {
31343176 EPDWriteImage (pOBD, UC8151_DTM1, NULL , 0 , 0 , pOBD->width , pOBD->height , 0 ); // send buffer to 'old' plane
@@ -3171,7 +3213,7 @@ static int EPDDumpBuffer(OBDISP *pOBD, int bRefresh)
31713213 }
31723214 if (pOBD->type == EPD29R_128x296) { // BLACK/WHITE/RED
31733215 uint8_t ucTemp[4 ];
3174- EPD29R_Begin (pOBD, 0 , 0 , pOBD->width , pOBD-> height , false );
3216+ EPDSendCMDSequence (pOBD, pOBD->pInitFull );
31753217#ifndef WIMPY_MCU
31763218 if (pOBD->ucScreen ) {
31773219 EPDWriteImage (pOBD, 0x26 , NULL , 0 , 0 , pOBD->width , pOBD->height , 1 ); // red plane
@@ -3667,8 +3709,8 @@ int i, tx, ty;
36673709 if (y + cy > pOBD->native_width )
36683710 cy = pOBD->native_width - y;
36693711 y &= 0xff8 ; // fix to byte boundary
3670- if ((pOBD->iFlags & OBD_FLIPV) || (pOBD->ucScreen == NULL && pOBD->chip_type == OBD_CHIP_SSD16xx)) // flipped Y when drawing with no back buffer
3671- tx = (pOBD->native_width - y - cy)/8 ;
3712+ if ((pOBD->iFlags & OBD_FLIPV) || (pOBD->ucScreen == NULL /* && pOBD->chip_type == OBD_CHIP_SSD16xx*/ )) // flipped Y when drawing with no back buffer
3713+ tx = (pOBD->native_width /* + 7 */ - y - cy)/8 ;
36723714 else
36733715 tx = y/8 ;
36743716 ty = x;
@@ -3715,8 +3757,10 @@ int i, tx, ty;
37153757 obdWriteCommand (pOBD, SSD1608_WRITE_RAM); // prepare to start writing pixels
37163758 } else {
37173759 obdWriteCommand (pOBD, SSD1608_SET_RAMXPOS);
3718- uc[0 ] = tx; // start x (byte boundary)
3719- uc[1 ] = tx+((cx-1 )>>3 ); // end x
3760+ uc[0 ] = tx + pOBD->x_offset ; // start x (byte boundary)
3761+ // if (cx == pOBD->native_width && (pOBD->native_width & 7) != 0)
3762+ // cx += 7; // needs one more byte for the full display width
3763+ uc[1 ] = tx+((cx-1 )>>3 ) + pOBD->x_offset ; // end x
37203764 RawWriteData (pOBD, uc, 2 );
37213765 obdWriteCommand (pOBD, SSD1608_SET_RAMYPOS);
37223766 if (pOBD->iFlags & OBD_FLIPV) {
@@ -3774,10 +3818,14 @@ int i, tx, ty;
37743818 }
37753819 uc[i++] = 0 ; // stay inside the partial window3
37763820 RawWriteData (pOBD, uc, i);
3777- // if (pOBD->iFG == OBD_RED) // write to red plane
3821+ if (pOBD->iFlags & OBD_3COLOR) {
3822+ if (pOBD->iFG == OBD_RED) // write to red plane
3823+ obdWriteCommand (pOBD, UC8151_DTM2);
3824+ else
3825+ obdWriteCommand (pOBD, UC8151_DTM1); // prepare to start writing pixels
3826+ } else {
37783827 obdWriteCommand (pOBD, UC8151_DTM2);
3779- // else
3780- // obdWriteCommand(pOBD, UC8151_DTM1); // prepare to start writing pixels
3828+ }
37813829 break ;
37823830 default : // error
37833831 break ;
0 commit comments