Prep for v1.1.0
authorKevin Townsend <kevin@ktownsend.com>
Tue, 3 Apr 2012 21:34:05 +0000 (23:34 +0200)
committerKevin Townsend <kevin@ktownsend.com>
Tue, 3 Apr 2012 21:34:05 +0000 (23:34 +0200)
34 files changed:
ChangeLog.txt
Makefile
build/crossworks/LPC1343_CodeBase.hzp
build/crossworks/LPC1343_CodeBase.hzs
drivers/displays/tft/aafonts.c
drivers/displays/tft/aafonts.h
drivers/displays/tft/aafonts/aa2/DejaVuSansCondensedBold14_AA2.h
drivers/displays/tft/bmp.c
drivers/displays/tft/colors.c
drivers/displays/tft/colors.h
drivers/displays/tft/controls/button.c [new file with mode: 0644]
drivers/displays/tft/controls/button.h [new file with mode: 0644]
drivers/displays/tft/controls/hsbchart.c [new file with mode: 0644]
drivers/displays/tft/controls/hsbchart.h [new file with mode: 0644]
drivers/displays/tft/controls/huechart.c [new file with mode: 0644]
drivers/displays/tft/controls/huechart.h [new file with mode: 0644]
drivers/displays/tft/controls/label.c [new file with mode: 0644]
drivers/displays/tft/controls/label.h [new file with mode: 0644]
drivers/displays/tft/controls/labelcentered.c [new file with mode: 0644]
drivers/displays/tft/controls/labelcentered.h [new file with mode: 0644]
drivers/displays/tft/controls/progressbar.c [new file with mode: 0644]
drivers/displays/tft/controls/progressbar.h [new file with mode: 0644]
drivers/displays/tft/drawing.c
drivers/displays/tft/drawing.h
drivers/displays/tft/touchscreen.c
main.c
project/cmd_tbl.h
project/commands/drawing/cmd_bmp.c
project/commands/drawing/cmd_button.c
project/commands/drawing/cmd_progress.c
project/commands/drawing/cmd_rectangle.c
project/commands/drawing/cmd_text.c
project/commands/drawing/cmd_textw.c
projectconfig.h

index 0f05637..979788a 100644 (file)
@@ -1,5 +1,51 @@
+v1.1.0 - Ongoing
+==============================================================================
+BREAKING CHANGES
+------------------------------------------------------------------------------
+- Rewrote corner and rounded rectangle code.  Only one corner enum is now used
+  (drawCorners_t)
+- Renamed drawRectangleRounded to drawRoundedRectangleFilled
+- Removed drawProgressBar and drawButton from drawing.c, since drawing should
+  only contain drawing primitives
+- Reorganised a lot of the TFT drawing library to support external controls,
+  and dynamically switch between bitmap and anti-aliased fonts.  In the future
+  everything that isn't a basic drawing primitive will be placed in it's own
+  control.  The main benefit of this is that it's much easier to customize the
+  look and feel of your UI without having to modify drawing.c and the basic
+  drawing primitives, and to be able to switch from bitmap to anti-aliased
+  fonts depending on how much flash space you have free, etc.
+- Removed bmp_error_t drawBitmapImage(uint16_t x, uint16_t y, char *filename)
+  to keep better seperation of primitives and more complex features, and
+  reduce external dependencies in drawing.c.  Call bmpDrawImage (bmp.c)
+  directly instead.
+
+NEW FEATURES
+------------------------------------------------------------------------------
+- Added drawCorner to graphics.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
+- New controls:
+  - button
+  - hsbchart (Hue/saturation/brightness chart for color pickers)
+  - huechart (Hue selection gradient for color pickers)
+  - label
+  - labelcentered
+  - progressbar
+- Added theme.h to try to define all of the color and font settings used by
+  the controls in one location to make it easier to update or modify
+- Added aafontsCenterString to aafonts.c
+
+BUG FIXES/OPTIMISATION/ETC.
+------------------------------------------------------------------------------
+- Updated Crossworks Project to use LPC1000 Lib 1.19 (uses CMSIS 3.0)
+- Some performance improvements to core/gpio/gpio.c (thanks Tom for the
+  suggestion)
+- Fixed alpha blending when alpha = 100%
+- Change gpioSetValue to be inline (should optimise to a single operation)
+
 v1.0.0 - 23 March 2012
-======================
+===========================================================
 - Added support for LPCXpresso IDE
 - *** Moved '/drivers/chibi' to '/drivers/rf/chibi' ***
 - *** Moved '/drivers/sensors/pn532' to '/drivers/rf/pn532' ***
index aa26d89..379faa6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -70,8 +70,12 @@ OBJS += isl12022m.o
 
 # TFT LCD support
 VPATH += drivers/displays/tft drivers/displays/tft/hw 
-VPATH += drivers/displays/tft/dialogues
-OBJS += drawing.o touchscreen.o colors.o bmp.o alphanumeric.o
+OBJS += drawing.o touchscreen.o colors.o bmp.o
+
+# GUI Controls
+VPATH += drivers/displays/tft/controls
+OBJS += button.o hsbchart.o huechart.o label.o
+OBJS += labelcentered.o progressbar.o
 
 # Bitmap (non-AA) fonts
 VPATH += drivers/displays/tft/fonts
index c01ad87..c05e75e 100644 (file)
@@ -1,7 +1,7 @@
 <!DOCTYPE CrossStudio_Project_File>
 <solution Name="LPC1343_CodeBase" target="8" version="2">
   <project Name="LPC1343_CodeBase">
-    <configuration Name="Common" Target="LPC1343" arm_architecture="v7M" arm_core_type="Cortex-M3" arm_gcc_target="arm-unknown-eabi" arm_library_optimization="Small" arm_linker_heap_size="512" arm_linker_process_stack_size="0" arm_linker_stack_size="1024" arm_simulator_memory_simulation_filename="$(TargetsDir)/LPC1000/LPC1000SimulatorMemory.dll" arm_simulator_memory_simulation_parameter="LPC13;0x8000;0x2000;0x0" arm_target_debug_interface_type="ADIv5" arm_target_loader_parameter="12000000" c_additional_options="" c_preprocessor_definitions="USE_PROCESS_STACK" c_user_include_directories="$(TargetsDir)/LPC1000/include;" link_include_standard_libraries="Yes" link_include_startup_code="No" linker_additional_files="$(TargetsDir)/LPC1000/lib/liblpc1000$(LibExt)$(LIB);$(TargetsDir)/LPC1000/lib/cmsis$(LibExt)$(LIB)" linker_memory_map_file="$(TargetsDir)/LPC1000/LPC1343_MemoryMap.xml" linker_output_format="bin" oscillator_frequency="12MHz" project_directory="" project_type="Executable" property_groups_file_path="$(TargetsDir)/LPC1000/propertyGroups13xx.xml"/>
+    <configuration Name="Common" Target="LPC1343" arm_architecture="v7M" arm_core_type="Cortex-M3" arm_gcc_target="arm-unknown-eabi" arm_library_optimization="Small" arm_linker_heap_size="512" arm_linker_process_stack_size="0" arm_linker_stack_size="1024" arm_simulator_memory_simulation_filename="$(TargetsDir)/LPC1000/LPC1000SimulatorMemory.dll" arm_simulator_memory_simulation_parameter="LPC13;0x8000;0x2000;0x0" arm_target_debug_interface_type="ADIv5" arm_target_loader_parameter="12000000" c_additional_options="" c_preprocessor_definitions="USE_PROCESS_STACK" c_user_include_directories="$(TargetsDir)/CMSIS_3/CMSIS/Include;$(TargetsDir)/LPC1000/include;$(TargetsDir)/LPC1000/include/CMSIS" link_include_standard_libraries="Yes" link_include_startup_code="No" linker_additional_files="$(TargetsDir)/LPC1000/lib/liblpc1000$(LibExt)$(LIB)" linker_memory_map_file="$(TargetsDir)/LPC1000/LPC1343_MemoryMap.xml" linker_output_format="bin" oscillator_frequency="12MHz" project_directory="" project_type="Executable" property_groups_file_path="$(TargetsDir)/LPC1000/propertyGroups13xx.xml"/>
     <configuration Name="Flash" Placement="Flash" arm_target_flash_loader_file_path="$(TargetsDir)/LPC1000/Release/Loader_lpc1300.elf" arm_target_flash_loader_type="LIBMEM RPC Loader" linker_patch_build_command="$(StudioDir)/bin/crossscript &quot;load(\&quot;$(TargetsDir)/LPC1000/LPC1000_LinkPatch.js\&quot;);patch(\&quot;$(TargetPath)\&quot;);&quot;" linker_section_placement_file="$(StudioDir)/targets/Cortex_M/flash_placement.xml" target_reset_script="FLASHReset()"/>
     <configuration Name="RAM" Placement="RAM" linker_section_placement_file="$(StudioDir)/targets/Cortex_M/ram_placement.xml" target_reset_script="SRAMReset()"/>
     <folder Name="Source Files" file_name="">
               <file file_name="../../drivers/displays/bitmap/ssd1306/ssd1306.c">
                 <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
               </file>
-              <file file_name="../../drivers/displays/bitmap/ssd1306/ssd1306_i2c.c">
-                <configuration Name="THUMB Flash Debug" build_exclude_from_build="Yes"/>
-                <configuration Name="THUMB Flash Release" build_exclude_from_build="Yes"/>
-              </file>
             </folder>
             <folder Name="sharpmem">
               <file file_name="../../drivers/displays/bitmap/sharpmem/sharpmem.c"/>
               </file>
             </folder>
             <folder Name="fonts">
