{
uint8_t bit = 0x00;
bit = (column[xoffset] << (8 - (yoffset + 1))); // Shift current row bit left
- bit = (bit >> 7); // Shift current row but right (results in 0x01 for black, and 0x00 for white)
+ bit = (bit >> 7); // Shift current row bit right (results in 0x01 for black, and 0x00 for white)
if (bit)
{
drawPixel(x + xoffset, y + yoffset, color);
/**************************************************************************/
void drawLineDotted ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t empty, uint16_t solid, uint16_t color )
{
+ lcdProperties_t properties;
+
+ // Get the LCD properties (to check for HW acceleration in the driver)
+ properties = lcdGetProperties();
+
if (solid == 0)
{
return;
y1 = y1 > 65000 ? 0 : y1;
// Check if we can use the optimised horizontal line method
- if ((y0 == y1) && (empty == 0))
+ if ((y0 == y1) && (empty == 0) && properties.fastHLine)
{
lcdDrawHLine(x0, x1, y0, color);
return;
// Check if we can use the optimised vertical line method.
// This can make a huge difference in performance, but may
// not work properly on every LCD controller:
- if ((x0 == x1) && (empty == 0))
+ if ((x0 == x1) && (empty == 0) && properties.fastVLine)
{
// Warning: This may actually be slower than drawing individual pixels on
// short lines ... Set a minimum line size to use the 'optimised' method
}
}
+/**************************************************************************/
+/*!
+ @brief Draws a rectangle with rounded corners
+
+ @param[in] x0
+ Starting x co-ordinate
+ @param[in] y0
+ Starting y co-ordinate
+ @param[in] x1
+ Ending x co-ordinate
+ @param[in] y1
+ Ending y co-ordinate
+ @param[in] color
+ Color used when drawing
+ @param[in] radius
+ Corner radius in pixels
+ @param[in] corners
+ Which corners to round
+
+ @section EXAMPLE
+ @code
+
+ drawRoundedRectangle ( 10, 10, 200, 200, COLOR_BLACK, 10, DRAW_CORNERS_ALL );
+
+ @endcode
+
+*/
+/**************************************************************************/
+void drawRoundedRectangle ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color, uint16_t radius, drawCorners_t corners )
+{
+ int height;
+ uint16_t y;
+
+ if (corners == DRAW_CORNERS_NONE)
+ {
+ drawRectangle(x0, y0, x1, y1, color);
+ return;
+ }
+
+ // Calculate height
+ if (y1 < y0)
+ {
+ y = y1;
+ y1 = y0;
+ y0 = y;
+ }
+ height = y1 - y0;
+
+ // Check radius
+ if (radius > height / 2)
+ {
+ radius = height / 2;
+ }
+ radius -= 1;
+
+ switch (corners)
+ {
+ case DRAW_CORNERS_ALL:
+ drawCorner(x0 + radius, y0 + radius, radius, DRAW_CORNERS_TOPLEFT, color);
+ drawCorner(x1 - radius, y0 + radius, radius, DRAW_CORNERS_TOPRIGHT, color);
+ drawCorner(x0 + radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMLEFT, color);
+ drawCorner(x1 - radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMRIGHT, color);
+ if (radius*2+1 < height)
+ {
+ drawLine(x0, y0+radius, x0, y1-radius, color);
+ drawLine(x1, y0+radius, x1, y1-radius, color);
+ }
+ drawLine(x0+radius, y0, x1-radius, y0, color);
+ drawLine(x0+radius, y1, x1-radius, y1, color);
+ break;
+ case DRAW_CORNERS_TOP:
+ drawCorner(x0 + radius, y0 + radius, radius, DRAW_CORNERS_TOPLEFT, color);
+ drawCorner(x1 - radius, y0 + radius, radius, DRAW_CORNERS_TOPRIGHT, color);
+ drawLine(x0, y0+radius, x0, y1, color);
+ drawLine(x0, y1, x1, y1, color);
+ drawLine(x1, y1, x1, y0+radius, color);
+ drawLine(x0+radius, y0, x1-radius, y0, color);
+ break;
+ case DRAW_CORNERS_BOTTOM:
+ drawCorner(x0 + radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMLEFT, color);
+ drawCorner(x1 - radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMRIGHT, color);
+ drawLine(x0, y0, x1, y0, color);
+ drawLine(x1, y0, x1, y1-radius, color );
+ drawLine(x1-radius, y1, x0+radius, y1, color);
+ drawLine(x0, y1-radius, x0, y0, color);
+ break;
+ case DRAW_CORNERS_LEFT:
+ drawCorner(x0 + radius, y0 + radius, radius, DRAW_CORNERS_TOPLEFT, color);
+ drawCorner(x0 + radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMLEFT, color);
+ if (radius*2+1 < height)
+ {
+ drawLine(x0, y0+radius, x0, y1-radius, color);
+ }
+ drawLine(x1, y0, x1, y1, color);
+ drawLine(x0+radius, y0, x1, y0, color);
+ drawLine(x0+radius, y1, x1, y1, color);
+ break;
+ case DRAW_CORNERS_RIGHT:
+ drawCorner(x1 - radius, y0 + radius, radius, DRAW_CORNERS_TOPRIGHT, color);
+ drawCorner(x1 - radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMRIGHT, color);
+ if (radius*2+1 < height)
+ {
+ drawLine(x1, y0+radius, x1, y1-radius, color);
+ }
+ drawLine(x0, y0, x0, y1, color);
+ drawLine(x0, y0, x1-radius, y0, color);
+ drawLine(x0, y1, x1-radius, y1, color);
+ break;
+ default:
+ break;
+ }
+}
+
/**************************************************************************/
/*!
@brief Draws a filled rectangle with rounded corners