1717// obd.inl
1818// display interfacing/control code for OneBitDisplay library
1919//
20+ #ifdef __AVR__
21+ #define WIMPY_MCU
22+ #endif
23+
2024#if defined(_LINUX_) || defined(ARDUINO_ARCH_MCS51)
2125#define memcpy_P memcpy
2226#endif
@@ -32,7 +36,6 @@ static void EPDWriteImage(OBDISP *pOBD, uint8_t ucCMD, uint8_t *pBits, int x, in
3236void EPD213_Begin (OBDISP *pOBD, int x, int y, int w, int h, int bPartial);
3337void EPD_CMD2 (OBDISP *pOBD, uint8_t cmd, uint8_t param);
3438void obdSetDCMode (OBDISP *pOBD, int iMode);
35- void InvertBytes (uint8_t *pData, uint8_t bLen);
3639void SPI_BitBang (OBDISP *pOBD, uint8_t *pData, int iLen, uint8_t iMOSIPin, uint8_t iSCKPin);
3740static void RawWrite (OBDISP *pOBD, unsigned char *pData, int iLen);
3841void RawWriteData (OBDISP *pOBD, unsigned char *pData, int iLen);
@@ -2057,6 +2060,7 @@ void obdSPIInit(OBDISP *pOBD, int iType, int iDC, int iCS, int iReset, int iMOSI
20572060 pOBD->iFlags |= (OBD_HAS_PARTIAL_UPDATE | OBD_HAS_FAST_UPDATE);
20582061 pOBD->can_flip = 0 ;
20592062 return ; // nothing else to do yet
2063+ #ifndef WIMPY_MCU
20602064 } else if (iType == EPD29_BWYR_128x296) {
20612065 pOBD->native_width = pOBD->width = 128 ;
20622066 pOBD->native_height = pOBD->height = 296 ;
@@ -2122,6 +2126,7 @@ void obdSPIInit(OBDISP *pOBD, int iType, int iDC, int iCS, int iReset, int iMOSI
21222126 pOBD->iTimeout = 20000 ; // 4-color need a longer timeout (20 seconds)
21232127 pOBD->pInitFull = epd30_bwyr_init_sequence_full;
21242128 return ;
2129+ #endif // !WIMPY_MCU
21252130 } else if (iType == EPD213_122x250 || iType == EPD213_104x212 || iType == EPD29B_128x296)
21262131 {
21272132 if (iType == EPD213_122x250) {
@@ -3040,9 +3045,11 @@ static int EPDDumpPartial(OBDISP *pOBD, uint8_t *pBuffer, int x, int y, int w, i
30403045 EPDSendCMDSequence (pOBD, pOBD->pInitPart );
30413046 if (pOBD->chip_type == OBD_CHIP_UC8151) {
30423047 int iSize = pOBD->width * ((pOBD->height +7 )>>3 );
3048+ #ifndef WIMPY_MCU
30433049 EPDWriteImage (pOBD, 0x10 , &pOBD->ucScreen [iSize], 0 ,0 ,pOBD->width , pOBD->height , pOBD->iFlags & OBD_FAST_INVERTED); // write old data inverted
30443050 EPDWriteImage (pOBD, 0x13 , NULL , 0 , 0 , pOBD->width , pOBD->height , pOBD->iFlags & OBD_FAST_INVERTED);
30453051 memcpy (&pOBD->ucScreen [iSize], pOBD->ucScreen , iSize); // new becomes old
3052+ #endif // WIMPY_MCU
30463053 lTime = millis () - lTime;
30473054 pOBD->iDataTime = (int )lTime;
30483055 lTime = millis ();
@@ -3054,7 +3061,9 @@ static int EPDDumpPartial(OBDISP *pOBD, uint8_t *pBuffer, int x, int y, int w, i
30543061 pOBD->iOpTime = (int )lTime;
30553062 return 0 ;
30563063 } else { // SSD16xx
3064+ #ifndef WIMPY_MCU
30573065 EPDWriteImage (pOBD, 0x24 , NULL , 0 , 0 , pOBD->width , pOBD->height , pOBD->iFlags & OBD_FAST_INVERTED);
3066+ #endif
30583067 EPD_CMD2 (pOBD, 0x22 , 0xff );
30593068 lTime = millis () - lTime;
30603069 pOBD->iDataTime = (int )lTime;
@@ -3631,8 +3640,10 @@ static int EPDDumpBuffer(OBDISP *pOBD, int bRefresh, int bWait, int bFast)
36313640 pBuf1 = pOBD->ucScreen ; // B/W plane
36323641 pBuf2 = &pOBD->ucScreen [iSize]; // R plane
36333642 }
3643+ #ifndef WIMPY_MCU
36343644 EPDWriteImage (pOBD, UC8151_DTM1, pBuf1, 0 , 0 , pOBD->width , pOBD->height , 0 ); // B/W or 'old' plane
36353645 EPDWriteImage (pOBD, UC8151_DTM2, pBuf2, 0 , 0 , pOBD->width , pOBD->height , bInvert); // R or 'new' plane
3646+ #endif
36363647 }
36373648 lTime = millis () - lTime;
36383649 pOBD->iDataTime = (int )lTime; // record the time to xfer data
@@ -3651,13 +3662,17 @@ static int EPDDumpBuffer(OBDISP *pOBD, int bRefresh, int bWait, int bFast)
36513662 pBuf2 = &pOBD->ucScreen [iSize]; // R plane
36523663 bInvert = 1 ; // invert the R plane
36533664 }
3665+ #ifndef WIMPY_MCU
36543666 EPDWriteImage (pOBD, SSD1608_WRITE_ALTRAM, pBuf2, 0 , 0 , pOBD->width , pOBD->height , bInvert);
3667+ #endif
36553668 // need to reset the write pointer between planes
36563669 EPD_CMD2 (pOBD, SSD1608_SET_RAMXCOUNT, 0x00 );
36573670 ucTemp[0 ] = ucTemp[1 ] = 0 ;
36583671 obdWriteCommand (pOBD, SSD1608_SET_RAMYCOUNT);
36593672 RawWriteData (pOBD, ucTemp, 2 );
3673+ #ifndef WIMPY_MCU
36603674 EPDWriteImage (pOBD, SSD1608_WRITE_RAM, pBuf1, 0 , 0 , pOBD->width , pOBD->height , 0 );
3675+ #endif
36613676 }
36623677 lTime = millis () - lTime; // record data xfer time
36633678 pOBD->iDataTime = (int )lTime;
@@ -3723,7 +3738,9 @@ static int EPDDumpBuffer(OBDISP *pOBD, int bRefresh, int bWait, int bFast)
37233738 obdWriteCommand (pOBD, 0x04 );
37243739 EPDWaitBusy (pOBD, 0 );
37253740 }
3741+ #ifndef WIMPY_MCU
37263742 EPDWriteImage2bpp (pOBD, 0x10 , 0 , 0 , pOBD->width , pOBD->height );
3743+ #endif
37273744 }
37283745 if (pOBD->type == EPD164_BWYR_168x168 || pOBD->type == EPD236_BWYR_168x296) {
37293746 EPD_CMD2 (pOBD, 0x68 , 0x00 );
@@ -3732,9 +3749,11 @@ static int EPDDumpBuffer(OBDISP *pOBD, int bRefresh, int bWait, int bFast)
37323749 }
37333750 if (pOBD->type == EPD266_BWYR_184x360 || pOBD->type == EPD29_BWYR_168x384 || pOBD->type == EPD29_BWYR_128x296) {
37343751 EPDSendCMDSequence (pOBD, pOBD->pInitFull );
3752+ #ifndef WIMPY_MCU
37353753 if (pOBD->ucScreen ) {
37363754 EPDWriteImage2bpp (pOBD, 0x10 , 0 , 0 , pOBD->width , pOBD->height );
37373755 }
3756+ #endif
37383757 EPD_CMD2 (pOBD, 0x12 , 0x00 ); // display refresh
37393758 }
37403759 if (pOBD->type == EPD42R2_400x300) {
0 commit comments