+v1.1.1 - Ongoing
+==============================================================================
+NEW FEATURES
+------------------------------------------------------------------------------
+- Added drawRoundedRectangle to drawing.c
+- Added ability to select filled or empty rounded rectangles to the 'R' CLI
+ command
+
+
v1.1.0 - 9 April 2012
==============================================================================
BREAKING CHANGES
NEW FEATURES
------------------------------------------------------------------------------
-- Added drawCorner to graphics.c
+- Added drawCorner to drawing.c
- Added new 'controls/' folder to the GFX library, and added a number of
controls that will render correctly with the theme settings, as well as
using bitmap or anti-aliased fonts, depending on projectconfig.h
<ProjectSessionItem path="LPC1343_CodeBase" name="unnamed" />
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase" name="unnamed" />
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files" name="unnamed" />
- <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers" name="unnamed" />
- <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;displays" name="unnamed" />
- <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;displays;tft" name="unnamed" />
- <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;displays;tft;controls" name="unnamed" />
</Project>
<Register1>
<RegisterWindow openNodes="GPIO2" binaryNodes="" hiddenNodes="" unsignedNodes="" visibleGroups="CPU;CoreDebug;GPIO2" decimalNodes="" octalNodes="" asciiNodes="" />
</TraceWindow>
<Watch1>
<Watches active="1" update="Each Second" >
- <Watchpoint linenumber="66" radix="10" name="msTicks" expression="msTicks" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/systick/systick.c" />
- <Watchpoint linenumber="138" radix="16" name="timer32_0_counter" expression="timer32_0_counter" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/timer32/timer32.c" />
- <Watchpoint linenumber="155" radix="-1" name="xTickCount" expression="xTickCount" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/freertos/tasks.c" />
<Watchpoint linenumber="155" radix="16" name="Tick" expression="Tick" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/freertos/tasks.c" />
+ <Watchpoint linenumber="155" radix="-1" name="xTickCount" expression="xTickCount" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/freertos/tasks.c" />
+ <Watchpoint linenumber="138" radix="16" name="timer32_0_counter" expression="timer32_0_counter" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/timer32/timer32.c" />
+ <Watchpoint linenumber="66" radix="10" name="msTicks" expression="msTicks" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/systick/systick.c" />
</Watches>
</Watch1>
<Watch2>
<Watches active="0" update="Never" />
</Watch4>
<Files>
- <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="27" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="42" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="30" />
+ <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="15" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="59" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="3" />
</Files>
- <ARMCrossStudioWindow activeProject="LPC1343_CodeBase" autoConnectTarget="SEGGER J-Link" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\drivers\displays\tft" fileDialogDefaultFilter="" autoConnectCapabilities="388991" debugSearchPath="" buildConfiguration="THUMB Flash Release" />
+ <ARMCrossStudioWindow activeProject="LPC1343_CodeBase" autoConnectTarget="SEGGER J-Link" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\drivers\displays\tft" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388991" debugSearchPath="" buildConfiguration="THUMB Flash Release" />
</session>
/**************************************************************************/
void buttonRender(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t fontColor, char *text, theme_t theme)
{
+ uint16_t brighter, darker;
+ uint16_t buttonEnd;
+
+ // Draw background gradient then outline
+ drawGradient(x+2, y+2, x+width-2, y+height-2, theme.colorFill, theme.colorBorder);
+ drawRoundedRectangle(x+1, y+1, x+width-1, y+height-1, theme.colorFill, 5, DRAW_CORNERS_ALL);
+ drawRoundedRectangle(x, y, x+width, y+height, theme.colorBorderDarker, 5, DRAW_CORNERS_ALL);
+
#if CFG_TFTLCD_USEAAFONTS
uint16_t ctable[4];
// This should really be optimized out into theme.h!
aafontsCalculateColorTable(theme.colorFill, fontColor, &ctable[0], 4);
- // Draw the primitive shapes for the button
- drawRoundedRectangleFilled(x, y, x+width, y+height, theme.colorBorder, 5, DRAW_CORNERS_ALL);
- drawRoundedRectangleFilled(x+1, y+1, x+width-1, y+height-1, theme.colorFill, 5, DRAW_CORNERS_ALL);
-
if (text != NULL)
{
aafontsCenterString(x + width / 2, y + 1 + (height / 2) - (THEME_FONT.fontHeight / 2), ctable, &THEME_FONT, text);
}
#else
- // Draw the primitive shapes for the button
- drawRoundedRectangleFilled(x, y, x+width, y+height, theme.colorBorder, 5, DRAW_CORNERS_ALL);
- drawRoundedRectangleFilled(x+1, y+1, x+width-1, y+height-1, theme.colorFill, 5, DRAW_CORNERS_ALL);
-
// Render text
if (text != NULL)
{
// Make sure we don't end up in negative territory with really small values
if (progressEnd < x + 2) progressEnd = x+2;
- // Calculate slightly brighter and darker colors for the border and gradient
- brighter = colorsAlphaBlend(COLOR_WHITE, color, 50);
- darker = colorsAlphaBlend(COLOR_BLACK, color, 35);
-
// Draw the outline and background gradient
+ // This needs to be square to avoid flickering with rapid updates :/
drawRectangle(x, y, x+width, y+height, theme.colorBorderDarker);
drawRectangle(x+1, y+1, x+width-1, y+height-1, theme.colorFill);
drawGradient(progressEnd+1, y+2, x+width-2, y+height-2, theme.colorFill, theme.colorBorder);
// Draw the progress gradient if required
if (progress)
{
+ // Calculate slightly brighter and darker colors for the border and gradient
+ brighter = colorsAlphaBlend(COLOR_WHITE, color, 50);
+ darker = colorsAlphaBlend(COLOR_BLACK, color, 35);
+ // Draw border rectangle and gradient fill
drawRectangle(x+2, y+2, progressEnd, y+height-2, darker);
drawGradient(x+3, y+3, progressEnd-1, y+height-3, brighter, color);
}
}
}
+/**************************************************************************/
+/*!
+ @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
void drawArrow ( uint16_t x, uint16_t y, uint16_t size, drawDirection_t, uint16_t color );
void drawRectangle ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color );
void drawRectangleFilled ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color );
+void drawRoundedRectangle ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color, uint16_t radius, drawCorners_t corners );
void drawRoundedRectangleFilled ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color, uint16_t radius, drawCorners_t corners );
void drawGradient ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t startColor, uint16_t endColor );
void drawTriangle ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color );
#include "core/cmd/cmd.h"
#endif
+#include "drivers/displays/tft/lcd.h"
+#include "drivers/displays/tft/drawing.h"
+#include "drivers/displays/tft/touchscreen.h"
+#include "drivers/displays/tft/controls/button.h"
+
/**************************************************************************/
/*!
Main program entry point. After reset, normal code execution will
{ "p", 3, 3, 0, cmd_pixel , "Draw Pixel" , "'p <x> <y> <color>'" },
{ "P", 6, 6, 0, cmd_progress , "Progress Bar" , "'P <x> <y> <w> <h> <%> <barclr>'" },
{ "r", 5, 7, 0, cmd_rectangle , "Rectangle" , "'r <x1> <y1> <x2> <y2> <color> [<filled[0|1]> <bcolor>]'" },
- { "R", 7, 7, 0, cmd_rectangleround , "Rounded Rectangle" , "'R <x1> <y1> <x2> <y2> <color> <radius> <corners>'" },
+ { "R", 7, 9, 0, cmd_rectangleround , "Rounded Rectangle" , "'R <x1> <y1> <x2> <y2> <color> <radius> <corners> [<filled[0|1]> <bcolor>]'" },
{ "s", 2, 99, 0, cmd_textw , "Text Width" , "'s <font#> <msg>'" },
{ "t", 6, 99, 0, cmd_text , "Text" , "'t <x> <y> <bgcolor> <fontcolor> <font#> <msg>'" },
{ "v", 7, 8, 0, cmd_triangle , "Triangle" , "'v <x1> <y1> <x2> <y2> <x3> <y3> <color> [<filled[0|1]>]'" },
/**************************************************************************/
void cmd_rectangleround(uint8_t argc, char **argv)
{
- int32_t x1, y1, x2, y2, c, radius, corners;
+ int32_t x1, y1, x2, y2, c, radius, corners, filled, border;
+ filled = 0;
// Convert supplied parameters
getNumber (argv[0], &x1);
getNumber (argv[4], &c);
getNumber (argv[5], &radius);
getNumber (argv[6], &corners);
+ if (argc >= 8)
+ {
+ getNumber (argv[7], &filled);
+ }
+ if (argc == 9)
+ {
+ getNumber (argv[8], &border);
+ if (border < 0 || border > 0xFFFF)
+ {
+ printf("Invalid Border Color%s", CFG_PRINTF_NEWLINE);
+ return;
+ }
+ }
// ToDo: Validate data!
if (c < 0 || c > 0xFFFF)
return;
}
- if ((radius == 0) || (corners == 0) || (corners > 5))
- {
- drawRectangleFilled(x1, y1, x2, y2, (uint16_t)c);
- }
+ if (filled)
+ drawRoundedRectangleFilled(x1, y1, x2, y2, (uint16_t)c, radius, corners);
else
+ drawRoundedRectangle(x1, y1, x2, y2, (uint16_t)c, radius, corners);
+
+ // Draw border if it's not the same color
+ if (argc == 9)
{
- drawRoundedRectangleFilled(x1, y1, x2, y2, (uint16_t)c, radius, corners);
+ drawRoundedRectangle(x1, y1, x2, y2, (uint16_t)border, radius, corners);
}
}