-              <file file_name="../../drivers/displays/tft/fonts/dejavusans9.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/dejavusansbold9.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/dejavusanscondensed9.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/dejavusansmono8.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/dejavusansmonobold8.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/veramono9.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/veramono11.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/veramonobold9.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/veramonobold11.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/verdana9.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/verdana14.c"/>
-              <file file_name="../../drivers/displays/tft/fonts/verdanabold14.c"/>
-            </folder>
-            <folder Name="dialogues">
-              <file file_name="../../drivers/displays/tft/dialogues/alphanumeric.c">
+              <file file_name="../../drivers/displays/tft/fonts/dejavusans9.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/dejavusansbold9.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/dejavusanscondensed9.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/dejavusansmono8.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/dejavusansmonobold8.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/veramono9.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/veramono11.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/veramonobold9.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/veramonobold11.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/verdana9.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/verdana14.c">
+                <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+              </file>
+              <file file_name="../../drivers/displays/tft/fonts/verdanabold14.c">
                 <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
               </file>
             </folder>
               <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
             </file>
             <file file_name="../../drivers/displays/tft/fonts.c"/>
+            <file file_name="../../drivers/displays/tft/theme.h"/>
+            <folder Name="controls">
+              <file file_name="../../drivers/displays/tft/controls/progressbar.c"/>
+              <file file_name="../../drivers/displays/tft/controls/button.c"/>
+              <file file_name="../../drivers/displays/tft/controls/hsbchart.c"/>
+              <file file_name="../../drivers/displays/tft/controls/huechart.c"/>
+              <file file_name="../../drivers/displays/tft/controls/label.c"/>
+              <file file_name="../../drivers/displays/tft/controls/labelcentered.c"/>
+            </folder>
           </folder>
           <folder Name="character">
             <folder Name="samsung_20T202DA2JA">
index d980ed8..e77a2dd 100644 (file)
@@ -9,7 +9,7 @@
  </ETMWindow>
  <ExecutionCountWindow/>
  <Memory1>
-  <MemoryWindow autoEvaluate="0" addressText="&amp;pbtResponse" numColumns="8" sizeText="64" dataSize="1" radix="16" addressSpace="" />
+  <MemoryWindow autoEvaluate="0" addressText="0x50021000" numColumns="8" sizeText="32" dataSize="4" radix="16" addressSpace="" />
  </Memory1>
  <Memory2>
   <MemoryWindow autoEvaluate="0" addressText="" numColumns="8" sizeText="" dataSize="1" radix="16" addressSpace="" />
   <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;bitmap" name="unnamed" />
-  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;displays;bitmap;ssd1306" name="unnamed" />
+  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;displays;tft" name="unnamed" />
+  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;project" name="unnamed" />
  </Project>
  <Register1>
-  <RegisterWindow openNodes="CPU;CoreDebug" binaryNodes="" hiddenNodes="" unsignedNodes="" visibleGroups="CPU;CoreDebug" decimalNodes="" octalNodes="" asciiNodes="" />
+  <RegisterWindow openNodes="GPIO2" binaryNodes="" hiddenNodes="" unsignedNodes="" visibleGroups="CPU;CoreDebug;GPIO2" decimalNodes="" octalNodes="" asciiNodes="" />
  </Register1>
  <Register2>
   <RegisterWindow openNodes="" binaryNodes="" hiddenNodes="" unsignedNodes="" visibleGroups="" decimalNodes="" octalNodes="" asciiNodes="" />
  </TraceWindow>
  <Watch1>
   <Watches active="1" update="Each Second" >
-   <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" />
+   <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" />
   </Watches>
  </Watch1>
  <Watch2>
@@ -63,7 +63,8 @@
   <Watches active="0" update="Never" />
  </Watch4>
  <Files>
-  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="5" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="69" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="41" />
+  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\projectconfig.h" y="554" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\projectconfig.h" left="0" selected="0" name="unnamed" top="507" />
+  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="175" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="147" />
  </Files>
- <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 Debug" />
+ <ARMCrossStudioWindow activeProject="LPC1343_CodeBase" autoConnectTarget="SEGGER J-Link" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\drivers\displays\tft\controls" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388991" debugSearchPath="" buildConfiguration="THUMB Flash Release" />
 </session>
index c425bf9..bc8875a 100644 (file)
@@ -239,6 +239,30 @@ void aafontsDrawString(uint16_t x, uint16_t y, const uint16_t * colorTable, cons
   }
 }
 
+/**************************************************************************/
+/*!
+    @brief  Draws a string using the supplied anti-aliased font, centering
+            it on the specified X/Y co-ordinate
+
+    @param[in]  x
+                Center x co-ordinate
+    @param[in]  y
+                Center y co-ordinate
+    @param[in]  colorTable
+                The color lookup table to use for the antialiased pixels
+    @param[in]  font
+                Pointer to the aafontsFont_t to use when drawing the string
+    @param[in]  str
+                The string to render
+*/
+/**************************************************************************/
+void aafontsCenterString(uint16_t x, uint16_t y, const uint16_t * colorTable, const aafontsFont_t *font, char *str)
+{
+  uint32_t stringWidth;
+  stringWidth = aafontsGetStringWidth(font, str);
+  aafontsDrawString(x - stringWidth/2, y, colorTable, font, str);
+}
+
 /**************************************************************************/
 /*!
     @brief  Returns the width in pixels of a string when it is rendered
index 7d0ec34..e09f246 100644 (file)
@@ -70,6 +70,7 @@ extern const uint16_t COLORTABLE_AA4_WHITEONBLACK[16];
 extern const uint16_t COLORTABLE_AA4_BLACKONWHITE[16];
 
 void      aafontsDrawString ( uint16_t x, uint16_t y, const uint16_t * colorTable, const aafontsFont_t *font, char *str );
+void      aafontsCenterString ( uint16_t x, uint16_t y, const uint16_t * colorTable, const aafontsFont_t *font, char *str );
 uint16_t  aafontsGetStringWidth ( const aafontsFont_t *font, char *str );
 void      aafontsCalculateColorTable ( uint16_t bgColor, uint16_t foreColor, uint16_t *colorTable, size_t tableSize );
 
index 2c217d4..7966d22 100644 (file)
@@ -36,7 +36,6 @@
 #ifndef __DEJAVUSANSCONDENSEDBOLD14_AA2_H__
 #define __DEJAVUSANSCONDENSEDBOLD14_AA2_H__
 
-#include "projectconfig.h"
 #include "drivers/displays/tft/aafonts.h"
 
 extern aafontsFont_t DejaVuSansCondensedBold14_AA2;
index 7554645..db55fe7 100644 (file)
@@ -146,12 +146,34 @@ bmp_error_t bmpParseBitmap(uint16_t x, uint16_t y, FIL file)
 
     #include "drivers/displays/tft/bmp.h"
 
-    bmp_error_t error;
-
     // Draw image.bmp (from the root folder) starting at pixel 0,0
-    error = bmpDrawBitmap(0, 0, "/image.bmp");
+    bmp_error_t error = bmpDrawBitmap(0, 0, "/image.bmp");
 
-    // Check 'error' for problems such as BMP_ERROR_FILENOTFOUND
+    if (error)
+    {
+      switch (error)
+      {
+        case BMP_ERROR_SDINITFAIL:
+          break;
+        case BMP_ERROR_FILENOTFOUND:
+          break;
+        case BMP_ERROR_NOTABITMAP:
+          // First two bytes of image not 'BM'
+          break;
+        case BMP_ERROR_INVALIDBITDEPTH:
+          // Image is not 24-bits
+          break;
+        case BMP_ERROR_COMPRESSEDDATA:
+          // Image contains compressed data
+          break;
+        case BMP_ERROR_INVALIDDIMENSIONS:
+          // Width or Height is > LCD size
+          break;
+        case BMP_ERROR_PREMATUREEOF:
+          // EOF unexpectedly reached in pixel data
+          break;
+      }
+    }
 
     @endcode
 */
index e74f74a..5788948 100644 (file)
@@ -156,6 +156,7 @@ uint16_t colorsBGR2RGB(uint16_t color)
 
     @code
 
+    #include "drivers/displays/tft/drawing.h"
     #include "drivers/displays/tft/colors.h"
 
     uint16_t newColor;
@@ -225,7 +226,7 @@ uint16_t colorsDim(uint16_t color, uint8_t intensity)
     uint16_t bg = COLOR_GREEN;
     uint16_t fore = COLOR_WHITE;
 
-    // Calculate the intermediate color with 25% fading
+    // Calculate the intermediate color with 25% bg blending
     uint16_t result = colorsAlphaBlend(bg, fore, 25);
 
     drawRectangleFilled(10, 10, 50, 50, bg);
index b2bb641..83cbf98 100644 (file)
 #define COLOR_GRAY_200                      (uint16_t)(0xCE59)    // 200 200 200
 #define COLOR_GRAY_225                      (uint16_t)(0xE71C)    // 225 225 225
 
