mesh phone

Dependencies:   RF22 mbed

Committer:
SangSTBK
Date:
Mon Jul 02 03:41:36 2012 +0000
Revision:
0:c674504a6536
mesh

Who changed what in which revision?

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