mirror of
https://github.com/usetrmnl/bb_epaper.git
synced 2026-04-29 13:43:26 -07:00
more cleanup
This commit is contained in:
+3
-1
@@ -123,7 +123,9 @@ void bbepWriteData(BBEPDISP *pBBEP, uint8_t *pData, int iLen)
|
||||
SPI.transferBytes(pData, NULL, iLen);
|
||||
#else
|
||||
digitalWrite(pBBEP->iCSPin, LOW);
|
||||
SPI.transfer(pData, iLen);
|
||||
for (int i=0; i<iLen; i++) { // Arduino clobbers the data (duplex)
|
||||
SPI.transfer(pData[i]);
|
||||
}
|
||||
digitalWrite(pBBEP->iCSPin, HIGH);
|
||||
#endif
|
||||
} /* bbepWriteData() */
|
||||
|
||||
@@ -1055,6 +1055,24 @@ void bbepSleep(BBEPDISP *pBBEP, int bDeep)
|
||||
pBBEP->is_awake = 0;
|
||||
} /* bbepSleep() */
|
||||
|
||||
void bbepStartWrite(BBEPDISP *pBBEP, int iPlane)
|
||||
{
|
||||
uint8_t u8Cmd;
|
||||
|
||||
if (pBBEP->chip_type == BBEP_CHIP_UC81xx) {
|
||||
if (iPlane == PLANE_0)
|
||||
u8Cmd = UC8151_DTM2;
|
||||
else
|
||||
u8Cmd = UC8151_DTM1;
|
||||
} else { // SSD16xx
|
||||
if (iPlane == PLANE_0)
|
||||
u8Cmd = SSD1608_WRITE_RAM;
|
||||
else
|
||||
u8Cmd = SSD1608_WRITE_ALTRAM;
|
||||
}
|
||||
bbepWriteCmd(pBBEP, u8Cmd);
|
||||
} /* bbepStartWrite() */
|
||||
|
||||
//
|
||||
// More efficient means of sending commands, data and busy-pauses
|
||||
//
|
||||
|
||||
+42
-35
@@ -1314,8 +1314,8 @@ void bbepRectangle(BBEPDISP *pBBEP, int x1, int y1, int x2, int y2, uint8_t ucCo
|
||||
}
|
||||
}
|
||||
|
||||
if (pBBEP == NULL || pBBEP->ucScreen == NULL)
|
||||
return; // only works with a back buffer
|
||||
if (pBBEP == NULL)
|
||||
return; // invalid - must have BBEPDISP structure
|
||||
|
||||
if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0 ||
|
||||
x1 >= pBBEP->width || y1 >= pBBEP->height || x2 >= pBBEP->width || y2 >= pBBEP->height) return; // invalid coordinates
|
||||
@@ -1336,41 +1336,48 @@ void bbepRectangle(BBEPDISP *pBBEP, int x1, int y1, int x2, int y2, uint8_t ucCo
|
||||
}
|
||||
if (bFilled)
|
||||
{
|
||||
int x, y, iMiddle;
|
||||
iMiddle = (y2 >> 3) - (y1 >> 3);
|
||||
ucMask = 0xff << (y1 & 7);
|
||||
if (iMiddle == 0) // top and bottom lines are in the same row
|
||||
ucMask &= (0xff >> (7-(y2 & 7)));
|
||||
d = &pBBEP->ucScreen[iRedOffset + (y1 >> 3)*iPitch + x1];
|
||||
// Draw top
|
||||
for (x = x1; x <= x2; x++)
|
||||
{
|
||||
if (ucColor)
|
||||
*d |= ucMask;
|
||||
else
|
||||
*d &= ~ucMask;
|
||||
d++;
|
||||
}
|
||||
if (iMiddle > 1) // need to draw middle part
|
||||
{
|
||||
ucMask = (ucColor) ? 0xff : 0x00;
|
||||
for (y=1; y<iMiddle; y++)
|
||||
{
|
||||
d = &pBBEP->ucScreen[iRedOffset + (y1 >> 3)*iPitch + x1 + (y*iPitch)];
|
||||
for (x = x1; x <= x2; x++)
|
||||
*d++ = ucMask;
|
||||
}
|
||||
}
|
||||
if (iMiddle >= 1) // need to draw bottom part
|
||||
{
|
||||
ucMask = 0xff >> (7-(y2 & 7));
|
||||
d = &pBBEP->ucScreen[iRedOffset + (y2 >> 3)*iPitch + x1];
|
||||
for (x = x1; x <= x2; x++)
|
||||
{
|
||||
if (pBBEP->ucScreen) { // has a buffer to fill
|
||||
int x, y, iMiddle;
|
||||
iMiddle = (y2 >> 3) - (y1 >> 3);
|
||||
ucMask = 0xff << (y1 & 7);
|
||||
if (iMiddle == 0) // top and bottom lines are in the same row
|
||||
ucMask &= (0xff >> (7-(y2 & 7)));
|
||||
d = &pBBEP->ucScreen[iRedOffset + (y1 >> 3)*iPitch + x1];
|
||||
// Draw top
|
||||
for (x = x1; x <= x2; x++) {
|
||||
if (ucColor)
|
||||
*d++ |= ucMask;
|
||||
*d |= ucMask;
|
||||
else
|
||||
*d++ &= ~ucMask;
|
||||
*d &= ~ucMask;
|
||||
d++;
|
||||
}
|
||||
if (iMiddle > 1) { // need to draw middle part
|
||||
ucMask = (ucColor) ? 0xff : 0x00;
|
||||
for (y=1; y<iMiddle; y++) {
|
||||
d = &pBBEP->ucScreen[iRedOffset + (y1 >> 3)*iPitch + x1 + (y*iPitch)];
|
||||
for (x = x1; x <= x2; x++)
|
||||
*d++ = ucMask;
|
||||
}
|
||||
}
|
||||
if (iMiddle >= 1) { // need to draw bottom part
|
||||
ucMask = 0xff >> (7-(y2 & 7));
|
||||
d = &pBBEP->ucScreen[iRedOffset + (y2 >> 3)*iPitch + x1];
|
||||
for (x = x1; x <= x2; x++) {
|
||||
if (ucColor)
|
||||
*d++ |= ucMask;
|
||||
else
|
||||
*d++ &= ~ucMask;
|
||||
}
|
||||
}
|
||||
} else { // no buffer
|
||||
int cx, cy, iPitch;
|
||||
cx = x2-x1+1;
|
||||
iPitch = (cx+7)/8;
|
||||
memset(u8Cache, (ucColor == BBEP_WHITE) ? 0xff:0x00, iPitch);
|
||||
bbepSetAddrWindow(pBBEP, x1, y1, cx, (y2-y1+1));
|
||||
bbepStartWrite(pBBEP, pBBEP->iPlane);
|
||||
for (cy = y1; cy <= y2; cy++) { // one line at a time
|
||||
bbepWriteData(pBBEP, u8Cache, iPitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-15
@@ -130,7 +130,7 @@ uint32_t BBEPAPER::capabilities(void)
|
||||
|
||||
void BBEPAPER::setRotation(int iRotation)
|
||||
{
|
||||
// obdSetRotation(&_bbep, iRotation);
|
||||
bbepSetRotation(&_bbep, iRotation);
|
||||
} /* setRotation() */
|
||||
|
||||
int BBEPAPER::getRotation(void)
|
||||
@@ -459,20 +459,7 @@ void BBEPAPER::drawSprite(const uint8_t *pSprite, int cx, int cy, int iPitch, in
|
||||
}
|
||||
void BBEPAPER::startWrite(int iPlane)
|
||||
{
|
||||
uint8_t u8Cmd;
|
||||
|
||||
if (_bbep.chip_type == BBEP_CHIP_UC81xx) {
|
||||
if (iPlane == PLANE_0)
|
||||
u8Cmd = UC8151_DTM2;
|
||||
else
|
||||
u8Cmd = UC8151_DTM1;
|
||||
} else { // SSD16xx
|
||||
if (iPlane == PLANE_0)
|
||||
u8Cmd = SSD1608_WRITE_RAM;
|
||||
else
|
||||
u8Cmd = SSD1608_WRITE_ALTRAM;
|
||||
}
|
||||
bbepWriteCmd(&_bbep, u8Cmd);
|
||||
bbepStartWrite(&_bbep, iPlane);
|
||||
} /* startWrite() */
|
||||
|
||||
void BBEPAPER::writeData(uint8_t *pData, int iLen)
|
||||
|
||||
Reference in New Issue
Block a user