-// Color Palettes
-#define COLOR_THEME_LIMEGREEN_BASE          (uint16_t)(0xD7F0)    // 211 255 130
-#define COLOR_THEME_LIMEGREEN_DARKER        (uint16_t)(0x8DE8)    // 137 188  69
-#define COLOR_THEME_LIMEGREEN_LIGHTER       (uint16_t)(0xEFF9)    // 238 255 207
-#define COLOR_THEME_LIMEGREEN_SHADOW        (uint16_t)(0x73EC)    // 119 127 103
-#define COLOR_THEME_LIMEGREEN_ACCENT        (uint16_t)(0xAE6D)    // 169 204 104
-
-#define COLOR_THEME_VIOLET_BASE             (uint16_t)(0x8AEF)    // 143  94 124
-#define COLOR_THEME_VIOLET_DARKER           (uint16_t)(0x4187)    //  66  49  59
-#define COLOR_THEME_VIOLET_LIGHTER          (uint16_t)(0xC475)    // 194 142 174
-#define COLOR_THEME_VIOLET_SHADOW           (uint16_t)(0x40E6)    //  66  29  52
-#define COLOR_THEME_VIOLET_ACCENT           (uint16_t)(0xC992)    // 204  50 144
-
-#define COLOR_THEME_EARTHY_BASE             (uint16_t)(0x6269)    //  97  79  73
-#define COLOR_THEME_EARTHY_DARKER           (uint16_t)(0x3103)    //  48  35  31
-#define COLOR_THEME_EARTHY_LIGHTER          (uint16_t)(0x8C30)    // 140 135 129
-#define COLOR_THEME_EARTHY_SHADOW           (uint16_t)(0xAB29)    // 173 102  79
-#define COLOR_THEME_EARTHY_ACCENT           (uint16_t)(0xFE77)    // 250 204 188
-
-#define COLOR_THEME_SKYBLUE_BASE            (uint16_t)(0x95BF)    // 150 180 255
-#define COLOR_THEME_SKYBLUE_DARKER          (uint16_t)(0x73B0)    // 113 118 131
-#define COLOR_THEME_SKYBLUE_LIGHTER         (uint16_t)(0xE75F)    // 227 235 255
-#define COLOR_THEME_SKYBLUE_SHADOW          (uint16_t)(0x4ACF)    //  75  90 127
-#define COLOR_THEME_SKYBLUE_ACCENT          (uint16_t)(0xB5F9)    // 182 188 204
-
-// Using these values allows you to update the entire UI color scheme in one location
-#define COLOR_THEME_DEFAULT_BASE            COLOR_THEME_LIMEGREEN_BASE
-#define COLOR_THEME_DEFAULT_DARKER          COLOR_THEME_LIMEGREEN_DARKER
-#define COLOR_THEME_DEFAULT_LIGHTER         COLOR_THEME_LIMEGREEN_LIGHTER
-#define COLOR_THEME_DEFAULT_SHADOW          COLOR_THEME_LIMEGREEN_SHADOW
-#define COLOR_THEME_DEFAULT_ACCENT          COLOR_THEME_LIMEGREEN_ACCENT
-
 uint16_t colorsRGB24toRGB565  ( uint8_t r, uint8_t g, uint8_t b );
 uint32_t colorsRGB565toBGRA32 ( uint16_t color );
 uint16_t colorsBGR2RGB        ( uint16_t color );
diff --git a/drivers/displays/tft/controls/button.c b/drivers/displays/tft/controls/button.c
new file mode 100644 (file)
index 0000000..a3de42c
--- /dev/null
@@ -0,0 +1,91 @@
+/**************************************************************************/
+/*! 
+    @file     button.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @brief    Renders a button
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#include <string.h>
+
+#include "button.h"
+
+/**************************************************************************/
+/*!
+    @brief  Draws a simple button with centered text
+
+    @param[in]  x
+                Starting x co-ordinate
+    @param[in]  y
+                Starting y co-ordinate
+    @param[in]  width
+                Button width in pixels
+    @param[in]  height
+                Button height in pixels
+    @param[in]  fontColor
+                Color used when rendering the text
+    @param[in]  text
+                Text to center inside the button
+*/
+/**************************************************************************/
+void buttonRender(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t fontColor, char *text, theme_t theme)
+{
+  #if CFG_TFTLCD_USEAAFONTS
+    uint16_t ctable[4];
+
+    // Calculate 4 color lookup table using the appropriate fore and bg colors
+    // 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)
+    {
+      uint16_t textWidth = fontsGetStringWidth(&THEME_FONT, text);
+      uint16_t xStart = x + (width / 2) - (textWidth / 2);
+      uint16_t yStart = y + (height / 2) - (THEME_FONT.height / 2) + 1;
+      fontsDrawString(xStart, yStart, fontColor, &THEME_FONT, text);
+    }
+  #endif
+}
diff --git a/drivers/displays/tft/controls/button.h b/drivers/displays/tft/controls/button.h
new file mode 100644 (file)
index 0000000..9401552
--- /dev/null
@@ -0,0 +1,44 @@
+/**************************************************************************/
+/*! 
+    @file     button.h
+    @author   K. Townsend (microBuilder.eu)
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#ifndef __BUTTON_H__
+#define __BUTTON_H__
+
+#include "projectconfig.h"
+#include "drivers/displays/tft/drawing.h"
+
+void buttonRender(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t fontColor, char *text, theme_t theme);
+
+#endif
diff --git a/drivers/displays/tft/controls/hsbchart.c b/drivers/displays/tft/controls/hsbchart.c
new file mode 100644 (file)
index 0000000..ab061be
--- /dev/null
@@ -0,0 +1,81 @@
+/**************************************************************************/
+/*! 
+    @file     hsbchart.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @brief    Renders a hue/saturation/brightness chart
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#include <string.h>
+
+#include "hsbchart.h"
+
+/**************************************************************************/
+/*! 
+    @brief  Draws a square HSB (hue, saturation, brightness) chart
+
+    @param[in]  x
+                Starting x co-ordinate
+    @param[in]  y
+                Starting y co-ordinate
+    @param[in]  size
+                Width/height of the chart
+    @param[in]  baseColor
+                The fully saturated color to use for the chart
+*/
+/**************************************************************************/
+void hsbchartRender(uint16_t x, uint16_t y, uint16_t size, uint16_t baseColor, theme_t theme)
+{
+  uint32_t delta;   // Alpha channel difference per pixel
+  uint16_t colorS;  // Alpha-blended color for saturation
+  uint16_t color;   // Alpha-blended color for saturation + brightness
+  uint32_t b;       // Brightness counter
+  uint32_t s;       // Saturation counter
+
+  drawRectangle(x, y, x+size, y+size, theme.colorBorderDarker);
+
+  if (size > 2)
+  {
+    delta = 10000/(size-2);       // Calculate difference in perfect per pixel (fixed point math, * 100)
+    for (b = 0; b<size-1; b++)
+    {
+      // Calculate color for saturation
+      colorS = colorsAlphaBlend(COLOR_WHITE, baseColor, 100 - (b*delta) / 100);
+      for (s = 0; s<size-1; s++)
+      {
+        // Calculate color for brightness
+        color = colorsAlphaBlend(colorS, COLOR_BLACK, 100 - (s*delta) / 100);
+        drawPixel(x+b+1, y+s+1, color);
+      }
+    }
+  }
+}
diff --git a/drivers/displays/tft/controls/hsbchart.h b/drivers/displays/tft/controls/hsbchart.h
new file mode 100644 (file)
index 0000000..23e2854
--- /dev/null
@@ -0,0 +1,44 @@
+/**************************************************************************/
+/*! 
+    @file     hsbchart.h
+    @author   K. Townsend (microBuilder.eu)
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#ifndef __HSBCHART_H__
+#define __HSBCHART_H__
+
+#include "projectconfig.h"
+#include "drivers/displays/tft/drawing.h"
+
+void hsbchartRender(uint16_t x, uint16_t y, uint16_t size, uint16_t baseColor, theme_t theme);
+
+#endif
diff --git a/drivers/displays/tft/controls/huechart.c b/drivers/displays/tft/controls/huechart.c
new file mode 100644 (file)
index 0000000..8f744a9
--- /dev/null
@@ -0,0 +1,71 @@
+/**************************************************************************/
+/*! 
+    @file     huechart.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @brief    Renders a hue/saturation/brightness chart
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#include <string.h>
+
+#include "huechart.h"
+
+/**************************************************************************/
+/*! 
+    @brief  Draws a rectangular hue chart showing the full spectrum
+                       of fully saturated colors
+
+    @param[in]  x
+                Starting x co-ordinate
+    @param[in]  y
+                Starting y co-ordinate
+    @param[in]  width
+                Width of the chart in pixels
+    @param[in]  height
+                Width of the chart in pixels
+*/
+/**************************************************************************/
+void huechartRender(uint16_t x, uint16_t y, uint16_t width, uint16_t height, theme_t theme)
+{
+  uint32_t delta = (height - 2) / 6;
+
+  // Draw border
+  drawRectangle(x, y, x+width, y+height, theme.colorBorderDarker);
+
+  // Draw gradient (R > M > B > C > G > Y > R)
+  drawGradient(x+1, y+1, x+width-1, y+delta-1, COLOR_RED, COLOR_MAGENTA);
+  drawGradient(x+1, y+delta, x+width-1, y+(delta*2)-1, COLOR_MAGENTA, COLOR_BLUE);
+  drawGradient(x+1, y+(delta*2), x+width-1, y+(delta*3)-1, COLOR_BLUE, COLOR_CYAN);
+  drawGradient(x+1, y+(delta*3), x+width-1, y+(delta*4)-1, COLOR_CYAN, COLOR_GREEN);
+  drawGradient(x+1, y+(delta*4), x+width-1, y+(delta*5)-1, COLOR_GREEN, COLOR_YELLOW);
+  drawGradient(x+1, y+(delta*5), x+width-1, y+height-1, COLOR_YELLOW, COLOR_RED);
+}
diff --git a/drivers/displays/tft/controls/huechart.h b/drivers/displays/tft/controls/huechart.h
new file mode 100644 (file)
index 0000000..9f79c12
--- /dev/null
@@ -0,0 +1,44 @@
+/**************************************************************************/
+/*! 
+    @file     huechart.h
+    @author   K. Townsend (microBuilder.eu)
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#ifndef __HUECHART_H__
+#define __HUECHART_H__
+
+#include "projectconfig.h"
+#include "drivers/displays/tft/drawing.h"
+
+void huechartRender(uint16_t x, uint16_t y, uint16_t width, uint16_t height, theme_t theme);
+
+#endif
diff --git a/drivers/displays/tft/controls/label.c b/drivers/displays/tft/controls/label.c
new file mode 100644 (file)
index 0000000..33bb9cd
--- /dev/null
@@ -0,0 +1,74 @@
+/**************************************************************************/
+/*! 
+    @file     label.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @brief    Renders a label
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#include <string.h>
+
+#include "label.h"
+
+/**************************************************************************/
+/*!
+    @brief  Draws a simple label
+
+    @param[in]  x
+                Starting x co-ordinate
+    @param[in]  y
+                Starting y co-ordinate
+    @param[in]  bgColor
+                Color used for the background (required for AA fonts)
+    @param[in]  fontColor
+                Color used when rendering the text
+    @param[in]  text
+                Text to center inside the label
+*/
+/**************************************************************************/
+void labelRender(uint16_t x, uint16_t y, uint16_t bgColor, uint16_t fontColor, char *text, theme_t theme)
+{
+  #if CFG_TFTLCD_USEAAFONTS
+    uint16_t ctable[4];
+    if (text != NULL)
+    {
+      aafontsCalculateColorTable(bgColor, fontColor, &ctable[0], 4);
+      aafontsDrawString(x, y, ctable, &THEME_FONT, text);
+    }
+  #else
+    // Render text
+    if (text != NULL)
+    {
+      fontsDrawString(x, y, fontColor, &THEME_FONT, text);
+    }
+  #endif
+}
diff --git a/drivers/displays/tft/controls/label.h b/drivers/displays/tft/controls/label.h
new file mode 100644 (file)
index 0000000..864763b
--- /dev/null
@@ -0,0 +1,44 @@
+/**************************************************************************/
+/*! 
+    @file     label.h
+    @author   K. Townsend (microBuilder.eu)
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#ifndef __LABEL_H__
+#define __LABEL_H__
+
+#include "projectconfig.h"
+#include "drivers/displays/tft/drawing.h"
+
+void labelRender(uint16_t x, uint16_t y, uint16_t bgColor, uint16_t fontColor, char *text, theme_t theme);
+
+#endif
diff --git a/drivers/displays/tft/controls/labelcentered.c b/drivers/displays/tft/controls/labelcentered.c
new file mode 100644 (file)
index 0000000..1b549d7
--- /dev/null
@@ -0,0 +1,76 @@
+/**************************************************************************/
+/*! 
+    @file     labelcentered.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @brief    Renders a centered text label
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#include <string.h>
+
+#include "labelcentered.h"
+
+/**************************************************************************/
+/*!
+    @brief  Draws a centered label
+
+    @param[in]  x
+                Starting x co-ordinate
+    @param[in]  y
+                Starting y co-ordinate
+    @param[in]  bgColor
+                Color used for the background (required for AA fonts)
+    @param[in]  fontColor
+                Color used when rendering the text
+    @param[in]  text
+                Text to center inside the label
+*/
+/**************************************************************************/
+void labelcenteredRender(uint16_t x, uint16_t y, uint16_t bgColor, uint16_t fontColor, char *text, theme_t theme)
+{
+  #if CFG_TFTLCD_USEAAFONTS
+    uint16_t ctable[4];
+    if (text != NULL)
+    {
+      aafontsCalculateColorTable(bgColor, fontColor, &ctable[0], 4);
+      aafontsCenterString(x, y, ctable, &THEME_FONT, text);
+    }
+  #else
+    // Render text
+    if (text != NULL)
+    {
+      uint16_t textWidth = fontsGetStringWidth(&THEME_FONT, text);
+      uint16_t xStart = x - (textWidth / 2);
+      fontsDrawString(xStart, y, fontColor, &THEME_FONT, text);
+    }
+  #endif
+}
diff --git a/drivers/displays/tft/controls/labelcentered.h b/drivers/displays/tft/controls/labelcentered.h
new file mode 100644 (file)
index 0000000..9696d3d
--- /dev/null
@@ -0,0 +1,44 @@
+/**************************************************************************/
+/*! 
+    @file     labelcentered.h
+    @author   K. Townsend (microBuilder.eu)
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#ifndef __LABELCENTERED_H__
+#define __LABELCENTERED_H__
+
+#include "projectconfig.h"
+#include "drivers/displays/tft/drawing.h"
+
+void labelcenteredRender(uint16_t x, uint16_t y, uint16_t bgColor, uint16_t fontColor, char *text, theme_t theme);
+
+#endif
diff --git a/drivers/displays/tft/controls/progressbar.c b/drivers/displays/tft/controls/progressbar.c
new file mode 100644 (file)
index 0000000..8a46d21
--- /dev/null
@@ -0,0 +1,97 @@
+/**************************************************************************/
+/*! 
+    @file     progressbar.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @brief    Renders a progress bar
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#include <string.h>
+
+#include "progressbar.h"
+
+/**************************************************************************/
+/*! 
+    @brief  Draws a simple (empty) rectangle
+
+    @param[in]  x
+                Starting x co-ordinate
+    @param[in]  y
+                Starting y co-ordinate
+    @param[in]  width
+                Button width in pixels
+    @param[in]  height
+                Button height in pixels
+    @param[in]  progress
+                Progress in percent from 0..100
+    @param[in]  color
+                Color used when rendering the progress bar
+
+    @note   Because all displays with built-in controllers and SRAM are
+            inherently single-buffered -- meaning you can see the updates
+            as you draw them -- you need to be very careful to try to avoid
+            tearing or 'blinking' effects.  This is usually caused by
+            writing the same pixel twice with different colors (for example
+            filling a background and then drawing something on top of it).
+
+            This progress bar avoids this blinking effect by only drawing
+            the background gradient where it is visible, and no beneath the
+            progress bar itself.
+*/
+/**************************************************************************/
+void progressbarRender(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t progress, uint16_t color, theme_t theme)
+{
+  uint16_t brighter, darker;
+  uint16_t progressEnd;
+
+  // Figure out the size of the progress bar
+  progressEnd = x + (((width-2) * progress)/100);
+
+  // 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
+  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)
+  { 
+    drawRectangle(x+2, y+2, progressEnd, y+height-2, darker);
+    drawGradient(x+3, y+3, progressEnd-1, y+height-3, brighter, color);
+  }
+}
diff --git a/drivers/displays/tft/controls/progressbar.h b/drivers/displays/tft/controls/progressbar.h
new file mode 100644 (file)
index 0000000..0f93fd1
--- /dev/null
@@ -0,0 +1,44 @@
+/**************************************************************************/
+/*! 
+    @file     progressbar.h
+    @author   K. Townsend (microBuilder.eu)
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, K. Townsend
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#ifndef __PROGRESSBAR_H__
+#define __PROGRESSBAR_H__
+
+#include "projectconfig.h"
+#include "drivers/displays/tft/drawing.h"
+
+void progressbarRender(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t progress, uint16_t color, theme_t theme);
+
+#endif
index 8161465..924c115 100644 (file)
 
 #include "drawing.h"
 
-#ifdef CFG_SDCARD
-  #include "bmp.h"
-#endif
-
 /**************************************************************************/
 /*                                                                        */
 /* ----------------------- Private Methods ------------------------------ */
