[wip] working on display graph
This commit is contained in:
@@ -44,6 +44,31 @@ void DISP_drawPixel(GFX_display_t *disp, uint8_t x, uint8_t y, GFX_Color_t color
|
||||
break;
|
||||
}
|
||||
}
|
||||
void DISP_drawBitmapSlow(GFX_display_t *disp, const GFX_bitmap_t *bitmap, uint8_t x, uint8_t y)
|
||||
{
|
||||
uint8_t row_div_by_8 = 0;
|
||||
uint8_t mask = 0;
|
||||
uint8_t bitmap_byte = 0;
|
||||
|
||||
for (uint8_t row = 0; row < bitmap->height; row++)
|
||||
{
|
||||
row_div_by_8 = row / 8;
|
||||
mask = (row % 8);
|
||||
for (uint8_t col = 0; col < bitmap->width; col++)
|
||||
{
|
||||
|
||||
bitmap_byte = bitmap->bitmap[row_div_by_8 * bitmap->width + col];
|
||||
if (bitmap_byte & (1 << mask))
|
||||
{
|
||||
DISP_drawPixel(disp, col + x, row + y, GFX_WHITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
DISP_drawPixel(disp, col + x, row + y, GFX_BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Draw a vertical line.
|
||||
@@ -97,7 +122,7 @@ void DISP_drawSlashLine(GFX_display_t *disp, int16_t x0, int16_t y0, int16_t x1,
|
||||
/**
|
||||
* @brief Write a perfectly vertical line
|
||||
* @param disp A pointer to display struct
|
||||
* @param x Top-most x coordinate
|
||||
* @param x Left-most x coordinate
|
||||
* @param y Top-most y coordinate
|
||||
* @param height Height in pixels
|
||||
* @param color Color of pixel WHITE(0), BLACK(1) or INVERSE(2)
|
||||
@@ -114,11 +139,11 @@ void DISP_drawVerticalLine(GFX_display_t *disp, int16_t x, int16_t y, int16_t he
|
||||
@brief Write a perfectly horizontal line
|
||||
@param disp A pointer to display struct
|
||||
@param x Left-most x coordinate
|
||||
@param y Left-most y coordinate
|
||||
@param y Top-most y coordinate
|
||||
@param width Width in pixels
|
||||
@param color Color of pixel WHITE(0), BLACK(1) or INVERSE(2)
|
||||
*/
|
||||
void DISP_drawHorizontalLine(GFX_display_t *disp, int16_t x, int16_t y, int16_t width, GFX_Color_t color)
|
||||
void DISP_drawHorizontalLine(GFX_display_t *disp, uint8_t x, uint8_t y, uint8_t width, GFX_Color_t color)
|
||||
{
|
||||
for (int16_t i = x; i < x + width; i++)
|
||||
{
|
||||
@@ -396,6 +421,56 @@ void DISP_drawBitmap(GFX_display_t *disp, const GFX_bitmap_t *bitmap, int8_t pos
|
||||
}
|
||||
}
|
||||
|
||||
void DISP_drawBitmapShift(GFX_display_t *disp, const GFX_bitmap_t *bitmap, int8_t pos_x, int8_t pos_y, uint8_t shift_left, GFX_BitmapColor_t color)
|
||||
{
|
||||
if (bitmap->width + pos_x < 0 || bitmap->height + pos_y < 0)
|
||||
return;
|
||||
|
||||
uint16_t tmp_buf16, bitmap_idx, buf_idx;
|
||||
uint8_t tmp_bitmap, bitmap_row;
|
||||
|
||||
buf_bitmap_boundry_t b;
|
||||
_getBoundry(disp, &b, bitmap->width, bitmap->height, pos_x, pos_y);
|
||||
|
||||
b.bitmap_col = (b.bitmap_col + shift_left) % bitmap->width;
|
||||
for (uint8_t col = b.buf_col_first; col < b.buf_col_last; col++, b.bitmap_col = (b.bitmap_col + 1) % bitmap->width)
|
||||
{
|
||||
tmp_buf16 = 0;
|
||||
bitmap_row = b.bitmap_row_first;
|
||||
|
||||
if (b.bitmap_row_first > 0)
|
||||
{
|
||||
tmp_buf16 = _getBitmapByte(bitmap->bitmap, bitmap->width * (b.bitmap_row_first - 1) + b.bitmap_col, color) >> (8 - b.bitmap_shift);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_buf16 = disp->buffor[b.buf_row_first * disp->width + col] & b.buf_mask_top;
|
||||
}
|
||||
|
||||
for (uint8_t buf_row = b.buf_row_first; buf_row < b.buf_row_last; buf_row++, bitmap_row++)
|
||||
{
|
||||
bitmap_idx = bitmap->width * bitmap_row + b.bitmap_col;
|
||||
buf_idx = buf_row * disp->width + col;
|
||||
|
||||
if (bitmap_idx < b.bitmap_max_idx)
|
||||
{
|
||||
tmp_bitmap = _getBitmapByte(bitmap->bitmap, bitmap_idx, color);
|
||||
tmp_buf16 |= tmp_bitmap << b.bitmap_shift;
|
||||
}
|
||||
|
||||
if (b.bitmap_row_last == buf_row)
|
||||
{
|
||||
disp->buffor[buf_idx] = (disp->buffor[buf_idx] & b.buf_mask_bottom) | (tmp_buf16 & ~(b.buf_mask_bottom));
|
||||
}
|
||||
else
|
||||
{
|
||||
disp->buffor[buf_idx] = (uint8_t)tmp_buf16;
|
||||
}
|
||||
tmp_buf16 = tmp_buf16 >> 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DISP_drawFillRect(GFX_display_t *disp, int16_t x, int16_t y, int16_t width, int16_t height)
|
||||
{
|
||||
GFX_bitmap_t area = {
|
||||
|
||||
@@ -51,7 +51,7 @@ typedef struct
|
||||
|
||||
void DISP_drawPixel(GFX_display_t *disp, uint8_t x, uint8_t y, GFX_Color_t color);
|
||||
void DISP_drawVerticalLine(GFX_display_t *disp, int16_t x, int16_t y, int16_t height, GFX_Color_t color);
|
||||
void DISP_drawHorizontalLine(GFX_display_t *disp, int16_t x, int16_t y, int16_t width, GFX_Color_t color);
|
||||
void DISP_drawHorizontalLine(GFX_display_t *disp, uint8_t x, uint8_t y, uint8_t width, GFX_Color_t color);
|
||||
void DISP_drawSlashLine(GFX_display_t *disp, int16_t x0, int16_t y0, int16_t x1, int16_t y1, GFX_Color_t color);
|
||||
void DISP_drawRect(GFX_display_t *disp, int16_t x, int16_t y, int16_t width, int16_t height, GFX_Color_t color);
|
||||
void DISP_drawFillRect(GFX_display_t *disp, int16_t x, int16_t y, int16_t width, int16_t height);
|
||||
@@ -59,5 +59,8 @@ void DISP_drawCircle(GFX_display_t *disp, int16_t x0, int16_t y0, uint8_t radius
|
||||
void DISP_drawQuarterCircle(GFX_display_t *disp, int16_t x0, int16_t y0, uint8_t radius, GFX_CircCorners_t corner, GFX_Color_t color);
|
||||
void DISP_drawRoundRect(GFX_display_t *disp, int16_t x, int16_t y, int16_t width, int16_t height, int16_t radius, GFX_Color_t color);
|
||||
void DISP_drawBitmap(GFX_display_t *disp, const GFX_bitmap_t *bitmap, int8_t pos_x, int8_t pos_y, GFX_BitmapColor_t color);
|
||||
void DISP_drawBitmapShift(GFX_display_t *disp, const GFX_bitmap_t *bitmap, int8_t pos_x, int8_t pos_y, uint8_t shift_left, GFX_BitmapColor_t color);
|
||||
void DISP_clearRegion(GFX_display_t *disp, int16_t x, int16_t y, int16_t width, int16_t height);
|
||||
void DISP_clearScreen(GFX_display_t *disp);
|
||||
|
||||
void DISP_drawBitmapSlow(GFX_display_t *disp, const GFX_bitmap_t *bitmap, uint8_t x, uint8_t y);
|
||||
|
||||
Reference in New Issue
Block a user