]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A5_SAMA5D4x_EK_IAR/AtmelFiles/libboard_sama5d4x-ek/source/lcd_font.c
Core kernel files:
[freertos] / FreeRTOS / Demo / CORTEX_A5_SAMA5D4x_EK_IAR / AtmelFiles / libboard_sama5d4x-ek / source / lcd_font.c
1 /* ----------------------------------------------------------------------------\r
2  *         SAM Software Package License \r
3  * ----------------------------------------------------------------------------\r
4  * Copyright (c) 2011, Atmel Corporation\r
5  *\r
6  * All rights reserved.\r
7  *\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
10  *\r
11  * - Redistributions of source code must retain the above copyright notice,\r
12  * this list of conditions and the disclaimer below.\r
13  *\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
16  *\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
28  */\r
29 \r
30 /** \file\r
31  *\r
32  * Implementation of draw font on LCD.\r
33  *\r
34  */\r
35 \r
36 /*----------------------------------------------------------------------------\r
37  *        Headers\r
38  *----------------------------------------------------------------------------*/\r
39 \r
40 #include "board.h"\r
41 \r
42 #include <stdint.h>\r
43 #include <assert.h>\r
44 \r
45 /*----------------------------------------------------------------------------\r
46  *        Local variables\r
47  *----------------------------------------------------------------------------*/\r
48 \r
49 /** Global variable describing the font being instancied. */\r
50 const Font gFont = {10, 14};\r
51 \r
52 /*----------------------------------------------------------------------------\r
53  *        Exported functions\r
54  *----------------------------------------------------------------------------*/\r
55 \r
56 /**\r
57  * \brief Draws an ASCII character on LCD.\r
58  *\r
59  * \param x  X-coordinate of character upper-left corner.\r
60  * \param y  Y-coordinate of character upper-left corner.\r
61  * \param c  Character to output.\r
62  * \param color  Character color.\r
63  */\r
64 extern void LCDD_DrawChar( uint32_t x, uint32_t y, uint8_t c, uint32_t color )\r
65 {\r
66     uint32_t row, col ;\r
67 \r
68     assert( (c >= 0x20) && (c <= 0x7F) ) ;\r
69 \r
70     for ( col = 0 ; col < 10 ; col++ )\r
71     {\r
72         for ( row = 0 ; row < 8 ; row++ )\r
73         {\r
74             if ( (pCharset10x14[((c - 0x20) * 20) + col * 2] >> (7 - row)) & 0x1 )\r
75             {\r
76                 LCDD_DrawPixel( x+col, y+row, color ) ;\r
77             }\r
78         }\r
79 \r
80         for (row = 0; row < 6; row++ )\r
81         {\r
82             if ((pCharset10x14[((c - 0x20) * 20) + col * 2 + 1] >> (7 - row)) & 0x1)\r
83             {\r
84                 LCDD_DrawPixel( x+col, y+row+8, color ) ;\r
85             }\r
86         }\r
87     }\r
88 }\r
89 \r
90 /**\r
91  * \brief Draws an ASCII character on LCD with given background color.\r
92  *\r
93  * \param x          X-coordinate of character upper-left corner.\r
94  * \param y          Y-coordinate of character upper-left corner.\r
95  * \param c          Character to output.\r
96  * \param fontColor  Character color.\r
97  * \param bgColor    Background color.\r
98  */\r
99 extern void LCDD_DrawCharWithBGColor( uint32_t x, uint32_t y, uint8_t c, uint32_t fontColor, uint32_t bgColor )\r
100 {\r
101     uint32_t row, col ;\r
102 \r
103     assert( (c >= 0x20) && (c <= 0x7F) ) ;\r
104 \r
105     for (col = 0; col < 10; col++)\r
106     {\r
107         for (row = 0 ; row < 8 ; row++)\r
108         {\r
109             if ( (pCharset10x14[((c - 0x20) * 20) + col * 2] >> (7 - row)) & 0x1 )\r
110             {\r
111                 LCDD_DrawPixel( x+col, y+row, fontColor ) ;\r
112             }\r
113             else\r
114             {\r
115                 LCDD_DrawPixel( x+col, y+row, bgColor ) ;\r
116             }\r
117         }\r
118 \r
119         for ( row = 0 ; row < 6 ; row++ )\r
120         {\r
121             if ( (pCharset10x14[((c - 0x20) * 20) + col * 2 + 1] >> (7 - row)) & 0x1 )\r
122             {\r
123                 LCDD_DrawPixel( x+col, y+row+8, fontColor ) ;\r
124             }\r
125             else\r
126             {\r
127                 LCDD_DrawPixel( x+col, y+row+8, bgColor ) ;\r
128             }\r
129         }\r
130     }\r
131 }\r
132 \r