1 /* ----------------------------------------------------------------------------
\r
2 * SAM Software Package License
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2011, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
33 * Implementation of draw font on LCD.
\r
37 /*----------------------------------------------------------------------------
\r
39 *----------------------------------------------------------------------------*/
\r
46 /*----------------------------------------------------------------------------
\r
48 *----------------------------------------------------------------------------*/
\r
50 /** Global variable describing the font being instancied. */
\r
51 const Font gFont = {10, 14};
\r
53 /*----------------------------------------------------------------------------
\r
54 * Exported functions
\r
55 *----------------------------------------------------------------------------*/
\r
58 * \brief Draws an ASCII character on LCD.
\r
60 * \param x X-coordinate of character upper-left corner.
\r
61 * \param y Y-coordinate of character upper-left corner.
\r
62 * \param c Character to output.
\r
63 * \param color Character color.
\r
65 extern void LCDD_DrawChar( uint32_t x, uint32_t y, uint8_t c, uint32_t color )
\r
69 assert( (c >= 0x20) && (c <= 0x7F) ) ;
\r
71 for ( col = 0 ; col < 10 ; col++ )
\r
73 for ( row = 0 ; row < 8 ; row++ )
\r
75 if ( (pCharset10x14[((c - 0x20) * 20) + col * 2] >> (7 - row)) & 0x1 )
\r
77 LCDD_DrawPixel( x+col, y+row, color ) ;
\r
81 for (row = 0; row < 6; row++ )
\r
83 if ((pCharset10x14[((c - 0x20) * 20) + col * 2 + 1] >> (7 - row)) & 0x1)
\r
85 LCDD_DrawPixel( x+col, y+row+8, color ) ;
\r
92 * \brief Draws a string inside a LCD buffer, at the given coordinates.
\r
93 * Line breaks will be honored.
\r
95 * \param dwX X-coordinate of string top-left corner.
\r
96 * \param dwY Y-coordinate of string top-left corner.
\r
97 * \param pString String to display.
\r
99 extern void LCD_DrawString( uint32_t dwX, uint32_t dwY, const uint8_t *pString, uint32_t color )
\r
101 uint32_t dwXorg = dwX ;
\r
103 while ( *pString != 0 )
\r
105 if ( *pString == '\n' )
\r
107 dwY += gFont.height + 2 ;
\r
112 LCDD_DrawChar( dwX, dwY, *pString, color ) ;
\r
113 dwX += gFont.width + 2 ;
\r
121 * \brief Draws an ASCII character on LCD with given background color.
\r
123 * \param x X-coordinate of character upper-left corner.
\r
124 * \param y Y-coordinate of character upper-left corner.
\r
125 * \param c Character to output.
\r
126 * \param fontColor Character color.
\r
127 * \param bgColor Background color.
\r
129 extern void LCDD_DrawCharWithBGColor( uint32_t x, uint32_t y, uint8_t c, uint32_t fontColor, uint32_t bgColor )
\r
131 uint32_t row, col ;
\r
133 assert( (c >= 0x20) && (c <= 0x7F) ) ;
\r
135 for (col = 0; col < 10; col++)
\r
137 for (row = 0 ; row < 8 ; row++)
\r
139 if ( (pCharset10x14[((c - 0x20) * 20) + col * 2] >> (7 - row)) & 0x1 )
\r
141 LCDD_DrawPixel( x+col, y+row, fontColor ) ;
\r
145 LCDD_DrawPixel( x+col, y+row, bgColor ) ;
\r
149 for ( row = 0 ; row < 6 ; row++ )
\r
151 if ( (pCharset10x14[((c - 0x20) * 20) + col * 2 + 1] >> (7 - row)) & 0x1 )
\r
153 LCDD_DrawPixel( x+col, y+row+8, fontColor ) ;
\r
157 LCDD_DrawPixel( x+col, y+row+8, bgColor ) ;
\r