v1.0.0 reorg
authorKevin Townsend <kevin@ktownsend.com>
Fri, 23 Mar 2012 04:25:34 +0000 (05:25 +0100)
committerKevin Townsend <kevin@ktownsend.com>
Fri, 23 Mar 2012 04:25:34 +0000 (05:25 +0100)
17 files changed:
drivers/displays/tft/aafonts.c
drivers/displays/tft/aafonts.h
drivers/displays/tft/bmp.c
drivers/displays/tft/colors.h
drivers/displays/tft/dialogues/alphanumeric.c
drivers/displays/tft/drawing.c
drivers/displays/tft/drawing.h
drivers/displays/tft/fonts/dejavusans9.h
drivers/displays/tft/fonts/dejavusansbold9.h
drivers/displays/tft/fonts/dejavusanscondensed9.h
drivers/displays/tft/fonts/dejavusansmono8.h
drivers/displays/tft/fonts/dejavusansmonobold8.h
drivers/displays/tft/fonts/verdana14.h
drivers/displays/tft/fonts/verdana9.h
drivers/displays/tft/fonts/verdanabold14.h
drivers/displays/tft/hw/hx8340b.h
drivers/displays/tft/touchscreen.c

index 163b677..dc400b5 100644 (file)
 #include "drivers/displays/tft/lcd.h"
 #include "drivers/displays/tft/drawing.h"
 
 #include "drivers/displays/tft/lcd.h"
 #include "drivers/displays/tft/drawing.h"
 
+// Common color lookup tables for AA2 (4-color anti-aliased) fonts
+static const uint16_t COLORTABLE_AA2_WHITEONBLACK[4] = { 0x0000, 0x52AA, 0xAD55, 0xFFFF};
+static const uint16_t COLORTABLE_AA2_BLACKONWHITE[4] = { 0xFFFF, 0xAD55, 0x52AA, 0x0000};
+
+// Common color lookup tables for AA4 (16-color anti-aliased) fonts
+static const uint16_t COLORTABLE_AA4_WHITEONBLACK[16] = { 0x0000, 0x1082, 0x2104, 0x3186, 0x4208, 0x528A, 0x630C, 0x738E, 0x8410, 0x9492, 0xA514, 0xB596, 0xC618, 0xD69A, 0xE71C, 0xFFFF};
+static const uint16_t COLORTABLE_AA4_BLACKONWHITE[16] = { 0xFFFF, 0xE71C, 0xD69A, 0xC618, 0xB596, 0xA514, 0x9492, 0x8410, 0x738E, 0x630C, 0x528A, 0x4208, 0x3186, 0x2104, 0x1082, 0x0000};
+
 /**************************************************************************/
 /*                                                                        */
 /* ----------------------- Private Methods ------------------------------ */
 /**************************************************************************/
 /*                                                                        */
 /* ----------------------- Private Methods ------------------------------ */
@@ -66,9 +74,9 @@
                 Pointer to the 4 element color lookup table
 */
 /**************************************************************************/
                 Pointer to the 4 element color lookup table
 */
 /**************************************************************************/
