Skip to content

Commit

Permalink
Merge pull request #16 from maro159/main
Browse files Browse the repository at this point in the history
Add ssd1306_clear_square function
  • Loading branch information
daschr authored Dec 15, 2023
2 parents df5bf00 + 85614b1 commit 8467f5b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ssd1306.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,16 @@ void ssd1306_draw_line(ssd1306_t *p, int32_t x1, int32_t y1, int32_t x2, int32_t
}
}

void ssd1306_clear_square(ssd1306_t *p, uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
for(uint32_t i=0; i<width; ++i)
for(uint32_t j=0; j<height; ++j)
ssd1306_clear_pixel(p, x+i, y+j);
}

void ssd1306_draw_square(ssd1306_t *p, uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
for(uint32_t i=0; i<width; ++i)
for(uint32_t j=0; j<height; ++j)
ssd1306_draw_pixel(p, x+i, y+j);

}

void ssd1306_draw_empty_square(ssd1306_t *p, uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
Expand Down
13 changes: 12 additions & 1 deletion ssd1306.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void ssd1306_clear_pixel(ssd1306_t *p, uint32_t x, uint32_t y);
void ssd1306_draw_pixel(ssd1306_t *p, uint32_t x, uint32_t y);

/**
@brief draw pixel on buffer
@brief draw line on buffer
@param[in] p : instance of display
@param[in] x1 : x position of starting point
Expand All @@ -172,6 +172,17 @@ void ssd1306_draw_pixel(ssd1306_t *p, uint32_t x, uint32_t y);
*/
void ssd1306_draw_line(ssd1306_t *p, int32_t x1, int32_t y1, int32_t x2, int32_t y2);

/**
@brief clear square at given position with given size
@param[in] p : instance of display
@param[in] x : x position of starting point
@param[in] y : y position of starting point
@param[in] width : width of square
@param[in] height : height of square
*/
void ssd1306_clear_square(ssd1306_t *p, uint32_t x, uint32_t y, uint32_t width, uint32_t height);

/**
@brief draw filled square at given position with given size
Expand Down

0 comments on commit 8467f5b

Please sign in to comment.