TFT

Dependencies:   mbed

Fork of Ovation_Controller_1 by Andrew R

Committer:
bf1891
Date:
Thu Aug 28 15:18:07 2014 +0000
Revision:
3:92845c139aca
Parent:
1:ecf8078bf531
publish;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewcrussell 1:ecf8078bf531 1 #ifndef FONT_H
andrewcrussell 1:ecf8078bf531 2
andrewcrussell 1:ecf8078bf531 3
andrewcrussell 1:ecf8078bf531 4
andrewcrussell 1:ecf8078bf531 5 //#define TEST
andrewcrussell 1:ecf8078bf531 6 //#define SMALL_TEST
andrewcrussell 1:ecf8078bf531 7
andrewcrussell 1:ecf8078bf531 8
andrewcrussell 1:ecf8078bf531 9 /***************************************************************************/
andrewcrussell 1:ecf8078bf531 10
andrewcrussell 1:ecf8078bf531 11 extern const unsigned char c14_data_table[];
andrewcrussell 1:ecf8078bf531 12 extern const unsigned int c14_offset_table[];
andrewcrussell 1:ecf8078bf531 13 extern const unsigned char c14_index_table[];
andrewcrussell 1:ecf8078bf531 14 extern const unsigned char c14_width_table[];
andrewcrussell 1:ecf8078bf531 15
andrewcrussell 1:ecf8078bf531 16 extern const unsigned char c28_data_table[];
andrewcrussell 1:ecf8078bf531 17 extern const unsigned int c28_offset_table[];
andrewcrussell 1:ecf8078bf531 18 extern const unsigned char c28_index_table[];
andrewcrussell 1:ecf8078bf531 19 extern const unsigned char c28_width_table[];
andrewcrussell 1:ecf8078bf531 20
andrewcrussell 1:ecf8078bf531 21 extern const unsigned char c72_data_table[];
andrewcrussell 1:ecf8078bf531 22 extern const unsigned int c72_offset_table[];
andrewcrussell 1:ecf8078bf531 23 extern const unsigned char c72_index_table[];
andrewcrussell 1:ecf8078bf531 24 extern const unsigned char c72_width_table[];
andrewcrussell 1:ecf8078bf531 25
andrewcrussell 1:ecf8078bf531 26 extern const unsigned char c78_1_data_table[];
andrewcrussell 1:ecf8078bf531 27 extern const unsigned int c78_1_offset_table[];
andrewcrussell 1:ecf8078bf531 28 extern const unsigned char c78_1_index_table[];
andrewcrussell 1:ecf8078bf531 29 extern const unsigned char c78_1_width_table[];
andrewcrussell 1:ecf8078bf531 30
andrewcrussell 1:ecf8078bf531 31 typedef struct _font {
andrewcrussell 1:ecf8078bf531 32 int dummy0;
andrewcrussell 1:ecf8078bf531 33 int dummy1;
andrewcrussell 1:ecf8078bf531 34 int dummy2;
andrewcrussell 1:ecf8078bf531 35 int height;
andrewcrussell 1:ecf8078bf531 36 int max_width;
andrewcrussell 1:ecf8078bf531 37 int space_width;
andrewcrussell 1:ecf8078bf531 38 const unsigned char *data_table;
andrewcrussell 1:ecf8078bf531 39 const unsigned int *offset_table;
andrewcrussell 1:ecf8078bf531 40 const unsigned char *index_table;
andrewcrussell 1:ecf8078bf531 41 const unsigned char *width_table;
andrewcrussell 1:ecf8078bf531 42 }
andrewcrussell 1:ecf8078bf531 43 font;
andrewcrussell 1:ecf8078bf531 44
andrewcrussell 1:ecf8078bf531 45
andrewcrussell 1:ecf8078bf531 46 extern font Calibri14;
andrewcrussell 1:ecf8078bf531 47 extern font Calibri28;
andrewcrussell 1:ecf8078bf531 48 extern font Calibri72;
andrewcrussell 1:ecf8078bf531 49 extern font Calibri78_1;
andrewcrussell 1:ecf8078bf531 50
andrewcrussell 1:ecf8078bf531 51
andrewcrussell 1:ecf8078bf531 52 #ifdef TEST
andrewcrussell 1:ecf8078bf531 53 #ifdef SMALL_TEST
andrewcrussell 1:ecf8078bf531 54 #define SC_WIDTH 128
andrewcrussell 1:ecf8078bf531 55 #define SC_HEIGHT 128
andrewcrussell 1:ecf8078bf531 56 #else
andrewcrussell 1:ecf8078bf531 57 #define SC_WIDTH 640
andrewcrussell 1:ecf8078bf531 58 #define SC_HEIGHT 480
andrewcrussell 1:ecf8078bf531 59 #endif
andrewcrussell 1:ecf8078bf531 60 #endif
andrewcrussell 1:ecf8078bf531 61
andrewcrussell 1:ecf8078bf531 62 void FontDrawInit( void );
andrewcrussell 1:ecf8078bf531 63
andrewcrussell 1:ecf8078bf531 64 /** FontDraw_printf
andrewcrussell 1:ecf8078bf531 65 *
andrewcrussell 1:ecf8078bf531 66 * A "printf" function that takes coodinate values as starting point of the string.
andrewcrussell 1:ecf8078bf531 67 * The coodinate is a point if the left-bottom point of string output area.
andrewcrussell 1:ecf8078bf531 68 *
andrewcrussell 1:ecf8078bf531 69 * Drawing parameters should be set by FontDraw_Set... functions before this function call.
andrewcrussell 1:ecf8078bf531 70 *
andrewcrussell 1:ecf8078bf531 71 * param: x left position of the string
andrewcrussell 1:ecf8078bf531 72 * param: y bottom position of the string
andrewcrussell 1:ecf8078bf531 73 * param: format... followings are normal printf arguments
andrewcrussell 1:ecf8078bf531 74 */
andrewcrussell 1:ecf8078bf531 75 void FontDraw_printf( int x, int y, char *format, ... );
andrewcrussell 1:ecf8078bf531 76
andrewcrussell 1:ecf8078bf531 77
andrewcrussell 1:ecf8078bf531 78 /** FontDraw_puts
andrewcrussell 1:ecf8078bf531 79 *
andrewcrussell 1:ecf8078bf531 80 * Similar to "printf" but no format support. It just put a strin on to the screen.
andrewcrussell 1:ecf8078bf531 81 * This may be bit faster than "FontDraw_printf".
andrewcrussell 1:ecf8078bf531 82 *
andrewcrussell 1:ecf8078bf531 83 * Drawing parameters should be set by FontDraw_Set... functions before this function call.
andrewcrussell 1:ecf8078bf531 84 *
andrewcrussell 1:ecf8078bf531 85 * param: x left position of the string
andrewcrussell 1:ecf8078bf531 86 * param: y bottom position of the string
andrewcrussell 1:ecf8078bf531 87 * param: s string
andrewcrussell 1:ecf8078bf531 88 */
andrewcrussell 1:ecf8078bf531 89 void FontDraw_puts( int x, int y, char *s );
andrewcrussell 1:ecf8078bf531 90
andrewcrussell 1:ecf8078bf531 91
andrewcrussell 1:ecf8078bf531 92 /** FontDrawString
andrewcrussell 1:ecf8078bf531 93 *
andrewcrussell 1:ecf8078bf531 94 * Similar to "FontDraw_puts" but this function takes several parameters to define its propaty.
andrewcrussell 1:ecf8078bf531 95 * This function will be useful if user want to use other parameter setting temporary.
andrewcrussell 1:ecf8078bf531 96 *
andrewcrussell 1:ecf8078bf531 97 * param: s string
andrewcrussell 1:ecf8078bf531 98 * param: x left position of the string
andrewcrussell 1:ecf8078bf531 99 * param: y bottom position of the string
andrewcrussell 1:ecf8078bf531 100 * param: f_color color value for string itself
andrewcrussell 1:ecf8078bf531 101 * param: b_color color value for rectangle around the string
andrewcrussell 1:ecf8078bf531 102 * param: font_ptr pointer to the font
andrewcrussell 1:ecf8078bf531 103 */
andrewcrussell 1:ecf8078bf531 104 void FontDrawString( char *s, int xpos, int ypos, int f_color, int b_color, font *font_ptr );
andrewcrussell 1:ecf8078bf531 105
andrewcrussell 1:ecf8078bf531 106
andrewcrussell 1:ecf8078bf531 107 /** FontDrawChar
andrewcrussell 1:ecf8078bf531 108 *
andrewcrussell 1:ecf8078bf531 109 * Similar to "FontDraw_puts" but this function takes several parameters to define its propaty.
andrewcrussell 1:ecf8078bf531 110 * This function will be useful if user want to use other parameter setting temporary.
andrewcrussell 1:ecf8078bf531 111 *
andrewcrussell 1:ecf8078bf531 112 * param: c character
andrewcrussell 1:ecf8078bf531 113 * param: x left position of the string
andrewcrussell 1:ecf8078bf531 114 * param: y bottom position of the string
andrewcrussell 1:ecf8078bf531 115 * param: f_color color value for character itself
andrewcrussell 1:ecf8078bf531 116 * param: b_color color value for rectangle around the character
andrewcrussell 1:ecf8078bf531 117 * param: font_ptr pointer to the font
andrewcrussell 1:ecf8078bf531 118 * return: the width of the character (including inter-caracter space if user set)
andrewcrussell 1:ecf8078bf531 119 */
andrewcrussell 1:ecf8078bf531 120 int FontDrawChar( char c, int xpos, int ypos, int f_color, int b_color, font *font_ptr );
andrewcrussell 1:ecf8078bf531 121
andrewcrussell 1:ecf8078bf531 122 /** FontDrawStringWidth
andrewcrussell 1:ecf8078bf531 123 *
andrewcrussell 1:ecf8078bf531 124 * Returns the string width (span) which will be drawn on the screen.
andrewcrussell 1:ecf8078bf531 125 * This will be useful like case of aligning the string at center or right.
andrewcrussell 1:ecf8078bf531 126 * for instance, if the string needed to be aligned to right and of the screen (ex. pixel=480), the code will be...
andrewcrussell 1:ecf8078bf531 127 *
andrewcrussell 1:ecf8078bf531 128 * code:
andrewcrussell 1:ecf8078bf531 129 * x = 480 - FontDrawStringWidth( "sample string", &Calibri14 );
andrewcrussell 1:ecf8078bf531 130 * FontDrawString( "sample string", x, y, 0x000000, 0xFFFFFF, &Calibri14 );
andrewcrussell 1:ecf8078bf531 131 *
andrewcrussell 1:ecf8078bf531 132 * param: s string
andrewcrussell 1:ecf8078bf531 133 * param: font_ptr pointer to the font
andrewcrussell 1:ecf8078bf531 134 * return: string width (including inter-caracter space if user set)
andrewcrussell 1:ecf8078bf531 135 */
andrewcrussell 1:ecf8078bf531 136 int FontDrawStringWidth( char *s, font *font_ptr );
andrewcrussell 1:ecf8078bf531 137
andrewcrussell 1:ecf8078bf531 138
andrewcrussell 1:ecf8078bf531 139 /** FontDraw_SetFont
andrewcrussell 1:ecf8078bf531 140 *
andrewcrussell 1:ecf8078bf531 141 * Setting the font to draw
andrewcrussell 1:ecf8078bf531 142 * This will affect to following "FontDraw_printf" and "FontDraw_puts" calls
andrewcrussell 1:ecf8078bf531 143 *
andrewcrussell 1:ecf8078bf531 144 * param: f font (default: Carlibri14)
andrewcrussell 1:ecf8078bf531 145 */
andrewcrussell 1:ecf8078bf531 146 void FontDraw_SetFont( font f );
andrewcrussell 1:ecf8078bf531 147
andrewcrussell 1:ecf8078bf531 148
andrewcrussell 1:ecf8078bf531 149 /** FontDraw_SetInterCharSpace
andrewcrussell 1:ecf8078bf531 150 *
andrewcrussell 1:ecf8078bf531 151 * Setting the inter-character space
andrewcrussell 1:ecf8078bf531 152 * When drawing the string, each caracters can have additional space between those (this will not applied to space caracters)
andrewcrussell 1:ecf8078bf531 153 *
andrewcrussell 1:ecf8078bf531 154 * param: space pixels. no ngative number can be specified (default: 0)
andrewcrussell 1:ecf8078bf531 155 */
andrewcrussell 1:ecf8078bf531 156 void FontDraw_SetInterCharSpace( int space );
andrewcrussell 1:ecf8078bf531 157
andrewcrussell 1:ecf8078bf531 158
andrewcrussell 1:ecf8078bf531 159 /** FontDraw_SetAlphaMode
andrewcrussell 1:ecf8078bf531 160 *
andrewcrussell 1:ecf8078bf531 161 * If the alphamode is enabled,no background will be written. No rectangle around the charators are drawn.
andrewcrussell 1:ecf8078bf531 162 *
andrewcrussell 1:ecf8078bf531 163 * param: mode zero for disable, non-zero for enable (default: disable)
andrewcrussell 1:ecf8078bf531 164 */
andrewcrussell 1:ecf8078bf531 165 void FontDraw_SetAlphaMode( int mode );
andrewcrussell 1:ecf8078bf531 166
andrewcrussell 1:ecf8078bf531 167
andrewcrussell 1:ecf8078bf531 168 /** FontDraw_SetForegroundColor
andrewcrussell 1:ecf8078bf531 169 *
andrewcrussell 1:ecf8078bf531 170 * Settng of the color for character itself.
andrewcrussell 1:ecf8078bf531 171 *
andrewcrussell 1:ecf8078bf531 172 * param: v color (24 bit value) (default: 0x0000FF)
andrewcrussell 1:ecf8078bf531 173 */
andrewcrussell 1:ecf8078bf531 174 void FontDraw_SetForegroundColor( int v );
andrewcrussell 1:ecf8078bf531 175
andrewcrussell 1:ecf8078bf531 176
andrewcrussell 1:ecf8078bf531 177 /** FontDraw_SetBackgroundColor
andrewcrussell 1:ecf8078bf531 178 *
andrewcrussell 1:ecf8078bf531 179 * Settng of the color for rectangle around the charators.
andrewcrussell 1:ecf8078bf531 180 *
andrewcrussell 1:ecf8078bf531 181 * param: v color (24 bit value) (default: 0xFFFFFF)
andrewcrussell 1:ecf8078bf531 182 */
andrewcrussell 1:ecf8078bf531 183 void FontDraw_SetBackgroundColor( int v );
andrewcrussell 1:ecf8078bf531 184
andrewcrussell 1:ecf8078bf531 185
andrewcrussell 1:ecf8078bf531 186 #endif