- Added initial version of Hierarchical Menu
- Beautified the Message Box a bit
This commit is contained in:
@@ -45,11 +45,6 @@ static dma_channel_config _DMA_Config_Drawing;
|
||||
void Display_Shapes_Draw_Rounded_Rect_Frame_1 (int16_t x, int16_t y, uint16_t width, uint16_t height, uint16_t radius, Display_Color color);
|
||||
void Display_Shapes_Draw_Circle_Frame_1 (int16_t center_x, int16_t center_y, uint16_t radius, Display_Color color);
|
||||
|
||||
void Display_Shapes_Draw_Circle_Helper(int16_t x0, int16_t y0, uint16_t radius, uint16_t thickness, uint8_t cornername, Display_Color color);
|
||||
void Display_Shapes_Draw_Circle_Helper_Improved(int16_t x0, int16_t y0, uint16_t radius, uint16_t thickness, uint8_t cornername, Display_Color color);
|
||||
void Display_Shapes_Draw_Circle_Helper_Single_Pixel(int16_t x0, int16_t y0, uint16_t radius, uint8_t cornername, Display_Color color);
|
||||
void Display_Shapes_Draw_Circle_Helper_Filled(int16_t x0, int16_t y0, uint16_t radius, uint8_t corners, int16_t delta, Display_Color color);
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
Functions
|
||||
@@ -84,7 +79,8 @@ void Display_Shapes_Fill_Screen(Display_Color color)
|
||||
|
||||
void Display_Shapes_Draw_Pixel_Safe(int16_t x, int16_t y, Display_Color color)
|
||||
{
|
||||
if(x >= 0 && x < DISPLAY_WIDTH && y >= 0 && y < DISPLAY_HEIGHT)
|
||||
// Cast to uint16_t purpose to reduce the amount of comparisions required
|
||||
if((uint16_t)x < DISPLAY_WIDTH && (uint16_t)y < DISPLAY_HEIGHT)
|
||||
{
|
||||
(*_Current_Buffer)->Dim_2[y][x] = color;
|
||||
}
|
||||
@@ -722,189 +718,4 @@ void Display_Shapes_Draw_Circle_Frame_1(int16_t center_x, int16_t center_y, uint
|
||||
|
||||
Last_X = Data[i];
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Quarter-circle drawer, used to do circles and roundrects
|
||||
@param x0 Center-point x coordinate
|
||||
@param y0 Center-point y coordinate
|
||||
@param r Radius of circle
|
||||
@param cornername Mask bit #1 or bit #2 to indicate which quarters of the circle we're doing
|
||||
@param color 16-bit 5-6-5 Color to draw with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Display_Shapes_Draw_Circle_Helper(int16_t x0, int16_t y0, uint16_t radius, uint16_t thickness, uint8_t cornername, Display_Color color)
|
||||
{
|
||||
int16_t f = 1 - radius;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * radius;
|
||||
int16_t x = 0;
|
||||
int16_t y = radius;
|
||||
|
||||
while (x < y)
|
||||
{
|
||||
if (f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
if (cornername & CORNER_BOTTOM_RIGHT)
|
||||
{
|
||||
Display_Shapes_Draw_Circle_Filled(x0 + x, y0 + y, thickness >> 1, color);
|
||||
Display_Shapes_Draw_Circle_Filled(x0 + y, y0 + x, thickness >> 1, color);
|
||||
}
|
||||
|
||||
if (cornername & CORNER_TOP_RIGHT)
|
||||
{
|
||||
Display_Shapes_Draw_Circle_Filled(x0 + x, y0 - y, thickness >> 1, color);
|
||||
Display_Shapes_Draw_Circle_Filled(x0 + y, y0 - x, thickness >> 1, color);
|
||||
}
|
||||
|
||||
if (cornername & CORNER_BOTTOM_LEFT)
|
||||
{
|
||||
Display_Shapes_Draw_Circle_Filled(x0 - x, y0 + y, thickness >> 1, color);
|
||||
Display_Shapes_Draw_Circle_Filled(x0 - y, y0 + x, thickness >> 1, color);
|
||||
}
|
||||
|
||||
if (cornername & CORNER_TOP_LEFT)
|
||||
{
|
||||
Display_Shapes_Draw_Circle_Filled(x0 - x, y0 - y, thickness >> 1, color);
|
||||
Display_Shapes_Draw_Circle_Filled(x0 - y, y0 - x, thickness >> 1, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Display_Shapes_Draw_Circle_Helper_Improved(int16_t x0, int16_t y0, uint16_t radius, uint16_t thickness, uint8_t cornername, Display_Color color)
|
||||
{
|
||||
if (radius == 0) return;
|
||||
|
||||
// For thickness of 1, use single pixel drawing
|
||||
if (thickness == 1) {
|
||||
Display_Shapes_Draw_Circle_Helper_Single_Pixel(x0, y0, radius, cornername, color);
|
||||
return;
|
||||
}
|
||||
|
||||
// For thicker lines, draw multiple concentric quarter-circles
|
||||
// This ensures consistent thickness with the straight edges
|
||||
for (uint16_t t = 0; t < thickness; t++) {
|
||||
uint16_t current_radius = radius - t;
|
||||
if (current_radius == 0) break;
|
||||
|
||||
Display_Shapes_Draw_Circle_Helper_Single_Pixel(x0, y0, current_radius, cornername, color);
|
||||
}
|
||||
}
|
||||
|
||||
void Display_Shapes_Draw_Circle_Helper_Single_Pixel(int16_t x0, int16_t y0, uint16_t radius, uint8_t cornername, Display_Color color)
|
||||
{
|
||||
if (radius == 0) return;
|
||||
|
||||
// Use Bresenham's circle algorithm for single pixel drawing
|
||||
int16_t f = 1 - radius;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * radius;
|
||||
int16_t x = 0;
|
||||
int16_t y = radius;
|
||||
|
||||
while (x < y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
// Draw quarter-circle segments based on corner mask - single pixels only
|
||||
if (cornername & CORNER_TOP_LEFT) {
|
||||
Display_Shapes_Draw_Pixel_Safe(x0 - x, y0 - y, color);
|
||||
Display_Shapes_Draw_Pixel_Safe(x0 - y, y0 - x, color);
|
||||
}
|
||||
|
||||
if (cornername & CORNER_TOP_RIGHT) {
|
||||
Display_Shapes_Draw_Pixel_Safe(0 + x, y0 - y, color);
|
||||
Display_Shapes_Draw_Pixel_Safe(x0 + y, y0 - x, color);
|
||||
}
|
||||
|
||||
if (cornername & CORNER_BOTTOM_RIGHT) {
|
||||
Display_Shapes_Draw_Pixel_Safe(x0 + x, y0 + y, color);
|
||||
Display_Shapes_Draw_Pixel_Safe(x0 + y, y0 + x, color);
|
||||
}
|
||||
|
||||
if (cornername & CORNER_BOTTOM_LEFT) {
|
||||
Display_Shapes_Draw_Pixel_Safe(x0 - x, y0 + y, color);
|
||||
Display_Shapes_Draw_Pixel_Safe(x0 - y, y0 + x, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Quarter-circle drawer with fill, used for circles and roundrects
|
||||
@param x0 Center-point x coordinate
|
||||
@param y0 Center-point y coordinate
|
||||
@param r Radius of circle
|
||||
@param corners Mask bits indicating which quarters we're doing
|
||||
@param delta Offset from center-point, used for round-rects
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Display_Shapes_Draw_Circle_Helper_Filled(int16_t x0, int16_t y0, uint16_t radius, uint8_t corners, int16_t delta, Display_Color color)
|
||||
{
|
||||
int16_t f = 1 - radius;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * radius;
|
||||
int16_t x = 0;
|
||||
int16_t y = radius;
|
||||
int16_t px = x;
|
||||
int16_t py = y;
|
||||
|
||||
delta++; // Avoid some +1's in the loop
|
||||
|
||||
while (x < y)
|
||||
{
|
||||
if (f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
// These checks avoid double-drawing certain lines, important
|
||||
// for the SSD1306 library which has an INVERT drawing mode.
|
||||
if (x < (y + 1))
|
||||
{
|
||||
if (corners & CORNER_TOP_LEFT) {
|
||||
Display_Shapes_Draw_VLine(x0 + x, y0 - y, 2 * y + delta, 1, color);
|
||||
// writeFastVLine(x0 + x, y0 - y, 2 * y + delta, color);
|
||||
}
|
||||
if (corners & CORNER_TOP_RIGHT) {
|
||||
Display_Shapes_Draw_VLine(x0 - x, y0 - y, 2 * y + delta, 1, color);
|
||||
// writeFastVLine(x0 - x, y0 - y, 2 * y + delta, color);
|
||||
}
|
||||
}
|
||||
|
||||
if (y != py)
|
||||
{
|
||||
if (corners & CORNER_TOP_LEFT) {
|
||||
Display_Shapes_Draw_VLine(x0 + py, y0 - px, 2 * px + delta, 1, color);
|
||||
// writeFastVLine(x0 + py, y0 - px, 2 * px + delta, color);
|
||||
}
|
||||
if (corners & CORNER_TOP_RIGHT) {
|
||||
Display_Shapes_Draw_VLine(x0 - py, y0 - px, 2 * px + delta, 1, color);
|
||||
// writeFastVLine(x0 - py, y0 - px, 2 * px + delta, color);
|
||||
}
|
||||
py = y;
|
||||
}
|
||||
px = x;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user