-int aafontsDrawCharAA2( uint16_t x, uint16_t y, uint16_t height, aafontsCharInfo_t character, const uint16_t * colorTable)
+void aafontsDrawCharAA2( uint16_t x, uint16_t y, uint16_t height, aafontsCharInfo_t character, const uint16_t * colorTable)
 {
 {
-  uint16_t w, h, xp, yp, pos;
+  uint16_t w, h, pos;
   uint8_t color;
 
   for (h = 0; h < height; h++)
   uint8_t color;
 
   for (h = 0; h < height; h++)
@@ -121,9 +129,9 @@ int aafontsDrawCharAA2( uint16_t x, uint16_t y, uint16_t height, aafontsCharInfo
                 Pointer to the 16 element color lookup table
 */
 /**************************************************************************/
                 Pointer to the 16 element color lookup table
 */
 /**************************************************************************/
-int aafontsDrawCharAA4( uint16_t x, uint16_t y, uint16_t height, aafontsCharInfo_t character, const uint16_t * colorTable)
+void aafontsDrawCharAA4( uint16_t x, uint16_t y, uint16_t height, aafontsCharInfo_t character, const uint16_t * colorTable)
 {
 {
-  uint16_t w, h, xp, yp;
+  uint16_t w, h;
   uint8_t color;
 
   for (h = 0; h < height; h++)
   uint8_t color;
 
   for (h = 0; h < height; h++)
@@ -188,7 +196,6 @@ void aafontsDrawString(uint16_t x, uint16_t y, const uint16_t * colorTable, cons
 {
   uint16_t currentX, charWidth, characterToOutput;
   const aafontsCharInfo_t *charInfo;
 {
   uint16_t currentX, charWidth, characterToOutput;
   const aafontsCharInfo_t *charInfo;
-  uint16_t charOffset;
 
   // set current x, y to that of requested
   currentX = x;
 
   // set current x, y to that of requested
   currentX = x;
@@ -198,7 +205,6 @@ void aafontsDrawString(uint16_t x, uint16_t y, const uint16_t * colorTable, cons
   {
     // get character to output
     characterToOutput = *str;
   {
     // get character to output
     characterToOutput = *str;
-    uint16_t last = font->lastChar;
 
     // Check if the character is within the font boundaries
     if ((characterToOutput > font->lastChar) || (characterToOutput < font->firstChar))
 
     // Check if the character is within the font boundaries
     if ((characterToOutput > font->lastChar) || (characterToOutput < font->firstChar))
@@ -263,7 +269,6 @@ uint16_t aafontsGetStringWidth(const aafontsFont_t *font, char *str)
   uint16_t width = 0;
   const aafontsCharInfo_t *charInfo;
   uint32_t currChar;
   uint16_t width = 0;
   const aafontsCharInfo_t *charInfo;
   uint32_t currChar;
-  uint32_t startChar = font->firstChar;
 
   // until termination
   for (currChar = *str; currChar; currChar = *(++str))
 
   // until termination
   for (currChar = *str; currChar; currChar = *(++str))
index f76d35a..c510eaf 100644 (file)
@@ -64,14 +64,6 @@ typedef struct aafontsFont_s
   const aafontsCharInfo_t *charTable;   /* Pointer to the aafontsCharInfo_t array containing the char data */
 } aafontsFont_t;
 
   const aafontsCharInfo_t *charTable;   /* Pointer to the aafontsCharInfo_t array containing the char data */
 } aafontsFont_t;
 
-// Common color lookup tables for AA2 (4-color anti-aliased) fonts
-const uint16_t COLORTABLE_AA2_WHITEONBLACK[4] = { 0x0000, 0x52AA, 0xAD55, 0xFFFF};
-const uint16_t COLORTABLE_AA2_BLACKONWHITE[4] = { 0xFFFF, 0xAD55, 0x52AA, 0x0000};
-
-// Common color lookup tables for AA4 (16-color anti-aliased) fonts
-const uint16_t COLORTABLE_AA4_WHITEONBLACK[16] = { 0x0000, 0x1082, 0x2104, 0x3186, 0x4208, 0x528A, 0x630C, 0x738E, 0x8410, 0x9492, 0xA514, 0xB596, 0xC618, 0xD69A, 0xE71C, 0xFFFF};
-const uint16_t COLORTABLE_AA4_BLACKONWHITE[16] = { 0xFFFF, 0xE71C, 0xD69A, 0xC618, 0xB596, 0xA514, 0x9492, 0x8410, 0x738E, 0x630C, 0x528A, 0x4208, 0x3186, 0x2104, 0x1082, 0x0000};
-
 uint16_t  aafontsBlendColor ( uint16_t bgColor, uint16_t foreColor, uint8_t intensity );
 void      aafontsDrawString( 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 );
 uint16_t  aafontsBlendColor ( uint16_t bgColor, uint16_t foreColor, uint8_t intensity );
 void      aafontsDrawString( 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 );
index a378a86..7554645 100644 (file)
@@ -122,7 +122,7 @@ bmp_error_t bmpParseBitmap(uint16_t x, uint16_t y, FIL file)
       // Render pixel
       // ToDo: This is a brutally slow way of rendering bitmaps ...
       //        update to pass one row of data at a time
       // Render pixel
       // ToDo: This is a brutally slow way of rendering bitmaps ...
       //        update to pass one row of data at a time
-      drawPixel(x + px, y + py - 1, drawRGB24toRGB565(buffer[(px * 3) + 2], buffer[(px * 3) + 1], buffer[(px * 3)]));
+      drawPixel(x + px, y + py - 1, colorsRGB24toRGB565(buffer[(px * 3) + 2], buffer[(px * 3) + 1], buffer[(px * 3)]));
     }
   }
 
     }
   }
 
@@ -326,7 +326,7 @@ bmp_error_t bmpSaveScreenshot(const char* filename)
     for (x = 0; x < lcdWidth; x++)
     {
       rgb565 = lcdGetPixel(x, y - 1);               // Get RGB565 pixel
     for (x = 0; x < lcdWidth; x++)
     {
       rgb565 = lcdGetPixel(x, y - 1);               // Get RGB565 pixel
-      bgra32 = drawRGB565toBGRA32(rgb565);          // Convert RGB565 to 24-bit color
+      bgra32 = colorsRGB565toBGRA32(rgb565);          // Convert RGB565 to 24-bit color
       r = (bgra32 & 0x00FF0000) >> 16;
       g = (bgra32 & 0x0000FF00) >> 8;
       b = (bgra32 & 0x000000FF);
       r = (bgra32 & 0x00FF0000) >> 16;
       g = (bgra32 & 0x0000FF00) >> 8;
       b = (bgra32 & 0x000000FF);
index eb39265..22f996a 100644 (file)
 #define COLOR_THEME_DEFAULT_SHADOW          COLOR_THEME_LIMEGREEN_SHADOW
 #define COLOR_THEME_DEFAULT_ACCENT          COLOR_THEME_LIMEGREEN_ACCENT
 
 #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 );
+uint16_t colorsDim            ( uint16_t color, uint8_t intensity );
+uint16_t colorsBlend          ( uint16_t bgColor, uint16_t foreColor, uint8_t intensity );
+
 #endif
 #endif
index 1912779..a3c14f6 100644 (file)
@@ -172,21 +172,21 @@ void alphaRenderButton(uint8_t alphaPage, uint8_t col, uint8_t row, bool selecte
   {
     case '<':
       // Backspace
   {
     case '<':
       // Backspace
-      drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, &dejaVuSans9ptFontInfo, 7, border, fill, font, NULL); 
+      drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, ALPHA_BTN_HEIGHT, &dejaVuSans9ptFontInfo, border, fill, font, NULL); 
       drawArrow (alphaBtnX[col] + ALPHA_BTN_WIDTH / 2 - 3, alphaBtnY[row] + ALPHA_BTN_HEIGHT / 2, 7, DRAW_DIRECTION_LEFT, font);
       break;
     case '*':
       // Page Shift
       drawArrow (alphaBtnX[col] + ALPHA_BTN_WIDTH / 2 - 3, alphaBtnY[row] + ALPHA_BTN_HEIGHT / 2, 7, DRAW_DIRECTION_LEFT, font);
       break;
     case '*':
       // Page Shift
-      drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, &dejaVuSans9ptFontInfo, 7, border, fill, font, NULL); 
+      drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, ALPHA_BTN_HEIGHT, &dejaVuSans9ptFontInfo, border, fill, font, NULL); 
       drawArrow (alphaBtnX[col] + ALPHA_BTN_WIDTH / 2, (alphaBtnY[row] + ALPHA_BTN_HEIGHT / 2) - 3, 7, DRAW_DIRECTION_UP, font);
       break;
     case '>':
       // OK
       drawArrow (alphaBtnX[col] + ALPHA_BTN_WIDTH / 2, (alphaBtnY[row] + ALPHA_BTN_HEIGHT / 2) - 3, 7, DRAW_DIRECTION_UP, font);
       break;
     case '>':
       // OK
-      drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, &dejaVuSans9ptFontInfo, 7, border, fill, font, "OK"); 
+      drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, ALPHA_BTN_HEIGHT, &dejaVuSans9ptFontInfo, border, fill, font, "OK"); 
       break;
     default:
       // Standard character
       break;
     default:
       // Standard character
-      drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, &dejaVuSans9ptFontInfo, 7, border, fill, font, key); 
+      drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, ALPHA_BTN_HEIGHT, &dejaVuSans9ptFontInfo, border, fill, font, key); 
       break;
   }
 }
       break;
   }
 }