@@ -109,40 +105,6 @@ void drawCharSmall(uint16_t x, uint16_t y, uint16_t color, uint8_t c, struct FON
 }
 #endif
 
-/**************************************************************************/
-/*!
-    @brief  Helper method to accurately draw individual circle points
-*/
-/**************************************************************************/
-void drawCirclePoints(int cx, int cy, int x, int y, uint16_t color)
-{    
-  if (x == 0) 
-  {
-      drawPixel(cx, cy + y, color);
-      drawPixel(cx, cy - y, color);
-      drawPixel(cx + y, cy, color);
-      drawPixel(cx - y, cy, color);
-  } 
-  else if (x == y) 
-  {
-      drawPixel(cx + x, cy + y, color);
-      drawPixel(cx - x, cy + y, color);
-      drawPixel(cx + x, cy - y, color);
-      drawPixel(cx - x, cy - y, color);
-  } 
-  else if (x < y) 
-  {
-      drawPixel(cx + x, cy + y, color);
-      drawPixel(cx - x, cy + y, color);
-      drawPixel(cx + x, cy - y, color);
-      drawPixel(cx - x, cy - y, color);
-      drawPixel(cx + y, cy + x, color);
-      drawPixel(cx - y, cy + x, color);
-      drawPixel(cx + y, cy - x, color);
-      drawPixel(cx - y, cy - x, color);
-  }
-}
-
 /**************************************************************************/
 /*                                                                        */
 /* ----------------------- Public Methods ------------------------------- */
@@ -163,14 +125,10 @@ void drawCirclePoints(int cx, int cy, int x, int y, uint16_t color)
 /**************************************************************************/
 void drawPixel(uint16_t x, uint16_t y, uint16_t color)
 {
-  if ((x >= lcdGetWidth()) || (y >= lcdGetHeight()))
+  if ((x < lcdGetWidth()) && (y < lcdGetHeight()))
   {
-    // Pixel out of range
-    return;
+    lcdDrawPixel(x, y, color);
   }
-
-  // Redirect to LCD
-  lcdDrawPixel(x, y, color);
 }
 
 /**************************************************************************/
@@ -422,25 +380,11 @@ void drawLineDotted ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16
 /**************************************************************************/
 void drawCircle (uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint16_t color)
 {
-  int x = 0;
-  int y = radius;
-  int p = (5 - radius*4)/4;
-
-  drawCirclePoints(xCenter, yCenter, x, y, color);
-  while (x < y) 
-  {
-    x++;
-    if (p < 0) 
-    {
-      p += 2*x+1;
-    } 
-    else 
-    {
-      y--;
-      p += 2*(x-y)+1;
-    }
-    drawCirclePoints(xCenter, yCenter, x, y, color);
-  }
+  drawPixel(xCenter, yCenter+radius, color);
+  drawPixel(xCenter, yCenter-radius, color);
+  drawPixel(xCenter+radius, yCenter, color);
+  drawPixel(xCenter-radius, yCenter, color);
+  drawCorner(xCenter, yCenter, radius, DRAW_CORNERS_ALL, color);
 }
 
 /**************************************************************************/
@@ -497,6 +441,74 @@ void drawCircleFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint
   }
 }
 
