diff --git a/src/canvas/canvas.cpp b/src/canvas/canvas.cpp index f415cb2..29001a7 100644 --- a/src/canvas/canvas.cpp +++ b/src/canvas/canvas.cpp @@ -106,7 +106,7 @@ template void NanoCanvasOps::fillRect(const NanoRect &rect) fillRect(rect.p1.x, rect.p1.y, rect.p2.x, rect.p2.y); } -template void NanoCanvasOps::drawCircle(lcdint_t xc, lcdint_t yc, lcdint_t r) +template void NanoCanvasOps::drawCircle(lcdint_t xc, lcdint_t yc, lcdint_t r, uint8_t options) { if ( (xc + r < offset.x) || (yc + r < offset.y) || (xc - r >= (lcdint_t)m_w + offset.x) || (yc - r >= (lcdint_t)m_h - offset.y) ) @@ -117,10 +117,10 @@ template void NanoCanvasOps::drawCircle(lcdint_t xc, lcdint_t lcdint_t x = 0; lcdint_t y = r; - putPixel(xc, yc + r); - putPixel(xc, yc - r); - putPixel(xc + r, yc); - putPixel(xc - r, yc); + if (options & (2+4)) putPixel(xc, yc + r); + if (options & (1+8)) putPixel(xc, yc - r); + if (options & (1+2)) putPixel(xc + r, yc); + if (options & (4+8)) putPixel(xc - r, yc); while ( y >= x ) { x++; @@ -131,14 +131,14 @@ template void NanoCanvasOps::drawCircle(lcdint_t xc, lcdint_t } d += 4 * x + 6; - putPixel(xc + x, yc + y); - putPixel(xc - x, yc + y); - putPixel(xc + x, yc - y); - putPixel(xc - x, yc - y); - putPixel(xc + y, yc + x); - putPixel(xc - y, yc + x); - putPixel(xc + y, yc - x); - putPixel(xc - y, yc - x); + if (options & (2)) putPixel(xc + x, yc + y); + if (options & (4)) putPixel(xc - x, yc + y); + if (options & (1)) putPixel(xc + x, yc - y); + if (options & (8)) putPixel(xc - x, yc - y); + if (options & (2)) putPixel(xc + y, yc + x); + if (options & (4)) putPixel(xc - y, yc + x); + if (options & (1)) putPixel(xc + y, yc - x); + if (options & (8)) putPixel(xc - y, yc - x); } } diff --git a/src/canvas/canvas.h b/src/canvas/canvas.h index d99a285..85baf32 100644 --- a/src/canvas/canvas.h +++ b/src/canvas/canvas.h @@ -208,8 +208,9 @@ template class NanoCanvasOps * @param x horizontal position of circle center in pixels * @param y vertical position of circle center in pixels * @param r circle radius in pixels + * @param options - lower bits correspond to 4 setions, where 1 means to draw, 0 - no */ - void drawCircle(lcdint_t x, lcdint_t y, lcdint_t r) __attribute__((noinline)); + void drawCircle(lcdint_t x, lcdint_t y, lcdint_t r, uint8_t options = 0x0F) __attribute__((noinline)); /** * @brief Draws monochrome bitmap in color buffer using color, specified via setColor() method diff --git a/src/v2/lcd/base/display.h b/src/v2/lcd/base/display.h index 747a187..f25bc85 100644 --- a/src/v2/lcd/base/display.h +++ b/src/v2/lcd/base/display.h @@ -1040,8 +1040,9 @@ template class NanoDisplayOps: public O * @param xc horizontal position of circle center in pixels * @param yc vertical position of circle center in pixels * @param r radius of circle in pixels + * @param options draw specific sections: each bit corresponds to 90 degree section */ - void drawCircle(lcdint_t xc, lcdint_t yc, lcdint_t r); + void drawCircle(lcdint_t xc, lcdint_t yc, lcdint_t r, uint8_t options = 0x0F); /** * Draws 1-bit canvas on lcd display diff --git a/src/v2/lcd/base/ssd1306_common.inl b/src/v2/lcd/base/ssd1306_common.inl index b34f815..20333c5 100644 --- a/src/v2/lcd/base/ssd1306_common.inl +++ b/src/v2/lcd/base/ssd1306_common.inl @@ -591,15 +591,15 @@ template void NanoDisplayOps::fillRect(const NanoRect & this->fillRect(rect.p1.x, rect.p1.y, rect.p2.x, rect.p2.y); } -template void NanoDisplayOps::drawCircle(lcdint_t xc, lcdint_t yc, lcdint_t r) +template void NanoDisplayOps::drawCircle(lcdint_t xc, lcdint_t yc, lcdint_t r, uint8_t options) { lcdint_t d = 3 - 2 * r; lcdint_t x = 0; lcdint_t y = r; - putPixel(xc, yc + r); - putPixel(xc, yc - r); - putPixel(xc + r, yc); - putPixel(xc - r, yc); + if (options & (2 + 4)) putPixel(xc, yc + r); + if (options & (1 + 8)) putPixel(xc, yc - r); + if (options & (1 + 2)) putPixel(xc + r, yc); + if (options & (4 + 8)) putPixel(xc - r, yc); while ( y >= x ) { x++; @@ -609,14 +609,14 @@ template void NanoDisplayOps::drawCircle(lcdint_t xc, l d += -4 * y + 4; } d += 4 * x + 6; - putPixel(xc + x, yc + y); - putPixel(xc - x, yc + y); - putPixel(xc + x, yc - y); - putPixel(xc - x, yc - y); - putPixel(xc + y, yc + x); - putPixel(xc - y, yc + x); - putPixel(xc + y, yc - x); - putPixel(xc - y, yc - x); + if (options & (2)) putPixel(xc + x, yc + y); + if (options & (4)) putPixel(xc - x, yc + y); + if (options & (1)) putPixel(xc + x, yc - y); + if (options & (8)) putPixel(xc - x, yc - y); + if (options & (2)) putPixel(xc + y, yc + x); + if (options & (4)) putPixel(xc - y, yc + x); + if (options & (1)) putPixel(xc + y, yc - x); + if (options & (8)) putPixel(xc - y, yc - x); } }