@@ -211,7 +211,7 @@ void alphaRefreshScreen(void)
 
   /* Render Text */
   drawRectangleRounded(ALPHA_BTN_SPACING, ALPHA_BTN_SPACING, lcdGetWidth() - 1 - ALPHA_BTN_SPACING, ALPHA_KEYPAD_TOP - ALPHA_BTN_SPACING, ALPHA_COLOR_INPUTFILL, 10, DRAW_ROUNDEDCORNERS_ALL);
 
   /* Render Text */
   drawRectangleRounded(ALPHA_BTN_SPACING, ALPHA_BTN_SPACING, lcdGetWidth() - 1 - ALPHA_BTN_SPACING, ALPHA_KEYPAD_TOP - ALPHA_BTN_SPACING, ALPHA_COLOR_INPUTFILL, 10, DRAW_ROUNDEDCORNERS_ALL);
-  drawString(ALPHA_BTN_SPACING * 3, ALPHA_BTN_SPACING * 3, ALPHA_COLOR_INPUTTEXT, &dejaVuSans9ptFontInfo, (char *)&alphaString);
+  fontsDrawString(ALPHA_BTN_SPACING * 3, ALPHA_BTN_SPACING * 3, ALPHA_COLOR_INPUTTEXT, &dejaVuSans9ptFontInfo, (char *)&alphaString);
 }
 
 /**************************************************************************/
 }
 
 /**************************************************************************/
index b7da3a3..8161465 100644 (file)
@@ -6,9 +6,6 @@
     drawLine and drawCircle adapted from a tutorial by Leonard McMillan:
     http://www.cs.unc.edu/~mcmillan/
 
     drawLine and drawCircle adapted from a tutorial by Leonard McMillan:
     http://www.cs.unc.edu/~mcmillan/
 
