v1.1.1
authorKevin Townsend <kevin@ktownsend.com>
Tue, 10 Apr 2012 13:43:40 +0000 (15:43 +0200)
committerKevin Townsend <kevin@ktownsend.com>
Tue, 10 Apr 2012 13:43:40 +0000 (15:43 +0200)
ChangeLog.txt
build/crossworks/LPC1343_CodeBase.hzs
drivers/displays/tft/controls/button.c
drivers/displays/tft/controls/progressbar.c
drivers/displays/tft/drawing.c
drivers/displays/tft/drawing.h
main.c
project/cmd_tbl.h
project/commands/drawing/cmd_rectangle.c

index 9f7f7da..5470fc1 100644 (file)
@@ -1,3 +1,12 @@
+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
@@ -21,7 +30,7 @@ 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
index 430ec20..8af0be3 100644 (file)
   <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>
@@ -63,7 +59,7 @@
   <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>
index a3de42c..db29382 100644 (file)
 /**************************************************************************/
 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];
 
@@ -66,19 +74,11 @@ void buttonRender(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint1
     // 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)
     {
index 8a46d21..3c0c061 100644 (file)
@@ -79,11 +79,8 @@ void progressbarRender(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
   // 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);
@@ -91,6 +88,10 @@ void progressbarRender(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
   // 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);
   }
index 924c115..52cf1b7 100644 (file)
@@ -732,6 +732,119 @@ void drawRectangleFilled ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, u
   }
 }
 
+/**************************************************************************/
+/*!
+    @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
index 3b3257b..432c7d3 100644 (file)
@@ -85,6 +85,7 @@ void      drawCornerFilled     ( uint16_t xCenter, uint16_t yCenter, uint16_t ra
 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 );
diff --git a/main.c b/main.c
index bb2c280..3d91f4d 100644 (file)
--- a/main.c
+++ b/main.c
   #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
index c305d07..b240cbe 100644 (file)
@@ -133,7 +133,7 @@ cmd_t cmd_tbl[] =
   { "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]>]'" },
index 05f039d..d35eafa 100644 (file)
@@ -101,7 +101,8 @@ void cmd_rectangle(uint8_t argc, char **argv)
 /**************************************************************************/
 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);
@@ -111,6 +112,19 @@ void cmd_rectangleround(uint8_t argc, char **argv)
   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)
@@ -119,13 +133,15 @@ void cmd_rectangleround(uint8_t argc, char **argv)
     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);
   }
 }
 
This page took 0.042335 seconds and 4 git commands to generate.