+/**************************************************************************/
+/*!
+    @brief  Draws a single 1-pixel wide corner
+
+    @note   Code courtesy Adafruit's excellent GFX lib:
+            https://github.com/adafruit/Adafruit-GFX-Library
+
+    @param[in]  xCenter
+                The horizontal center of the circle
+    @param[in]  yCenter
+                The vertical center of the circle
+    @param[in]  corner
+                The drawCorners_t representing the corner(s) to draw
+    @param[in]  color
+                Color used when drawing
+    
+    @section EXAMPLE
+
+    @code
+
+    // Draw a top-left corner with a 10 pixel radius, centered at 20, 20
+    drawCorner(20, 20, 10, DRAW_CORNER_TOPLEFT, COLOR_GRAY_128);
+
+    @endcode
+*/
+/**************************************************************************/
+void drawCorner (uint16_t xCenter, uint16_t yCenter, uint16_t r, drawCorners_t corner, uint16_t color) 
+{
+  int16_t f     = 1 - r;
+  int16_t ddF_x = 1;
+  int16_t ddF_y = -2 * r;
+  int16_t x     = 0;
+  int16_t y     = r;
+
+  while (x<y) 
+  {
+    if (f >= 0) 
+    {
+      y--;
+      ddF_y += 2;
+      f     += ddF_y;
+    }
+    x++;
+    ddF_x += 2;
+    f     += ddF_x;
+    if (corner & DRAW_CORNERS_BOTTOMRIGHT) 
+    {
+      drawPixel(xCenter + x, yCenter + y, color);
+      drawPixel(xCenter + y, yCenter + x, color);
+    } 
+    if (corner & DRAW_CORNERS_TOPRIGHT) 
+    {
+      drawPixel(xCenter + x, yCenter - y, color);
+      drawPixel(xCenter + y, yCenter - x, color);
+    }
+    if (corner & DRAW_CORNERS_BOTTOMLEFT) 
+    {
+      drawPixel(xCenter - y, yCenter + x, color);
+      drawPixel(xCenter - x, yCenter + y, color);
+    }
+    if (corner & DRAW_CORNERS_TOPLEFT) 
+    {
+      drawPixel(xCenter - y, yCenter - x, color);
+      drawPixel(xCenter - x, yCenter - y, color);
+    }
+  }
+}
+
 /**************************************************************************/
 /*!
     @brief  Draws a filled rounded corner
@@ -514,7 +526,7 @@ void drawCircleFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint
                 Color used when drawing
 */
 /**************************************************************************/
-void drawCornerFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, drawCornerPosition_t position, uint16_t color)
+void drawCornerFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, drawCorners_t position, uint16_t color)
 {
   int16_t f = 1 - radius;
   int16_t ddF_x = 1;
@@ -524,16 +536,14 @@ void drawCornerFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, draw
   int16_t xc_px, yc_my, xc_mx, xc_py, yc_mx, xc_my;
   int16_t lcdWidth = lcdGetWidth();
 
-  switch (position)
+
+  if ((position & DRAW_CORNERS_TOPRIGHT) || (position & DRAW_CORNERS_TOPLEFT))
   {
-    case DRAW_CORNERPOSITION_TOPRIGHT:
-    case DRAW_CORNERPOSITION_TOPLEFT:
-      if (xCenter < lcdWidth) drawLine(xCenter, yCenter-radius < 0 ? 0 : yCenter-radius, xCenter, yCenter, color);
-      break;
-    case DRAW_CORNERPOSITION_BOTTOMRIGHT:
-    case DRAW_CORNERPOSITION_BOTTOMLEFT:
-      if (xCenter < lcdWidth) drawLine(xCenter, yCenter-radius < 0 ? 0 : yCenter, xCenter, (yCenter-radius) + (2*radius), color);
-      break;
+    if (xCenter < lcdWidth) drawLine(xCenter, yCenter-radius < 0 ? 0 : yCenter-radius, xCenter, yCenter, color);
+  }
+  if ((position & DRAW_CORNERS_BOTTOMRIGHT) || (position & DRAW_CORNERS_BOTTOMLEFT))
+  {
+    if (xCenter < lcdWidth) drawLine(xCenter, yCenter-radius < 0 ? 0 : yCenter, xCenter, (yCenter-radius) + (2*radius), color);
   }
   
   while (x<y) 
@@ -555,24 +565,26 @@ void drawCornerFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, draw
     yc_mx = yCenter-x;
     yc_my = yCenter-y;
 
-    switch (position)
+
+    if (position & DRAW_CORNERS_TOPRIGHT)
     {
-      case DRAW_CORNERPOSITION_TOPRIGHT:
         if ((xc_px < lcdWidth) && (xc_px >= 0)) drawLine(xc_px, yc_my, xc_px, yCenter, color);
         if ((xc_py < lcdWidth) && (xc_py >= 0)) drawLine(xc_py, yc_mx, xc_py, yCenter, color);
-        break;
-      case DRAW_CORNERPOSITION_BOTTOMRIGHT:
+    }
+    if (position & DRAW_CORNERS_BOTTOMRIGHT)
+    {
         if ((xc_px < lcdWidth) && (xc_px >= 0)) drawLine(xc_px, yCenter, xc_px, yc_my + 2*y, color);
         if ((xc_py < lcdWidth) && (xc_py >= 0)) drawLine(xc_py, yCenter, xc_py, yc_mx + 2*x, color);
-        break;
-      case DRAW_CORNERPOSITION_TOPLEFT:
+    }
+    if (position & DRAW_CORNERS_TOPLEFT)
+    {
         if ((xc_mx < lcdWidth) && (xc_mx >= 0)) drawLine(xc_mx, yc_my, xc_mx, yCenter, color);
         if ((xc_my < lcdWidth) && (xc_my >= 0)) drawLine(xc_my, yc_mx, xc_my, yCenter, color);
-        break;
-      case DRAW_CORNERPOSITION_BOTTOMLEFT:
+    }
+    if (position & DRAW_CORNERS_BOTTOMLEFT)
+    {
         if ((xc_mx < lcdWidth) && (xc_mx >= 0)) drawLine(xc_mx, yCenter, xc_mx, yc_my + 2*y, color);
         if ((xc_my < lcdWidth) && (xc_my >= 0)) drawLine(xc_my, yCenter, xc_my, yc_mx + 2*x, color);
-        break;
     }
   }
 }
@@ -740,12 +752,12 @@ void drawRectangleFilled ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, u
                 Which corners to round
 */
 /**************************************************************************/