-    drawString based on an example from Eran Duchan:
-    http://www.pavius.net/downloads/tools/53-the-dot-factory
-
     @section LICENSE
 
     Software License Agreement (BSD License)
     @section LICENSE
 
     Software License Agreement (BSD License)
@@ -66,50 +63,6 @@ void drawSwap(uint32_t a, uint32_t b)
   b = t;
 }
 
   b = t;
 }
 
-/**************************************************************************/
-/*!
-    @brief  Draws a single bitmap character
-*/
-/**************************************************************************/
-void drawCharBitmap(const uint16_t xPixel, const uint16_t yPixel, uint16_t color, const char *glyph, uint8_t cols, uint8_t rows)
-{
-  uint16_t currentY, currentX, indexIntoGlyph;
-  uint16_t _row, _col, _colPages;
-
-  // set initial current y
-  currentY = yPixel;
-  currentX = xPixel;
-
-  // Figure out how many columns worth of data we have
-  if (cols % 8)
-    _colPages = cols / 8 + 1;
-  else
-    _colPages = cols / 8;
-
-  for (_row = 0; _row < rows; _row++)
-  {
-    for (_col = 0; _col < _colPages; _col++)
-    {
-      if (_row == 0)
-        indexIntoGlyph = _col;
-      else
-        indexIntoGlyph = (_row * _colPages) + _col;
-
-      currentY = yPixel + _row;
-      currentX = xPixel + (_col*8);
-      // send the data byte
-      if (glyph[indexIntoGlyph] & (0X80)) drawPixel(currentX, currentY, color);
-      if (glyph[indexIntoGlyph] & (0X40)) drawPixel(currentX+1, currentY, color);
-      if (glyph[indexIntoGlyph] & (0X20)) drawPixel(currentX+2, currentY, color);
-      if (glyph[indexIntoGlyph] & (0X10)) drawPixel(currentX+3, currentY, color);
-      if (glyph[indexIntoGlyph] & (0X08)) drawPixel(currentX+4, currentY, color);
-      if (glyph[indexIntoGlyph] & (0X04)) drawPixel(currentX+5, currentY, color);
-      if (glyph[indexIntoGlyph] & (0X02)) drawPixel(currentX+6, currentY, color);
-      if (glyph[indexIntoGlyph] & (0X01)) drawPixel(currentX+7, currentY, color);
-    }
-  }
-}
-
 #if defined CFG_TFTLCD_INCLUDESMALLFONTS & CFG_TFTLCD_INCLUDESMALLFONTS == 1
 /**************************************************************************/
 /*!
 #if defined CFG_TFTLCD_INCLUDESMALLFONTS & CFG_TFTLCD_INCLUDESMALLFONTS == 1
 /**************************************************************************/
 /*!
@@ -281,128 +234,6 @@ void drawStringSmall(uint16_t x, uint16_t y, uint16_t color, char* text, struct
 }
 #endif
 
 }
 #endif
 
-/**************************************************************************/
-/*!
-    @brief  Draws a string using the supplied font
-
-    @param[in]  x
-                Starting x co-ordinate
-    @param[in]  y
-                Starting y co-ordinate
-    @param[in]  color
-                Color to use when rendering the font
-    @param[in]  fontInfo
-                Pointer to the FONT_INFO to use when drawing the string
-    @param[in]  str
-                The string to render
-
-    @section Example
-
-    @code 
-
-    #include "drivers/displays/tft/fonts/dejavusans9.h"
-    
-    drawString(0, 90,  COLOR_BLACK, &dejaVuSans9ptFontInfo, "DejaVu Sans 9");
-    drawString(0, 105, COLOR_BLACK, &dejaVuSans9ptFontInfo, "123456789012345678901234567890");
-
-    @endcode
-*/
-/**************************************************************************/
-void drawString(uint16_t x, uint16_t y, uint16_t color, const FONT_INFO *fontInfo, char *str)
-{
-  uint16_t currentX, charWidth, characterToOutput;
-  const FONT_CHAR_INFO *charInfo;
-  uint16_t charOffset;
-
-  // set current x, y to that of requested
-  currentX = x;
-
-  // while not NULL
-  while (*str != '\0')
-  {
-    // get character to output
-    characterToOutput = *str;
-    
-    // get char info
-    charInfo = fontInfo->charInfo;
-    
-    // some fonts have character descriptors, some don't
-    if (charInfo != NULL)
-    {
-      // get correct char offset
-      charInfo += (characterToOutput - fontInfo->startChar);
-      
-      // get width from char info
-      charWidth = charInfo->widthBits;
-      
-      // get offset from char info
-      charOffset = charInfo->offset;
-    }        
-    else
-    {
-      // if no char info, char width is always 5
-      charWidth = 5;
-      
-      // char offset - assume 5 * letter offset
-      charOffset = (characterToOutput - fontInfo->startChar) * 5;
-    }        
-    
-    // Send individual characters
-    // We need to manually calculate width in pages since this is screwy with variable width fonts
-    //uint8_t heightPages = charWidth % 8 ? charWidth / 8 : charWidth / 8 + 1;
-    drawCharBitmap(currentX, y, color, (const char *)(&fontInfo->data[charOffset]), charWidth, fontInfo->height);
-
-    // next char X
-    currentX += charWidth + 1;
-    
-    // next char
-    str++;
-  }
-}
-
-/**************************************************************************/
-/*!
-    @brief  Returns the width in pixels of a string when it is rendered
-
-    This method can be used to determine whether a string will fit
-    inside a specific area, or if it needs to be broken up into multiple
-    lines to be properly rendered on the screen.
-
-    This function only applied to bitmap fonts (which can have variable
-    widths).  All smallfonts (if available) are fixed width and can
-    easily have their width calculated without costly functions like
-    this one.
-
-    @param[in]  fontInfo
-                Pointer to the FONT_INFO for the font that will be used
-    @param[in]  str
-                The string that will be rendered
-*/
-/**************************************************************************/
-uint16_t drawGetStringWidth(const FONT_INFO *fontInfo, char *str)
-{
-  uint16_t width = 0;
-  uint32_t currChar;
-  uint32_t startChar = fontInfo->startChar;
-
-  // until termination
-  for (currChar = *str; currChar; currChar = *(++str))
-  {
-    // if char info exists for the font, use width from there
-    if (fontInfo->charInfo != NULL)
-    {
-      width += fontInfo->charInfo[currChar - startChar].widthBits + 1;
-    }
-    else
-    {
-      width += 5 + 1;
-    }
-  }
-
-  /* return the width */
-  return width > 0 ? width - 1 : width;
-}
-
 /**************************************************************************/
 /*!
     @brief  Draws a bresenham line
 /**************************************************************************/
 /*!
     @brief  Draws a bresenham line
@@ -987,6 +818,104 @@ void drawRectangleRounded ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
   }
 }
 
   }
 }
 
+/**************************************************************************/
+/*!
+    @brief  Draws a gradient-filled rectangle
+
+    @param[in]  x0
+                Starting x co-ordinate
+    @param[in]  y0
+                Starting y co-ordinate
+    @param[in]  x1
+                Ending x co-ordinate
+    @param[in]  y1
+                Ending y co-ordinate
+    @param[in]  startColor
+                The color at the start of the gradient
+    @param[in]  endColor
+                The color at the end of the gradient
+
+    @section EXAMPLE
+
+    @code
+
+    #include "drivers/displays/tft/drawing.h"
+    #include "drivers/displays/tft/aafonts.h"
+    #include "drivers/displays/tft/aafonts/aa2/DejaVuSansCondensed14_AA2.h"
+
+    // Draw a gradient-filled rectangle with anti-aliased text inside it
+
+    uint16_t btnWidth, btnHeight, btnX, btnY;
+    uint16_t fntX, fntY;
+
+    btnWidth = 200;
+    btnHeight = 20;
+    btnX = 10;
+    btnY = 30;
+
+    lcdFillRGB(0xFFFF);
+
+    drawRectangle(btnX-1, btnY-1, btnX+btnWidth+1, btnY+btnHeight+1, COLOR_GRAY_80);
+    drawGradient(btnX, btnY, btnX+btnWidth, btnY+btnHeight, COLOR_WHITE, COLOR_GRAY_128);
+
+    // Center text vertically and horizontally
+    fntY = btnY + ((btnHeight - DejaVuSansCondensed14_AA2.fontHeight) / 2);
+    fntX = btnX + ((btnWidth - aafontsGetStringWidth(&DejaVuSansCondensed14_AA2, "Click to continue"))/2);
+    aafontsDrawString(fntX, fntY, COLORTABLE_AA2_BLACKONWHITE, &DejaVuSansCondensed14_AA2, "Click to continue");
+
+    @endcode
+*/
+/**************************************************************************/
+void drawGradient ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t startColor, uint16_t endColor)
+{
+  int height;
+  uint16_t x, y;
+  uint8_t r, g, b;
+  int16_t rDelta, gDelta, bDelta;
+
+  // Clear gradient steps, etc.
+  r = g = b = 0;
+  rDelta = gDelta = bDelta = 0;
+
+  if (y1 < y0)
+  {
+    // Switch y1 and y0
+    y = y1;
+    y1 = y0;
+    y0 = y;
+  }
+
+  if (x1 < x0)
+  {
+    // Switch x1 and x0
+    x = x1;
+    x1 = x0;
+    x0 = x;
+  }
+
+  height = y1 - y0;
+
+  // Calculate global r/g/b changes between start and end colors
+  rDelta = ((endColor >> 11) & 0x1F) - ((startColor >> 11) & 0x1F);
+  gDelta = ((endColor >> 5) & 0x3F) - ((startColor >> 5) & 0x3F);
+  bDelta = (endColor & 0x1F) - (startColor & 0x1F);
+
+  // Calculate interpolation deltas to 2 decimal places (fixed point)
+  rDelta = (rDelta * 100) / height;
+  gDelta = (gDelta * 100) / height;
+  bDelta = (bDelta * 100) / height;
+
+  // Draw individual lines
+  for (height = y0; y1 > height - 1; ++height)
+  {
+    // Calculate new rgb values based on: start color + (line number * interpolation delta)
+    r = ((startColor >> 11) & 0x1F) + ((rDelta * (height - y0)) / 100);
+    g = ((startColor >> 5) & 0x3F) + ((gDelta * (height - y0)) / 100);
+    b = (startColor & 0x1F) + ((bDelta * (height - y0)) / 100);
+    drawLine(x0, height, x1, height, ((r & 0x1F) << 11) | ((g & 0x3F) << 5) | (b & 0x1F));
+  }
+}
+
 /**************************************************************************/
 /*!
     @brief  Draws a triangle
 /**************************************************************************/
 /*!
     @brief  Draws a triangle
@@ -1103,88 +1032,6 @@ void drawTriangleFilled ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, ui
   }
 }
 
   }
 }
 
-/**************************************************************************/
-/*!
-    @brief  Converts a 24-bit RGB color to an equivalent 16-bit RGB565 value
-
-    @param[in]  r
-                8-bit red
-    @param[in]  g
-                8-bit green
-    @param[in]  b
-                8-bit blue
-
-    @section Example
-
-    @code 
-
-    // Get 16-bit equivalent of 24-bit color
-    uint16_t gray = drawRGB24toRGB565(0x33, 0x33, 0x33);
-
-    @endcode
-*/
-/**************************************************************************/
-uint16_t drawRGB24toRGB565(uint8_t r, uint8_t g, uint8_t b)
-{
-  return ((r / 8) << 11) | ((g / 4) << 5) | (b / 8);
-}
-
-/**************************************************************************/
-/*!
-    @brief  Converts a 16-bit RGB565 color to a standard 32-bit BGRA32
-            color (with alpha set to 0xFF)
-
-    @param[in]  color
-                16-bit rgb565 color
-
-    @section Example
-
-    @code 
-
-    // First convert 24-bit color to RGB565
-    uint16_t rgb565 = drawRGB24toRGB565(0xFF, 0x00, 0x00);
-  
-    // Convert RGB565 color back to BGRA32
-    uint32_t bgra32 = drawRGB565toBGRA32(rgb565);
-  
-    // Display results
-    printf("BGRA32: 0x%08X R: %u G: %u B: %u A: %u \r\n", 
-        bgra32, 
-        (bgra32 & 0x000000FF),        // Blue
-        (bgra32 & 0x0000FF00) >> 8,   // Green
-        (bgra32 & 0x00FF0000) >> 16,  // Red
-        (bgra32 & 0xFF000000) >> 24); // Alpha
-
-    @endcode
-*/
-/**************************************************************************/
-uint32_t drawRGB565toBGRA32(uint16_t color)
-{
-  uint32_t bits = (uint32_t)color;
-  uint32_t blue = bits & 0x001F;     // 5 bits blue
-  uint32_t green = bits & 0x07E0;    // 6 bits green
-  uint32_t red = bits & 0xF800;      // 5 bits red
-
-  // Return shifted bits with alpha set to 0xFF
-  return (red << 8) | (green << 5) | (blue << 3) | 0xFF000000;
-}
-
-/**************************************************************************/
-/*! 
-    @brief  Reverses a 16-bit color from BGR to RGB
-*/
-/**************************************************************************/
-uint16_t drawBGR2RGB(uint16_t color)
-{   
-  uint16_t r, g, b;   
-   
-  b = (color>>0)  & 0x1f;   
-  g = (color>>5)  & 0x3f;   
-  r = (color>>11) & 0x1f;   
-     
-  return( (b<<11) + (g<<5) + (r<<0) );
-}
-
 /**************************************************************************/
 /*!
     @brief  Draws a progress bar with rounded corners
 /**************************************************************************/
 /*!
     @brief  Draws a progress bar with rounded corners
@@ -1275,7 +1122,7 @@ void drawProgressBar ( uint16_t x, uint16_t y, uint16_t width, uint16_t height,
     #include "drivers/displays/tft/drawing.h"  
     #include "drivers/displays/tft/fonts/dejavusans9.h"
 
     #include "drivers/displays/tft/drawing.h"  
     #include "drivers/displays/tft/fonts/dejavusans9.h"
 
-    // Draw two buttons using Vera Sans Bold 9
+    // 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");
 
     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");
 
@@ -1292,10 +1139,10 @@ void drawButton(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const F
   // Render text
   if (text != NULL)
   {
   // Render text
   if (text != NULL)
   {
-    uint16_t textWidth = drawGetStringWidth(&*fontInfo, text);
+    uint16_t textWidth = fontsGetStringWidth(&*fontInfo, text);
     uint16_t xStart = x + (width / 2) - (textWidth / 2);
     uint16_t yStart = y + (height / 2) - (fontInfo->height / 2) + 1;
     uint16_t xStart = x + (width / 2) - (textWidth / 2);
     uint16_t yStart = y + (height / 2) - (fontInfo->height / 2) + 1;
-    drawString(xStart, yStart, fontclr, &*fontInfo, text);
+    fontsDrawString(xStart, yStart, fontclr, &*fontInfo, text);
   }
 }
 
   }
 }
 
index 5009d3b..48a3c79 100644 (file)
@@ -2,14 +2,12 @@
 /*! 
     @file     drawing.h
     @author   K. Townsend (microBuilder.eu)
 /*! 
     @file     drawing.h
     @author   K. Townsend (microBuilder.eu)
-    @date     22 March 2010
-    @version  0.10
 
     @section LICENSE
 
     Software License Agreement (BSD License)
 
 
     @section LICENSE
 
     Software License Agreement (BSD License)
 
-    Copyright (c) 2010, microBuilder SARL
+    Copyright (c) 2012, microBuilder SARL
     All rights reserved.
 
     Redistribution and use in source and binary forms, with or without
     All rights reserved.
 
     Redistribution and use in source and binary forms, with or without
@@ -41,7 +39,7 @@
 #include "projectconfig.h"
 #include "lcd.h"
 #include "colors.h"
 #include "projectconfig.h"
 #include "lcd.h"
 #include "colors.h"
-#include "drivers/displays/tft/fonts/bitmapfonts.h"
+#include "fonts.h"
 
 #if defined CFG_TFTLCD_INCLUDESMALLFONTS & CFG_TFTLCD_INCLUDESMALLFONTS == 1
   #include "drivers/displays/smallfonts.h"
 
 #if defined CFG_TFTLCD_INCLUDESMALLFONTS & CFG_TFTLCD_INCLUDESMALLFONTS == 1
   #include "drivers/displays/smallfonts.h"
@@ -96,16 +94,12 @@ void      drawArrow            ( uint16_t x, uint16_t y, uint16_t size, drawDire
 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      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      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      drawString           ( uint16_t x, uint16_t y, uint16_t color, const FONT_INFO *fontInfo, char *str );
-uint16_t  drawGetStringWidth   ( const FONT_INFO *fontInfo, char *str );
+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[] );
 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[] );
-uint16_t  drawRGB24toRGB565    ( uint8_t r, uint8_t g, uint8_t b );
-uint32_t  drawRGB565toBGRA32   ( uint16_t color );
-uint16_t  drawBGR2RGB          ( uint16_t color );
 
 #if defined CFG_TFTLCD_INCLUDESMALLFONTS & CFG_TFTLCD_INCLUDESMALLFONTS == 1
 void      drawStringSmall      ( uint16_t x, uint16_t y, uint16_t color, char* text, struct FONT_DEF font );
 
 #if defined CFG_TFTLCD_INCLUDESMALLFONTS & CFG_TFTLCD_INCLUDESMALLFONTS == 1
 void      drawStringSmall      ( uint16_t x, uint16_t y, uint16_t color, char* text, struct FONT_DEF font );
index c5f4af0..fd9d00f 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __DEJA_VU_SANS_9__
 #define __DEJA_VU_SANS_9__
 
 #ifndef __DEJA_VU_SANS_9__
 #define __DEJA_VU_SANS_9__
 
-#include "bitmapfonts.h"
+#include "../fonts.h"
 
 extern const uint8_t dejaVuSans9ptCharBitmaps[];
 extern const FONT_CHAR_INFO dejaVuSans9ptCharDescriptors[];
 
 extern const uint8_t dejaVuSans9ptCharBitmaps[];
 extern const FONT_CHAR_INFO dejaVuSans9ptCharDescriptors[];
index d4b6490..3521ef9 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __DEJA_VU_SANS_BOLD_9__
 #define __DEJA_VU_SANS_BOLD_9__
 
 #ifndef __DEJA_VU_SANS_BOLD_9__
 #define __DEJA_VU_SANS_BOLD_9__
 
-#include "bitmapfonts.h"
+#include "../fonts.h"
 
 extern const uint8_t dejaVuSansBold9ptCharBitmaps[];
 extern const FONT_CHAR_INFO dejaVuSansBold9ptCharDescriptors[];
 
 extern const uint8_t dejaVuSansBold9ptCharBitmaps[];
 extern const FONT_CHAR_INFO dejaVuSansBold9ptCharDescriptors[];
index a07c51f..0a751fe 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __DEJA_VU_SANS_CONDENSED_9__
 #define __DEJA_VU_SANS_CONDENSED_9__
 
 #ifndef __DEJA_VU_SANS_CONDENSED_9__
 #define __DEJA_VU_SANS_CONDENSED_9__
 
-#include "bitmapfonts.h"
+#include "../fonts.h"
 
 extern const uint8_t dejaVuSansCondensed9ptCharBitmaps[];
 extern const FONT_CHAR_INFO dejaVuSansCondensed9ptCharDescriptors[];
 
 extern const uint8_t dejaVuSansCondensed9ptCharBitmaps[];
 extern const FONT_CHAR_INFO dejaVuSansCondensed9ptCharDescriptors[];
index 3310409..f831837 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __DEJA_VU_SANS_MONO_8__
 #define __DEJA_VU_SANS_MONO_8__
 
 #ifndef __DEJA_VU_SANS_MONO_8__
 #define __DEJA_VU_SANS_MONO_8__
 
-#include "bitmapfonts.h"
+#include "../fonts.h"
 
 extern const uint8_t dejaVuSansMono8ptCharBitmaps[];
 extern const FONT_CHAR_INFO dejaVuSansMono8ptCharDescriptors[];
 
 extern const uint8_t dejaVuSansMono8ptCharBitmaps[];
 extern const FONT_CHAR_INFO dejaVuSansMono8ptCharDescriptors[];
index 4a38f88..6fc8a24 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __DEJA_VU_SANS_MONO_BOLD_8__
 #define __DEJA_VU_SANS_MONO_BOLD_8__
 
 #ifndef __DEJA_VU_SANS_MONO_BOLD_8__
 #define __DEJA_VU_SANS_MONO_BOLD_8__
 
-#include "bitmapfonts.h"
+#include "../fonts.h"
 
 extern const uint8_t dejaVuSansMonoBold8ptCharBitmaps[];
 extern const FONT_CHAR_INFO dejaVuSansMonoBold8ptCharDescriptors[];
 
 extern const uint8_t dejaVuSansMonoBold8ptCharBitmaps[];
 extern const FONT_CHAR_INFO dejaVuSansMonoBold8ptCharDescriptors[];
index 9a84419..f1a619c 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __VERDANA_14__
 #define __VERDANA_14__
 
 #ifndef __VERDANA_14__
 #define __VERDANA_14__
 
-#include "bitmapfonts.h"
+#include "../fonts.h"
 
 /* Font data for Verdana 14pt */
 extern const uint8_t verdana14ptBitmaps[];
 
 /* Font data for Verdana 14pt */
 extern const uint8_t verdana14ptBitmaps[];
