diff --git a/README.md b/README.md
index cac4234..ccdc7a9 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,11 @@ The current code supports 1-bit black and white epaper displays as well as the B
See WiKi and example code for how to use the library.
+In the photo below, the custom font and ellipse were drawn without using a local copy of the frame buffer (aka bufferless). bb_epaper offers some unique features like these when working on very constrained devices (insufficient RAM to hold a copy of the graphics).
+
+
+
+
If you find this code useful, please consider sending a donation or becomming a Github sponsor.
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SR4F44J2UR8S4)
diff --git a/bb_epaper_demo.jpg b/bb_epaper_demo.jpg
new file mode 100644
index 0000000..d206056
Binary files /dev/null and b/bb_epaper_demo.jpg differ
diff --git a/src/bb_ep_gfx.inl b/src/bb_ep_gfx.inl
index 2a04206..26437dd 100644
--- a/src/bb_ep_gfx.inl
+++ b/src/bb_ep_gfx.inl
@@ -1335,7 +1335,7 @@ static void DrawScaledLine(BBEPDISP *pBBEP, int iCX, int iCY, int x, int y, int3
// Draw the 8 pixels around the Bresenham circle
// (scaled to make an ellipse)
//
-static void BresenhamCircle(BBEPDISP *pBBEP, int iCX, int iCY, int x, int y, int32_t iXFrac, int32_t iYFrac, uint8_t ucColor, uint8_t bFill)
+static void BresenhamCircle(BBEPDISP *pBBEP, int iCX, int iCY, int x, int y, int32_t iXFrac, int32_t iYFrac, uint8_t ucColor, uint8_t u8Parts, uint8_t bFill)
{
if (bFill) // draw a filled ellipse
{
@@ -1347,21 +1347,29 @@ static void BresenhamCircle(BBEPDISP *pBBEP, int iCX, int iCY, int x, int y, int
}
else // draw 8 pixels around the edges
{
- DrawScaledPixel(pBBEP, iCX, iCY, x, y, iXFrac, iYFrac, ucColor);
- DrawScaledPixel(pBBEP, iCX, iCY, -x, y, iXFrac, iYFrac, ucColor);
- DrawScaledPixel(pBBEP, iCX, iCY, x, -y, iXFrac, iYFrac, ucColor);
- DrawScaledPixel(pBBEP, iCX, iCY, -x, -y, iXFrac, iYFrac, ucColor);
- DrawScaledPixel(pBBEP, iCX, iCY, y, x, iXFrac, iYFrac, ucColor);
- DrawScaledPixel(pBBEP, iCX, iCY, -y, x, iXFrac, iYFrac, ucColor);
- DrawScaledPixel(pBBEP, iCX, iCY, y, -x, iXFrac, iYFrac, ucColor);
- DrawScaledPixel(pBBEP, iCX, iCY, -y, -x, iXFrac, iYFrac, ucColor);
+ if (u8Parts & 1) {
+ DrawScaledPixel(pBBEP, iCX, iCY, -x, -y, iXFrac, iYFrac, ucColor);
+ DrawScaledPixel(pBBEP, iCX, iCY, -y, -x, iXFrac, iYFrac, ucColor);
+ }
+ if (u8Parts & 2) {
+ DrawScaledPixel(pBBEP, iCX, iCY, x, -y, iXFrac, iYFrac, ucColor);
+ DrawScaledPixel(pBBEP, iCX, iCY, y, -x, iXFrac, iYFrac, ucColor);
+ }
+ if (u8Parts & 4) {
+ DrawScaledPixel(pBBEP, iCX, iCY, x, y, iXFrac, iYFrac, ucColor);
+ DrawScaledPixel(pBBEP, iCX, iCY, y, x, iXFrac, iYFrac, ucColor);
+ }
+ if (u8Parts & 8) {
+ DrawScaledPixel(pBBEP, iCX, iCY, -x, y, iXFrac, iYFrac, ucColor);
+ DrawScaledPixel(pBBEP, iCX, iCY, -y, x, iXFrac, iYFrac, ucColor);
+ }
}
} /* BresenhamCircle() */
//
// Draw an outline or filled ellipse
//
-void bbepEllipse(BBEPDISP *pBBEP, int iCenterX, int iCenterY, int32_t iRadiusX, int32_t iRadiusY, uint8_t ucColor, uint8_t bFilled)
+void bbepEllipse(BBEPDISP *pBBEP, int iCenterX, int iCenterY, int32_t iRadiusX, int32_t iRadiusY, uint8_t u8Parts, uint8_t ucColor, uint8_t bFilled)
{
int32_t iXFrac, iYFrac;
int iRadius, iDelta, x, y;
@@ -1383,7 +1391,7 @@ void bbepEllipse(BBEPDISP *pBBEP, int iCenterX, int iCenterY, int32_t iRadiusX,
iDelta = 3 - (2 * iRadius);
x = 0; y = iRadius;
while (x <= y) {
- BresenhamCircle(pBBEP, iCenterX, iCenterY, x, y, iXFrac, iYFrac, ucColor, bFilled);
+ BresenhamCircle(pBBEP, iCenterX, iCenterY, x, y, iXFrac, iYFrac, ucColor, u8Parts, bFilled);
x++;
if (iDelta < 0) {
iDelta += (4*x) + 6;
@@ -1554,5 +1562,29 @@ void bbepRectangle(BBEPDISP *pBBEP, int x1, int y1, int x2, int y2, uint8_t ucCo
} // outline
} /* bbepRectangle() */
+void bbepRoundRect(BBEPDISP *pBBEP, int x, int y, int w, int h, int r, uint8_t iColor, int bFilled)
+{
+ if (bFilled) {
+ bbepRectangle(pBBEP, x+r, y, w-(2*r), r, iColor, 1);
+ bbepRectangle(pBBEP, x, y+r, w, h-(2*r), iColor, 1);
+ bbepRectangle(pBBEP, x+r, y+h-r, w-(2*r), r, iColor, 1);
+ // draw four corners
+ bbepEllipse(pBBEP, x+w-r-1, y+r, r, r, 1, iColor, 1);
+ bbepEllipse(pBBEP, x+r, y+r, r, r, 2, iColor, 1);
+ bbepEllipse(pBBEP, x+w-r-1, y+h-r, r, r, 1, iColor, 1);
+ bbepEllipse(pBBEP, x+r, y+h-r, r, r, 2, iColor, 1);
+ } else {
+ bbepDrawLine(pBBEP, x+r, y, x+w-r, y, iColor); // top
+ bbepDrawLine(pBBEP, x+r, y+h-1, x+w-r, y+h-1, iColor); // bottom
+ bbepDrawLine(pBBEP, x, y+r, x, y+h-r, iColor); // left
+ bbepDrawLine(pBBEP, x+w-1, y+r, x+w-1, y+h-r, iColor); // right
+ // four corners
+ bbepEllipse(pBBEP, x+r, y+r, r, r, 1, iColor, 0);
+ bbepEllipse(pBBEP, x+w-r-1, y+r, r, r, 2, iColor, 0);
+ bbepEllipse(pBBEP, x+w-r-1, y+h-r-1, r, r, 4, iColor, 0);
+ bbepEllipse(pBBEP, x+r, y+h-r-1, r, r, 8, iColor, 0);
+ }
+} /* bbepRoundRect() */
+
#endif // __BB_EP_GFX__
diff --git a/src/bb_epaper.cpp b/src/bb_epaper.cpp
index 75975ab..182d261 100644
--- a/src/bb_epaper.cpp
+++ b/src/bb_epaper.cpp
@@ -428,19 +428,19 @@ int16_t BBEPAPER::height(void)
}
void BBEPAPER::drawCircle(int32_t x, int32_t y, int32_t r, uint32_t color)
{
- bbepEllipse(&_bbep, x, y, r, r, color, 0);
+ bbepEllipse(&_bbep, x, y, r, r, 0xf, color, 0);
}
void BBEPAPER::fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color)
{
- bbepEllipse(&_bbep, x, y, r, r, color, 1);
+ bbepEllipse(&_bbep, x, y, r, r, 0xf, color, 1);
}
void BBEPAPER::drawEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color)
{
- bbepEllipse(&_bbep, x, y, rx, ry, color, 0);
+ bbepEllipse(&_bbep, x, y, rx, ry, 0xf, color, 0);
}
void BBEPAPER::fillEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color)
{
- bbepEllipse(&_bbep, x, y, rx, ry, color, 1);
+ bbepEllipse(&_bbep, x, y, rx, ry, 0xf, color, 1);
}
void BBEPAPER::sleep(int bDeep)
@@ -492,4 +492,15 @@ void BBEPAPER::writeCmd(uint8_t u8Cmd)
bbepWriteCmd(&_bbep, u8Cmd);
} /* writeCmd() */
+void BBEPAPER::drawRoundRect(int x, int y, int w, int h,
+ int r, uint8_t color)
+{
+ bbepRoundRect(&_bbep, x, y, w, h, r, color, 0);
+}
+void BBEPAPER::fillRoundRect(int x, int y, int w, int h,
+ int r, uint8_t color)
+{
+ bbepRoundRect(&_bbep, x, y, w, h, r, color, 1);
+}
+
#endif // __cplusplus
diff --git a/src/bb_epaper.h b/src/bb_epaper.h
index 729e561..c3954fc 100644
--- a/src/bb_epaper.h
+++ b/src/bb_epaper.h
@@ -301,6 +301,10 @@ class BBEPAPER
uint32_t capabilities();
void setRotation(int iAngle);
int getRotation(void);
+ void drawRoundRect(int x, int y, int w, int h,
+ int r, uint8_t color);
+ void fillRoundRect(int x, int y, int w, int h,
+ int r, uint8_t color);
void fillScreen(int iColor, int iPlane = PLANE_DUPLICATE);
void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);