-void drawRectangleRounded ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color, uint16_t radius, drawRoundedCorners_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 )
 {
   int height;
   uint16_t y;
 
-  if (corners == DRAW_ROUNDEDCORNERS_NONE)
+  if (corners == DRAW_CORNERS_NONE)
   {
     drawRectangleFilled(x0, y0, x1, y1, color);
     return;
@@ -772,41 +784,41 @@ void drawRectangleRounded ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
 
   switch (corners)
   {
-    case DRAW_ROUNDEDCORNERS_ALL:
-      drawCircleFilled(x0 + radius, y0 + radius, radius, color);
-      drawCircleFilled(x1 - radius, y0 + radius, radius, color);
-      drawCircleFilled(x0 + radius, y1 - radius, radius, color);
-      drawCircleFilled(x1 - radius, y1 - radius, radius, color);
+    case DRAW_CORNERS_ALL:
+      drawCornerFilled(x0 + radius, y0 + radius, radius, DRAW_CORNERS_TOPLEFT, color);
+      drawCornerFilled(x1 - radius, y0 + radius, radius, DRAW_CORNERS_TOPRIGHT, color);
+      drawCornerFilled(x0 + radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMLEFT, color);
+      drawCornerFilled(x1 - radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMRIGHT, color);
       if (radius*2+1 < height)
       {
         drawRectangleFilled(x0, y0 + radius, x0 + radius, y1 - radius, color);
         drawRectangleFilled(x1 - radius, y0 + radius, x1, y1 - radius, color);
       }
       break;
-    case DRAW_ROUNDEDCORNERS_TOP:
-      drawCircleFilled(x0 + radius, y0 + radius, radius, color);
-      drawCircleFilled(x1 - radius, y0 + radius, radius, color);
+    case DRAW_CORNERS_TOP:
+      drawCornerFilled(x0 + radius, y0 + radius, radius, DRAW_CORNERS_TOPLEFT, color);
+      drawCornerFilled(x1 - radius, y0 + radius, radius, DRAW_CORNERS_TOPRIGHT, color);
       drawRectangleFilled(x0, y0 + radius, x0 + radius, y1, color); 
       drawRectangleFilled(x1 - radius, y0 + radius, x1, y1, color); 
       break;
-    case DRAW_ROUNDEDCORNERS_BOTTOM:
-      drawCircleFilled(x0 + radius, y1 - radius, radius, color);
-      drawCircleFilled(x1 - radius, y1 - radius, radius, color);
+    case DRAW_CORNERS_BOTTOM:
+      drawCornerFilled(x0 + radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMLEFT, color);
+      drawCornerFilled(x1 - radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMRIGHT, color);
       drawRectangleFilled(x0, y0, x0 + radius, y1 - radius, color);
       drawRectangleFilled(x1 - radius, y0, x1, y1 - radius, color);
       break;
-    case DRAW_ROUNDEDCORNERS_LEFT:
-      drawCircleFilled(x0 + radius, y0 + radius, radius, color);
-      drawCircleFilled(x0 + radius, y1 - radius, radius, color);
+    case DRAW_CORNERS_LEFT:
+      drawCornerFilled(x0 + radius, y0 + radius, radius, DRAW_CORNERS_TOPLEFT, color);
+      drawCornerFilled(x0 + radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMLEFT, color);
       if (radius*2+1 < height)
       {
         drawRectangleFilled(x0, y0 + radius, x0 + radius, y1 - radius, color);
       }
       drawRectangleFilled(x1 - radius, y0, x1, y1, color);
       break;
-    case DRAW_ROUNDEDCORNERS_RIGHT:
-      drawCircleFilled(x1 - radius, y0 + radius, radius, color);
-      drawCircleFilled(x1 - radius, y1 - radius, radius, color);
+    case DRAW_CORNERS_RIGHT:
+      drawCornerFilled(x1 - radius, y0 + radius, radius, DRAW_CORNERS_TOPRIGHT, color);
+      drawCornerFilled(x1 - radius, y1 - radius, radius, DRAW_CORNERS_BOTTOMRIGHT, color);
       if (radius*2+1 < height)
       {
         drawRectangleFilled(x1 - radius, y0 + radius, x1, y1 - radius, color);
@@ -1032,120 +1044,6 @@ void drawTriangleFilled ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, ui
   }
 }
 
-/**************************************************************************/
-/*!
-    @brief  Draws a progress bar with rounded corners
-
-    @param[in]  x
-                Starting x location
-    @param[in]  y
-                Starting y location
-    @param[in]  width
-                Total width of the progress bar in pixels
-    @param[in]  height
-                Total height of the progress bar in pixels
-    @param[in]  borderCorners
-                The type of rounded corners to render with the progress bar border
-    @param[in]  progressCorners
-                The type of rounded corners to render with the inner progress bar
-    @param[in]  borderColor
-                16-bit color for the outer border
-    @param[in]  borderFillColor
-                16-bit color for the interior of the outer border
-    @param[in]  progressBorderColor
-                16-bit color for the progress bar's border
-    @param[in]  progressFillColor
-                16-bit color for the inner bar's fill
-    @param[in]  progress
-                Progress percentage (between 0 and 100)
-
-    @section Example
-
-    @code 
-    #include "drivers/displays/tft/drawing.h"
-
-    // Draw a the progress bar (150x15 pixels large, starting at X:10, Y:195
-    // with rounded corners on the top and showing 72% progress)
-    drawProgressBar(10, 195, 150, 15, DRAW_ROUNDEDCORNERS_TOP, DRAW_ROUNDEDCORNERS_TOP, COLOR_DARKERGRAY, COLOR_DARKGRAY, COLOR_LIMEGREENDIM, COLOR_LIMEGREEN, 72 );
-
-    @endcode
-*/
-/**************************************************************************/
-void drawProgressBar ( uint16_t x, uint16_t y, uint16_t width, uint16_t height, drawRoundedCorners_t borderCorners, drawRoundedCorners_t progressCorners, uint16_t borderColor, uint16_t borderFillColor, uint16_t progressBorderColor, uint16_t progressFillColor, uint8_t progress )
-{
-  // Draw border with rounded corners
-  drawRectangleRounded(x, y, x + width, y + height, borderColor, 5, borderCorners);
-  drawRectangleRounded(x+1, y+1, x + width - 1, y + height - 1, borderFillColor, 5, borderCorners);
-
-  // Progress bar
-  if (progress > 0 && progress <= 100)
-  {
-    // Calculate bar size
-    uint16_t bw;
-    bw = (width - 6);   // bar at 100%
-    if (progress != 100)
-    {
-      bw = (bw * progress) / 100;
-    } 
-    drawRectangleRounded(x + 3, y + 3, bw + x + 3, y + height - 3, progressBorderColor, 5, progressCorners);
-    drawRectangleRounded(x + 4, y + 4, bw + x + 3 - 1, y + height - 4, progressFillColor, 5, progressCorners);
-  }
-}
-
-/**************************************************************************/
-/*!
-    @brief  Draws a simple button
-
-    @param[in]  x
-                Starting x location
-    @param[in]  y
-                Starting y location
-    @param[in]  width
-                Total width of the button in pixels
-    @param[in]  height
-                Total height of the button in pixels
-    @param[in]  fontInfo
-                Pointer to the FONT_INFO used to render the button text
-    @param[in]  borderclr
-                The rgb565 border color
-    @param[in]  fillclr
-                The rgb565 background color
-    @param[in]  fontclr
-                The rgb565 font color
-    @param[in]  text
-                The text to render on the button
-
-    @section Example
-
-    @code 
-
-    #include "drivers/displays/tft/drawing.h"  
-    #include "drivers/displays/tft/fonts/dejavusans9.h"
-
-    // Draw two buttons using DejaVu Sans 9
-    drawButton(20, 195, 200, 35, &dejaVuSans9ptFontInfo, COLOR_GRAY_80, COLOR_GRAY_80, COLOR_WHITE, "System Settings");
-    drawButton(20, 235, 200, 35, &dejaVuSans9ptFontInfo, COLOR_THEME_LIMEGREEN_DARKER, COLOR_THEME_LIMEGREEN_BASE, COLOR_BLACK, "System Settings");
-
-    @endcode
-*/
-/**************************************************************************/
-void drawButton(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const FONT_INFO *fontInfo, uint16_t borderclr, uint16_t fillclr, uint16_t fontclr, char* text)
-{
-  // Border
-  drawRectangleRounded(x, y, x + width, y + height, borderclr, 5, DRAW_ROUNDEDCORNERS_ALL);
-  // Fill
-  drawRectangleRounded(x+2, y+2, x+width-2, y+height-2, fillclr, 5, DRAW_ROUNDEDCORNERS_ALL);
-
-  // Render text
-  if (text != NULL)
-  {
-    uint16_t textWidth = fontsGetStringWidth(&*fontInfo, text);
-    uint16_t xStart = x + (width / 2) - (textWidth / 2);
-    uint16_t yStart = y + (height / 2) - (fontInfo->height / 2) + 1;
-    fontsDrawString(xStart, yStart, fontclr, &*fontInfo, text);
-  }
-}
-
 /**************************************************************************/
 /*! 
     @brief  Renders a 16x16 monochrome icon using the supplied uint16_t
@@ -1199,54 +1097,3 @@ void drawIcon16(uint16_t x, uint16_t y, uint16_t color, uint16_t icon[])
     if (icon[i] & (0X0001)) drawPixel(x+15, y+i, color);
   }
 }
-
-#ifdef CFG_SDCARD
-/**************************************************************************/
-/*!
-    @brief  Loads a 24-bit Windows bitmap image from an SD card and
-            renders it
-
-    @section Example
-
-    @code 
-
-    #include "drivers/displays/tft/drawing.h"
-
-    // Draw image.bmp (from the root folder) starting at pixel 0,0
-    bmp_error_t error = drawBitmapImage(0, 0, "/image.bmp");
-
-    if (error)
-    {
-      switch (error)
-      {
-        case BMP_ERROR_SDINITFAIL:
-          break;
-        case BMP_ERROR_FILENOTFOUND:
-          break;
-        case BMP_ERROR_NOTABITMAP:
-          // First two bytes of image not 'BM'
-          break;
-        case BMP_ERROR_INVALIDBITDEPTH:
-          // Image is not 24-bits
-          break;
-        case BMP_ERROR_COMPRESSEDDATA:
-          // Image contains compressed data
-          break;
-        case BMP_ERROR_INVALIDDIMENSIONS:
-          // Width or Height is > LCD size
-          break;
-        case BMP_ERROR_PREMATUREEOF:
-          // EOF unexpectedly reached in pixel data
-          break;
-      }
-    }
-        
-    @endcode
-*/
-/**************************************************************************/
-bmp_error_t drawBitmapImage(uint16_t x, uint16_t y, char *filename)
-{
-  return bmpDrawBitmap(x, y, filename);
-}
-
-#endif
index 48a3c79..3b3257b 100644 (file)
 #include "projectconfig.h"
 #include "lcd.h"
 #include "colors.h"
-#include "fonts.h"
+#include "theme.h"
 
-#if defined CFG_TFTLCD_INCLUDESMALLFONTS & CFG_TFTLCD_INCLUDESMALLFONTS == 1
-  #include "drivers/displays/smallfonts.h"
+#if CFG_TFTLCD_USEAAFONTS
+  #include "aafonts.h"
+#else
+  #include "fonts.h"
 #endif
 
-#ifdef CFG_SDCARD
-  #include "bmp.h"
+#if CFG_TFTLCD_INCLUDESMALLFONTS
+  #include "drivers/displays/smallfonts.h"
 #endif
 
-typedef struct
-{
-  uint8_t red;
-  uint8_t green;
-  uint8_t blue;
-} drawColorRGB24_t;
-
 typedef enum
 {
-  DRAW_ROUNDEDCORNERS_NONE    = 0,
-  DRAW_ROUNDEDCORNERS_ALL     = 1,
-  DRAW_ROUNDEDCORNERS_TOP     = 2,
-  DRAW_ROUNDEDCORNERS_BOTTOM  = 3,
-  DRAW_ROUNDEDCORNERS_LEFT    = 4,
-  DRAW_ROUNDEDCORNERS_RIGHT   = 5
-} drawRoundedCorners_t;
-
-typedef enum
-{
-  DRAW_CORNERPOSITION_TOPLEFT     = 0,
-  DRAW_CORNERPOSITION_TOPRIGHT    = 1,
-  DRAW_CORNERPOSITION_BOTTOMLEFT  = 2,
-  DRAW_CORNERPOSITION_BOTTOMRIGHT = 3
-} drawCornerPosition_t;
+  DRAW_CORNERS_NONE        = 0x00,
+  DRAW_CORNERS_TOPLEFT     = 0x01,
+  DRAW_CORNERS_TOPRIGHT    = 0x02,
+  DRAW_CORNERS_BOTTOMLEFT  = 0x04,
+  DRAW_CORNERS_BOTTOMRIGHT = 0x08,
+  DRAW_CORNERS_ALL         = 0x0F, // 0x01 + 0x02 + 0x04 + 0x08
+  DRAW_CORNERS_TOP         = 0x03, // 0x01 + 0x02
+  DRAW_CORNERS_BOTTOM      = 0x0C, // 0x04 + 0x08
+  DRAW_CORNERS_LEFT        = 0x05, // 0x01 + 0x04
+  DRAW_CORNERS_RIGHT       = 0x0A  // 0x02 + 0x08
+} drawCorners_t;
 
 typedef enum
 {
@@ -89,24 +80,19 @@ void      drawLine             ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t
 void      drawLineDotted       ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t space, uint16_t solid, uint16_t color );
 void      drawCircle           ( uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint16_t color );
 void      drawCircleFilled     ( uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint16_t color );
-void      drawCornerFilled     (uint16_t xCenter, uint16_t yCenter, uint16_t radius, drawCornerPosition_t position, uint16_t color);
+void      drawCorner           ( uint16_t xCenter, uint16_t yCenter, uint16_t r, drawCorners_t corner, uint16_t color );
+void      drawCornerFilled     ( uint16_t xCenter, uint16_t yCenter, uint16_t radius, drawCorners_t position, uint16_t color );
 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      drawRectangleRounded ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color, uint16_t radius, drawRoundedCorners_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 );
 void      drawTriangleFilled   ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color );