index 57fcfe0..e3e5808 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __VERDANA_9__
 #define __VERDANA_9__
 
 #ifndef __VERDANA_9__
 #define __VERDANA_9__
 
-#include "bitmapfonts.h"
+#include "../fonts.h"
 
 /* Font data for Verdana 9pt */
 extern const uint8_t verdana9ptBitmaps[];
 
 /* Font data for Verdana 9pt */
 extern const uint8_t verdana9ptBitmaps[];
index 0474fc7..f3d5812 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __VERDANA_BOLD_14__
 #define __VERDANA_BOLD_14__
 
 #ifndef __VERDANA_BOLD_14__
 #define __VERDANA_BOLD_14__
 
-#include "bitmapfonts.h"
+#include "../fonts.h"
 
 /* Font data for Verdana Bold 14pt */
 extern const uint8_t verdanabold14ptBitmaps[];
 
 /* Font data for Verdana Bold 14pt */
 extern const uint8_t verdanabold14ptBitmaps[];
index d425324..f7d4bf2 100644 (file)
@@ -50,7 +50,7 @@
 #endif
 
 /**************************************************************************
 #endif
 
 /**************************************************************************
-    BTL221722-276L CONNECTOR (Use HX8340B_ICVERSION_N)
+    BTL221722-276L CONNECTOR (HX8340B_ICVERSION_N)
     -----------------------------------------------------------------------
     Pin   Function        Notes
     ===   ==============  ===============================
     -----------------------------------------------------------------------
     Pin   Function        Notes
     ===   ==============  ===============================
index 3370c5f..c66619f 100644 (file)
@@ -170,7 +170,7 @@ uint32_t tsReadY(void)
 /**************************************************************************/
 void tsCalibCenterText(char* text, uint16_t y, uint16_t color)
 {
 /**************************************************************************/
 void tsCalibCenterText(char* text, uint16_t y, uint16_t color)
 {
-  drawString((lcdGetWidth() - drawGetStringWidth(&dejaVuSans9ptFontInfo, text)) / 2, y, color, &dejaVuSans9ptFontInfo, text);
+  fontsDrawString((lcdGetWidth() - fontsGetStringWidth(&dejaVuSans9ptFontInfo, text)) / 2, y, color, &dejaVuSans9ptFontInfo, text);
 }
 
 /**************************************************************************/
 }
 
 /**************************************************************************/
This page took 0.052424 seconds and 4 git commands to generate.