added _ssd1306_circle function

This commit is contained in:
nopnop2002 2024-06-29 06:58:05 +09:00
parent 37977a6ebe
commit 9d45b006a8
2 changed files with 22 additions and 0 deletions

View File

@ -528,6 +528,27 @@ void _ssd1306_line(SSD1306_t * dev, int x1, int y1, int x2, int y2, bool invert
} }
} }
// Draw circle
void _ssd1306_circle(SSD1306_t * dev, int x0, int y0, int r, bool invert)
{
int x;
int y;
int err;
int old_err;
x=0;
y=-r;
err=2-2*r;
do{
_ssd1306_pixel(dev, x0-x, y0+y, invert);
_ssd1306_pixel(dev, x0-y, y0-x, invert);
_ssd1306_pixel(dev, x0+x, y0-y, invert);
_ssd1306_pixel(dev, x0+y, y0+x, invert);
if ((old_err=err)<=x) err+=++x*2+1;
if (old_err>y || err>x) err+=++y*2+1;
} while(y<0);
}
void ssd1306_invert(uint8_t *buf, size_t blen) void ssd1306_invert(uint8_t *buf, size_t blen)
{ {
uint8_t wk; uint8_t wk;

View File

@ -126,6 +126,7 @@ void ssd1306_wrap_arround(SSD1306_t * dev, ssd1306_scroll_type_t scroll, int sta
void ssd1306_bitmaps(SSD1306_t * dev, int xpos, int ypos, uint8_t * bitmap, int width, int height, bool invert); void ssd1306_bitmaps(SSD1306_t * dev, int xpos, int ypos, uint8_t * bitmap, int width, int height, bool invert);
void _ssd1306_pixel(SSD1306_t * dev, int xpos, int ypos, bool invert); void _ssd1306_pixel(SSD1306_t * dev, int xpos, int ypos, bool invert);
void _ssd1306_line(SSD1306_t * dev, int x1, int y1, int x2, int y2, bool invert); void _ssd1306_line(SSD1306_t * dev, int x1, int y1, int x2, int y2, bool invert);
void _ssd1306_circle(SSD1306_t * dev, int x0, int y0, int r, bool invert);
void ssd1306_invert(uint8_t *buf, size_t blen); void ssd1306_invert(uint8_t *buf, size_t blen);
void ssd1306_flip(uint8_t *buf, size_t blen); void ssd1306_flip(uint8_t *buf, size_t blen);
uint8_t ssd1306_copy_bit(uint8_t src, int srcBits, uint8_t dst, int dstBits); uint8_t ssd1306_copy_bit(uint8_t src, int srcBits, uint8_t dst, int dstBits);