-void      drawProgressBar      ( uint16_t x, uint16_t y, uint16_t width, uint16_t height, drawRoundedCorners_t borderCorners, drawRoundedCorners_t progressCorners, uint16_t borderColor, uint16_t borderFillColor, uint16_t progressBorderColor, uint16_t progressFillColor, uint8_t progress );
-void      drawButton           ( uint16_t x, uint16_t y, uint16_t width, uint16_t height, const FONT_INFO *fontInfo, uint16_t borderclr, uint16_t fillclr, uint16_t fontclr, char* text );
 void      drawIcon16           ( uint16_t x, uint16_t y, uint16_t color, uint16_t icon[] );
 
-#if defined CFG_TFTLCD_INCLUDESMALLFONTS & CFG_TFTLCD_INCLUDESMALLFONTS == 1
+#if CFG_TFTLCD_INCLUDESMALLFONTS
 void      drawStringSmall      ( uint16_t x, uint16_t y, uint16_t color, char* text, struct FONT_DEF font );
 #endif
 
-#if defined CFG_SDCARD
-bmp_error_t   drawBitmapImage  ( uint16_t x, uint16_t y, char *filename );
-#endif
-
 #endif
index 97f448b..6e31824 100644 (file)
@@ -43,7 +43,7 @@
 #include "drivers/storage/eeprom/eeprom.h"
 #include "drivers/displays/tft/lcd.h"
 #include "drivers/displays/tft/drawing.h"
-#include "drivers/displays/tft/fonts/dejavusans9.h"
+#include "drivers/displays/tft/controls/labelcentered.h"
 
 #define TS_LINE1 "Touch the center of"
 #define TS_LINE2 "the red circle using"
@@ -170,7 +170,7 @@ uint32_t tsReadY(void)
 /**************************************************************************/
 void tsCalibCenterText(char* text, uint16_t y, uint16_t color)
 {
-  fontsDrawString((lcdGetWidth() - fontsGetStringWidth(&dejaVuSans9ptFontInfo, text)) / 2, y, color, &dejaVuSans9ptFontInfo, text);
+  labelcenteredRender(lcdGetWidth()/2, y, COLOR_WHITE, color, text, THEME_DEFAULT);
 }
 
 /**************************************************************************/
diff --git a/main.c b/main.c
index 99f192a..ba5cd42 100644 (file)
--- a/main.c
+++ b/main.c
@@ -61,7 +61,7 @@ int main(void)
 
   uint32_t currentSecond, lastSecond;
   currentSecond = lastSecond = 0;
-  
+
   while (1)
   {
     // Toggle LED once per second
@@ -69,7 +69,7 @@ int main(void)
     if (currentSecond != lastSecond)
     {
       lastSecond = currentSecond;
-      gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, !(gpioGetValue(CFG_LED_PORT, CFG_LED_PIN)));
+      gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, lastSecond % 2);
     }
 
     // Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h
index a775021..c305d07 100644 (file)
@@ -118,7 +118,7 @@ cmd_t cmd_tbl[] =
   #endif
 
   #ifdef CFG_TFTLCD
-  { "b",    7,  99, 0, cmd_button            , "Button"                         , "'b <x> <y> <w> <h> <brdrclr> <fillclr> <fontclr> [<txt>]'" },
+  { "b",    5,  99, 0, cmd_button            , "Button"                         , "'b <x> <y> <w> <h> <fontclr> [<txt>]'" },
   #ifdef CFG_SDCARD
   { "B",    3,  3,  0, cmd_bmp               , "Bitmap (SD Card)"               , "'B <x> <y> <file>'" },
   #endif
@@ -131,11 +131,11 @@ cmd_t cmd_tbl[] =
   { "n",    5,  5,  0, cmd_roundedcorner     , "Rounded Corner"                 , "'n <x> <y> <radius> <corner> <color>'" },
   { "o",    0,  1,  0, cmd_orientation       , "LCD Orientation"                , "'o [<0|1>]'" },
   { "p",    3,  3,  0, cmd_pixel             , "Draw Pixel"                     , "'p <x> <y> <color>'" },
-  { "P",    9,  9,  0, cmd_progress          , "Progress Bar"                   , "'P <x> <y> <w> <h> <%> <bclr> <bfillclr> <pbrdclr> <pfillclr>'" },
+  { "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>'" },
   { "s",    2, 99,  0, cmd_textw             , "Text Width"                     , "'s <font#> <msg>'" },
-  { "t",    5, 99,  0, cmd_text              , "Text"                           , "'t <x> <y> <color> <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]>]'" },
   { "W",    0,  1,  0, cmd_tswait            , "Wait for Touch"                 , "'W [<ms>]'" },
   { "x",    0,  1,  0, cmd_tsthreshhold      , "Touch Threshold"                , "'x [<0..254>]'" },
index 4cb88d7..291b665 100644 (file)
@@ -45,6 +45,7 @@
 #if defined CFG_TFTLCD && defined CFG_SDCARD
   #include "drivers/displays/tft/lcd.h"    
   #include "drivers/displays/tft/drawing.h"  
+  #include "drivers/displays/tft/bmp.h"  
 
 /**************************************************************************/
 /*! 
@@ -63,7 +64,7 @@ void cmd_bmp(uint8_t argc, char **argv)
 
   // Render image
   bmp_error_t error;
-  error = drawBitmapImage(x, y, filename);
+  error = bmpDrawBitmap(x, y, filename);
 
   switch (error)
   {
index 6dcd77c..bfa321b 100644 (file)
@@ -47,7 +47,7 @@
   #include "drivers/displays/tft/lcd.h"    
   #include "drivers/displays/tft/drawing.h"  
   #include "drivers/displays/tft/touchscreen.h"
-  #include "drivers/displays/tft/fonts/dejavusans9.h"
+  #include "drivers/displays/tft/controls/button.h"
 
 /**************************************************************************/
 /*! 
@@ -60,7 +60,7 @@
 /**************************************************************************/
 void cmd_button(uint8_t argc, char **argv)
 {
-  int32_t x, y, w, h, border, fill, font;
+  int32_t x, y, w, h, fontcolor;
   
   // ToDo: Validate data!
 
@@ -69,31 +69,29 @@ void cmd_button(uint8_t argc, char **argv)
   getNumber (argv[1], &y);
   getNumber (argv[2], &w);
   getNumber (argv[3], &h);
-  getNumber (argv[4], &border);
-  getNumber (argv[5], &fill);
-  getNumber (argv[6], &font);
+  getNumber (argv[4], &fontcolor);
 
-  if (argc == 7)
+  if (argc == 5)
   {
     // Render the button with no text
-    drawButton(x, y, w, h, &dejaVuSans9ptFontInfo, (uint16_t)border, (uint16_t)fill, (uint16_t)font, NULL);
+    buttonRender(x, y, w, h, (uint16_t)fontcolor, NULL, THEME_DEFAULT);
   }
   else
   {
     // Get text contents
     uint8_t i, len, *data_ptr, data[50];
     data_ptr = data;
-    for (i = 0; i < argc - 7; i++)
+    for (i = 0; i < argc - 5; i++)
     {
-      len = strlen(argv[i + 7]);
-      strcpy((char *)data_ptr, (char *)argv[i + 7]);
+      len = strlen(argv[i + 5]);
+      strcpy((char *)data_ptr, (char *)argv[i + 5]);
       data_ptr += len;
       *data_ptr++ = ' ';
     }
     *data_ptr++ = '\0';
 
     // Render the button with text
-    drawButton(x, y, w, h, &dejaVuSans9ptFontInfo, (uint16_t)border, (uint16_t)fill, (uint16_t)font, (char *)&data);
+    buttonRender(x, y, w, h, (uint16_t)fontcolor, (char *)&data, THEME_DEFAULT);
   }
 }
 
index 0168e05..a8b9e56 100644 (file)
@@ -45,6 +45,7 @@
 #ifdef CFG_TFTLCD    
   #include "drivers/displays/tft/lcd.h"    
   #include "drivers/displays/tft/drawing.h"  
+  #include "drivers/displays/tft/controls/progressbar.h"
 
 /**************************************************************************/
 /*! 
@@ -53,7 +54,7 @@
 /**************************************************************************/
 void cmd_progress(uint8_t argc, char **argv)
 {
-  int32_t x, y, w, h, percent, border, borderfill, progressborder, progressfill;
+  int32_t x, y, w, h, percent, progressfill;
 
   // Convert supplied parameters
   getNumber (argv[0], &x);
@@ -61,13 +62,10 @@ void cmd_progress(uint8_t argc, char **argv)
   getNumber (argv[2], &w);
   getNumber (argv[3], &h);
   getNumber (argv[4], &percent);
-  getNumber (argv[5], &border);
-  getNumber (argv[6], &borderfill);
-  getNumber (argv[7], &progressborder);
-  getNumber (argv[8], &progressfill);
+  getNumber (argv[5], &progressfill);
 
   // ToDo: Validate data!
-  if (border < 0 || border > 0xFFFF || borderfill < 0 || borderfill > 0xFFFF || progressborder < 0 || progressborder > 0xFFFF || progressfill < 0 || progressfill > 0xFFFF)
+  if (progressfill < 0 || progressfill > 0xFFFF)
   {
     printf("Invalid Color%s", CFG_PRINTF_NEWLINE);
     return;
@@ -79,7 +77,7 @@ void cmd_progress(uint8_t argc, char **argv)
   }
 
   // Draw the progress bar (always use rounded corners for simplicity sake)
-  drawProgressBar(x, y, w, h, DRAW_ROUNDEDCORNERS_ALL, DRAW_ROUNDEDCORNERS_ALL, border, borderfill, progressborder, progressfill, percent);
+  progressbarRender(x, y, w, h, percent, progressfill, THEME_DEFAULT);
 }
 
 #endif  
index ff27504..05f039d 100644 (file)
@@ -125,7 +125,7 @@ void cmd_rectangleround(uint8_t argc, char **argv)
   }
   else
   {
-    drawRectangleRounded(x1, y1, x2, y2, (uint16_t)c, radius, corners);
+    drawRoundedRectangleFilled(x1, y1, x2, y2, (uint16_t)c, radius, corners);
   }
 }
 
index ad669d0..d25830f 100644 (file)
 #ifdef CFG_TFTLCD    
   #include "drivers/displays/tft/lcd.h"    
   #include "drivers/displays/tft/drawing.h"  
-  #include "drivers/displays/tft/fonts/dejavusans9.h"
-
-  // Only include this w/UART since there isn't enough space otherwise!
-  #ifdef CFG_PRINTF_UART
-  #include "drivers/displays/tft/fonts/dejavusansmono8.h"
-  #include "drivers/displays/tft/fonts/dejavusansbold9.h"
-  #endif
 
 /**************************************************************************/
 /*! 
@@ -61,7 +54,7 @@
 /**************************************************************************/
 void cmd_text(uint8_t argc, char **argv)
 {
-  int32_t x, y, color;
+  int32_t x, y, bgcolor, fontcolor;
   int32_t font;
   uint8_t i, len;
   char *data_ptr, data[80];
@@ -69,37 +62,39 @@ void cmd_text(uint8_t argc, char **argv)
   // Convert supplied parameters
   getNumber (argv[0], &x);
   getNumber (argv[1], &y);
-  getNumber (argv[2], &color);
-  getNumber (argv[3], &font);
+  getNumber (argv[2], &bgcolor);
+  getNumber (argv[3], &fontcolor);
+  getNumber (argv[4], &font);
 
   // Get message contents
   data_ptr = data;
-  for (i=0; i<argc-4; i++)
+  for (i=0; i<argc-5; i++)
   {
-    len = strlen(argv[i+4]);
-    strcpy((char *)data_ptr, (char *)argv[i+4]);
+    len = strlen(argv[i+5]);
+    strcpy((char *)data_ptr, (char *)argv[i+5]);
     data_ptr += len;
     *data_ptr++ = ' ';
   }
   *data_ptr++ = '\0';
 
-  // Only include this w/UART since there isn't enough space otherwise!
-  #ifdef CFG_PRINTF_UART
+  #if CFG_TFTLCD_USEAAFONTS
+    uint16_t ctable[4];
+    // Calculate 4 color lookup table using the appropriate fore and bg colors
+    // This should really be optimized out into theme.h!
+    aafontsCalculateColorTable(bgcolor, (uint16_t)fontcolor, &ctable[0], 4);
     switch (font)
     {
-      case 1:   // DejaVu Sans Mono 8
-        fontsDrawString((uint16_t)x, (uint16_t)y, (uint16_t)color, &dejaVuSansMono8ptFontInfo, (char *)&data);
-        break;
-      case 2:   // DejaVu Sans Bold 9
-        fontsDrawString((uint16_t)x, (uint16_t)y, (uint16_t)color, &dejaVuSansBold9ptFontInfo, (char *)&data);
-        break;
-      default:  // DejaVu Sans 9        
-        fontsDrawString((uint16_t)x, (uint16_t)y, (uint16_t)color, &dejaVuSans9ptFontInfo, (char *)&data);
+      default:  // Only enough space for the default font for now
+        aafontsDrawString((uint16_t)x, (uint16_t)y, ctable, &THEME_FONT, (char *)&data);
         break;
     }
   #else
-    // Always use Vera Mono 9 is used by default
-    fontsDrawString((uint16_t)x, (uint16_t)y, (uint16_t)color, &dejaVuSans9ptFontInfo, (char *)&data);
+    switch (font)
+    {
+      default:  // Only enough space for the default font for now
+        fontsDrawString((uint16_t)x, (uint16_t)y, (uint16_t)fontcolor, &THEME_FONT, (char *)&data);
+        break;
+    }
   #endif
 }
 
index fdcd0aa..151c344 100644 (file)
 #ifdef CFG_TFTLCD    
   #include "drivers/displays/tft/lcd.h"    
   #include "drivers/displays/tft/drawing.h"  
-  #include "drivers/displays/tft/fonts/dejavusans9.h"
-
-  // Only include this w/UART since there isn't enough space otherwise!
-  #ifdef CFG_PRINTF_UART
-  #include "drivers/displays/tft/fonts/dejavusansmono8.h"
-  #include "drivers/displays/tft/fonts/dejavusansbold9.h"
-  #endif
 
 /**************************************************************************/
 /*! 
@@ -79,26 +72,22 @@ void cmd_textw(uint8_t argc, char **argv)
   }
   *data_ptr++ = '\0';
 
-  // Only include this w/UART since there isn't enough space otherwise!
-  #ifdef CFG_PRINTF_UART
+  #if CFG_TFTLCD_USEAAFONTS
     switch (font)
     {
-      case 1:   // DejaVu Sans Mono 8
-        printf("%d %s", fontsGetStringWidth(&dejaVuSansMono8ptFontInfo, data), CFG_PRINTF_NEWLINE);
-        break;
-      case 2:   // DejaVu Sans Bold 9
-        printf("%d %s", fontsGetStringWidth(&dejaVuSansBold9ptFontInfo, data), CFG_PRINTF_NEWLINE);
-        break;
-      default:  // DejaVu Sans 9        
-        printf("%d %s", fontsGetStringWidth(&dejaVuSans9ptFontInfo, data), CFG_PRINTF_NEWLINE);
+      default:  // Only enough space for one font for now
+        printf("%d %s", aafontsGetStringWidth(&THEME_FONT, data), CFG_PRINTF_NEWLINE);
         break;
     }
   #else
-    // Always use DejaVu Sans 9 by default
-    printf("%d %s", fontsGetStringWidth(&dejaVuSans9ptFontInfo, data), CFG_PRINTF_NEWLINE);
+    switch (font)
+    {
+      default:  // Only enough space for one font for now
+        printf("%d %s", fontsGetStringWidth(&THEME_FONT, data), CFG_PRINTF_NEWLINE);
+        break;
+    }
   #endif
 
-
   return;
 }
 
index ac0366d..f0fc30c 100644 (file)
     FIRMWARE VERSION SETTINGS
     -----------------------------------------------------------------------*/
     #define CFG_FIRMWARE_VERSION_MAJOR            (1)
-    #define CFG_FIRMWARE_VERSION_MINOR            (0)
+    #define CFG_FIRMWARE_VERSION_MINOR            (1)
     #define CFG_FIRMWARE_VERSION_REVISION         (0)
 /*=========================================================================*/
 
                                 support for larger fonts generated with
                                 Dot Factory 
                                 http://www.pavius.net/downloads/tools/53-the-dot-factory
+    CFG_TFTLCD_USEAAFONTS       If set to a non-zero value, anti-aliased
+                                fonts will be used instead of regular 1-bit
+                                font.  These result in much higher-
+                                quality text, but the fonts are 2 or 4
+                                times larger than plain bitmap fonts and
+                                take a bit more rendering time to display.
     CFG_TFTLCD_TS_DEFAULTTHRESHOLD  Default minimum threshold to trigger a
                                 touch event with the touch screen (and exit
                                 from 'tsWaitForEvent' in touchscreen.c).
     #ifdef CFG_BRD_LPC1343_REFDESIGN
       // #define CFG_TFTLCD
       #define CFG_TFTLCD_INCLUDESMALLFONTS   (0)
+      #define CFG_TFTLCD_USEAAFONTS          (1)
       #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50)
       #define CFG_TFTLCD_TS_KEYPADDELAY      (100)
     #endif
     #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
       // #define CFG_TFTLCD
       #define CFG_TFTLCD_INCLUDESMALLFONTS   (0)
+      #define CFG_TFTLCD_USEAAFONTS          (0)
       #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50)
       #define CFG_TFTLCD_TS_KEYPADDELAY      (100)
     #endif
     #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
       #define CFG_TFTLCD
       #define CFG_TFTLCD_INCLUDESMALLFONTS   (0)
+      #define CFG_TFTLCD_USEAAFONTS          (1)
       #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50)
       #define CFG_TFTLCD_TS_KEYPADDELAY      (100)
     #endif
     #ifdef CFG_BRD_LPC1343_802154USBSTICK
       // #define CFG_TFTLCD
       #define CFG_TFTLCD_INCLUDESMALLFONTS   (0)
+      #define CFG_TFTLCD_USEAAFONTS          (0)
       #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50)
       #define CFG_TFTLCD_TS_KEYPADDELAY      (100)
     #endif
     #ifdef CFG_BRD_LPC1343_OLIMEX_P
       // #define CFG_TFTLCD
       #define CFG_TFTLCD_INCLUDESMALLFONTS   (0)
+      #define CFG_TFTLCD_USEAAFONTS          (0)
       #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50)
       #define CFG_TFTLCD_TS_KEYPADDELAY      (100)
     #endif     
     #ifdef CFG_BRD_LPC1343_LPCXPRESSO
       // #define CFG_TFTLCD
       #define CFG_TFTLCD_INCLUDESMALLFONTS   (0)
+      #define CFG_TFTLCD_USEAAFONTS          (0)
       #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50)
       #define CFG_TFTLCD_TS_KEYPADDELAY      (100)
     #endif
This page took 0.134278 seconds and 4 git commands to generate.