126 * |
126 * |
127 * @param x0,y0 center |
127 * @param x0,y0 center |
128 * @param r radius |
128 * @param r radius |
129 * @param color 16 bit color * |
129 * @param color 16 bit color * |
130 * |
130 * |
131 */ |
131 */ |
132 virtual void circle(int x, int y, int r, unsigned short color); |
132 virtual void circle(int x, int y, int r, unsigned short color); |
133 |
133 |
134 /** draw a filled circle |
134 /** draw a filled circle |
135 * |
135 * |
136 * @param x0,y0 center |
136 * @param x0,y0 center |
137 * @param r radius |
137 * @param r radius |
138 * @param color 16 bit color * |
138 * @param color 16 bit color * |
139 */ |
139 */ |
140 virtual void fillcircle(int x, int y, int r, unsigned short color); |
140 virtual void fillcircle(int x, int y, int r, unsigned short color); |
141 |
141 |
142 |
142 |
143 /** draw a 1 pixel line |
143 /** draw a 1 pixel line |
144 * |
144 * |
145 * @param x0,y0 start point |
145 * @param x0,y0 start point |
146 * @param x1,y1 stop point |
146 * @param x1,y1 stop point |
147 * @param color 16 bit color |
147 * @param color 16 bit color |
148 * |
148 * |
149 */ |
149 */ |
150 virtual void line(int x0, int y0, int x1, int y1, unsigned short color); |
150 virtual void line(int x0, int y0, int x1, int y1, unsigned short color); |
151 |
151 |
152 /** draw a horizontal line |
152 /** draw a horizontal line |
153 * |
153 * |
154 * @param x0 horizontal start |
154 * @param x0 horizontal start |
155 * @param x1 horizontal stop |
155 * @param x1 horizontal stop |
156 * @param y vertical position |
156 * @param y vertical position |
157 * @param color 16 bit color |
157 * @param color 16 bit color |
158 * |
158 * |
159 */ |
159 */ |
160 void hline(int x0, int x1, int y, unsigned short color); |
160 void hline(int x0, int x1, int y, unsigned short color); |
161 |
161 |
162 /** draw a vertical line |
162 /** draw a vertical line |
163 * |
163 * |
164 * @param x horizontal position |
164 * @param x horizontal position |
165 * @param y0 vertical start |
165 * @param y0 vertical start |
166 * @param y1 vertical stop |
166 * @param y1 vertical stop |
167 * @param color 16 bit color |
167 * @param color 16 bit color |
168 */ |
168 */ |
169 void vline(int y0, int y1, int x, unsigned short color); |
169 void vline(int y0, int y1, int x, unsigned short color); |
170 |
170 |
171 /** draw a rect |
171 /** draw a rect |
172 * |
172 * |
173 * @param x0,y0 top left corner |
173 * @param x0,y0 top left corner |
174 * @param x1,y1 down right corner |
174 * @param x1,y1 down right corner |
175 * @param color 16 bit color |
175 * @param color 16 bit color |
176 * * |
176 * * |
177 */ |
177 */ |
178 virtual void rect(int x0, int y0, int x1, int y1, unsigned short color); |
178 virtual void rect(int x0, int y0, int x1, int y1, unsigned short color); |
179 |
179 |
180 /** draw a filled rect |
180 /** draw a filled rect |
181 * |
181 * |
182 * @param x0,y0 top left corner |
182 * @param x0,y0 top left corner |
183 * @param x1,y1 down right corner |
183 * @param x1,y1 down right corner |
184 * @param color 16 bit color |
184 * @param color 16 bit color |
185 * |
185 * |
186 */ |
186 */ |
187 virtual void fillrect(int x0, int y0, int x1, int y1, unsigned short color); |
187 virtual void fillrect(int x0, int y0, int x1, int y1, unsigned short color); |
188 |
188 |
189 /** setup cursor position for text |
189 /** setup cursor position for text |
190 * |
190 * |
191 * @param x x-position (top left) |
191 * @param x x-position (top left) |
192 * @param y y-position |
192 * @param y y-position |
193 */ |
193 */ |
194 virtual void locate(int x, int y); |
194 virtual void locate(int x, int y); |
195 |
195 |
196 /** put a char on the screen |
196 /** put a char on the screen |
197 * |
197 * |
198 * @param value char to print |
198 * @param value char to print |
199 * @returns printed char |
199 * @returns printed char |
200 * |
200 * |
201 */ |
201 */ |
202 virtual int _putc(int value); |
202 virtual int _putc(int value); |
203 |
203 |
|
204 /** draw a character on current position out of the active font to the TFT |
|
205 * |
|
206 * @param c char to print |
|
207 * |
|
208 */ |
|
209 virtual void character(int c); |
|
210 |
204 /** draw a character on given position out of the active font to the TFT |
211 /** draw a character on given position out of the active font to the TFT |
205 * |
212 * |
206 * @param x x-position of char (top left) |
213 * @param x x-position of char (top left) |
207 * @param y y-position |
214 * @param y y-position |
208 * @param c char to print |
215 * @param c char to print |
209 * |
216 * |
210 */ |
217 */ |
211 virtual void character(int x, int y, int c); |
218 virtual void character(int x, int y, int c); |
212 |
219 |
213 /** paint a bitmap on the TFT |
220 /** return the actual width of a character out of the active font to the TFT |
214 * |
221 * |
215 * @param x,y : upper left corner |
222 * @param c char to print |
|
223 * @param move_location wether to move current poisition or not |
|
224 * |
|
225 */ |
|
226 virtual uint8_t char_width(char c, bool move_location=false); |
|
227 |
|
228 /** paint a bitmap on the TFT |
|
229 * |
|
230 * @param x,y : upper left corner |
216 * @param w width of bitmap |
231 * @param w width of bitmap |
217 * @param h high of bitmap |
232 * @param h high of bitmap |
218 * @param *bitmap pointer to the bitmap data |
233 * @param *bitmap pointer to the bitmap data |
219 * |
234 * |
220 * bitmap format: 16 bit R5 G6 B5 |
235 * bitmap format: 16 bit R5 G6 B5 |
221 * |
236 * |
222 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5 |
237 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5 |
223 * use winhex to load this file and mark data stating at offset 0x46 to end |
238 * use winhex to load this file and mark data stating at offset 0x46 to end |
224 * use edit -> copy block -> C Source to export C array |
239 * use edit -> copy block -> C Source to export C array |
225 * paste this array into your program |
240 * paste this array into your program |
226 * |
241 * |
227 * define the array as static const unsigned char to put it into flash memory |
242 * define the array as static const unsigned char to put it into flash memory |
228 * cast the pointer to (unsigned char *) : |
243 * cast the pointer to (unsigned char *) : |
229 * tft.Bitmap(10,40,309,50,(unsigned char *)scala); |
244 * tft.Bitmap(10,40,309,50,(unsigned char *)scala); |
230 */ |
245 */ |
231 void Bitmap(int x, int y, int w, int h,unsigned char *bitmap); |
246 void Bitmap(int x, int y, int w, int h,unsigned char *bitmap); |
232 |
247 |
233 /** paint monochrome bitmap to screen |
248 /** paint monochrome bitmap to screen |
234 * |
249 * |
235 * @param bm Bitmap in flash |
250 * @param bm Bitmap in flash |
236 * @param x x start |
251 * @param x x start |
237 * @param y y start |
252 * @param y y start |
238 * |
253 * |
239 */ |
254 */ |
240 void Bitmap_BW(Bitmap_s bm, int x, int y); |
255 void Bitmap_BW(Bitmap_s bm, int x, int y); |
241 |
256 |
242 /** paint a 16 bit BMP from filesytem on the TFT (slow) |
257 /** paint a 16 bit BMP from filesytem on the TFT (slow) |
243 * |
258 * |
244 * @param x,y : position of upper left corner |
259 * @param x,y : position of upper left corner |
245 * @param *Name_BMP name of the BMP file with drive: "/local/test.bmp" |
260 * @param *Name_BMP name of the BMP file with drive: "/local/test.bmp" |
246 * |
261 * |
247 * @returns 1 if bmp file was found and painted |
262 * @returns 1 if bmp file was found and painted |
248 * @returns 0 if bmp file was found not found |
263 * @returns 0 if bmp file was found not found |
249 * @returns -1 if file is no bmp |
264 * @returns -1 if file is no bmp |
250 * @returns -2 if bmp file is no 16 bit bmp |
265 * @returns -2 if bmp file is no 16 bit bmp |
251 * @returns -3 if bmp file is to big for screen |
266 * @returns -3 if bmp file is to big for screen |
252 * @returns -4 if buffer malloc go wrong |
267 * @returns -4 if buffer malloc go wrong |
253 * |
268 * |
254 * bitmap format: 16 bit R5 G6 B5 |
269 * bitmap format: 16 bit R5 G6 B5 |
255 * |
270 * |
256 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5 |
271 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5 |
257 * copy to internal file system or SD card |
272 * copy to internal file system or SD card |
258 */ |
273 */ |
259 int BMP_16(int x, int y, const char *Name_BMP); |
274 int BMP_16(int x, int y, const char *Name_BMP); |
260 |
275 |
261 |
276 |
262 |
277 |
263 /** select the font to use |
278 /** select the font to use |
264 * |
279 * |
265 * @param f pointer to font array |
280 * @param f pointer to font array |
266 * @param firstascii first ascii code present in font array, default 32 (space) |
281 * @param firstascii first ascii code present in font array, default 32 (space) |
267 * @param lastascii last ascii code present in font array, default 127 (DEL) |
282 * @param lastascii last ascii code present in font array, default 127 (DEL) |
268 * @param proportional enable/disable variable font width (default enabled) |
283 * @param proportional enable/disable variable font width (default enabled) |
269 * |
284 * |
270 * font array can created with GLCD Font Creator from http://www.mikroe.com |
285 * font array can created with GLCD Font Creator from http://www.mikroe.com |
271 * you have to add 4 parameter at the beginning of the font array to use: |
286 * you have to add 4 parameter at the beginning of the font array to use: |
272 * - the number of byte / char (not used in this revision, set to whatever) |
287 * - the number of byte / char (not used in this revision, set to whatever) |
273 * - the vertial size in pixel |
288 * - the vertial size in pixel |
274 * - the horizontal size in pixel |
289 * - the horizontal size in pixel |
275 * - the number of byte per vertical line (not used in this revision, set to whatever) |
290 * - the number of byte per vertical line (not used in this revision, set to whatever) |
276 * you also have to change the array to cont unsigned char[] and __align(2) |
291 * you also have to change the array to cont unsigned char[] and __align(2) |
277 * |
292 * |
278 */ |
293 */ |
279 void set_font(unsigned char* f, unsigned char firstascii=32, unsigned char lastascii=127, bool proportional = true); |
294 void set_font(unsigned char* f, unsigned char firstascii=32, unsigned char lastascii=127, bool proportional = true); |
280 |
295 |
281 /** Zoom fount |
296 /** Zoom fount |
282 * |
297 * |
283 * @param x_mul horizontal size multiplier |
298 * @param x_mul horizontal size multiplier |
284 * @param y_mul vertical size multiplier |
299 * @param y_mul vertical size multiplier |
285 */ |
300 */ |
286 void set_font_zoom(unsigned char x_mul, unsigned char y_mul); |
301 void set_font_zoom(unsigned char x_mul, unsigned char y_mul); |
287 |
302 |
288 /** Get the number of columns based on the currently active font. |
303 /** Get the number of columns based on the currently active font. |
289 * @returns number of columns. |
304 * @returns number of columns. |
290 * @note this method may be overridden in a derived class. |
305 * @note this method may be overridden in a derived class. |
294 /** Get the number of rows based on the currently active font. |
309 /** Get the number of rows based on the currently active font. |
295 * @returns number of rows. |
310 * @returns number of rows. |
296 * @note this method may be overridden in a derived class. |
311 * @note this method may be overridden in a derived class. |
297 */ |
312 */ |
298 virtual int rows(); |
313 virtual int rows(); |
299 |
314 |
300 /** get the current oriented screen width in pixels |
315 /** get the current oriented screen width in pixels |
301 * @returns screen width in pixels. |
316 * @returns screen width in pixels. |
302 */ |
317 */ |
303 int width(); |
318 int width(); |
304 |
319 |
305 /** get the current oriented screen height in pixels |
320 /** get the current oriented screen height in pixels |
306 * @returns screen height in pixels. |
321 * @returns screen height in pixels. |
307 */ |
322 */ |
308 int height(); |
323 int height(); |
309 |
324 |
310 /** set the current oriented screen width in pixels |
325 /** set the current oriented screen width in pixels |
311 * @param width screen width in pixels. |
326 * @param width screen width in pixels. |
312 */ |
327 */ |
313 void set_width(int width); |
328 void set_width(int width); |
314 |
329 |
315 /** set the current oriented screen height in pixels |
330 /** set the current oriented screen height in pixels |
316 * @param height screen height in pixels. |
331 * @param height screen height in pixels. |
317 */ |
332 */ |
318 void set_height(int height); |
333 void set_height(int height); |
319 |
334 |
320 /** setup auto update of screen |
335 /** setup auto update of screen |
321 * |
336 * |
322 * @param up 1 = on , 0 = off |
337 * @param up 1 = on , 0 = off |
323 * if switched off the program has to call copy_to_lcd() |
338 * if switched off the program has to call copy_to_lcd() |
324 * to update screen from framebuffer |
339 * to update screen from framebuffer |
325 */ |
340 */ |
326 void set_auto_up(bool up); |
341 void set_auto_up(bool up); |
327 |
342 |
328 /** get status of the auto update function |
343 /** get status of the auto update function |
329 * |
344 * |
330 * @returns if auto update is on |
345 * @returns if auto update is on |
331 */ |
346 */ |
332 bool get_auto_up(void); |
347 bool get_auto_up(void); |
333 |
348 |
334 |
349 |
335 |
350 |
336 private: |
351 private: |
337 |
352 |
338 unsigned char* font; |
353 unsigned char* font; |
339 // display width and height related to current orientation |
354 // display width and height related to current orientation |
340 int oriented_width; |
355 int oriented_width; |
341 int oriented_height; |
356 int oriented_height; |
342 |
357 |
343 // text char location |
358 // text char location |
344 int char_x; |
359 int char_x; |
345 int char_y; |
360 int char_y; |
346 |
361 |
347 int fontoffset;// bytes / char (short) |
362 int fontoffset;// bytes / char (short) |
348 int fonthor; // hor size of font (char) |
363 int fonthor; // hor size of font (char) |
349 int fontvert; // ver size of font (char) |
364 int fontvert; // ver size of font (char) |
350 int fontbpl; // bytes per line (char) |
365 int fontbpl; // bytes per line (char) |
351 int fontzoomver; // size multiplier |
366 int fontzoomver; // size multiplier |
352 int fontzoomhor; // size multiplier |
367 int fontzoomhor; // size multiplier |
353 unsigned char firstch; // first ascii code present in font array (usually 32) |
368 unsigned char firstch; // first ascii code present in font array (usually 32) |
354 unsigned char lastch; // last ascii code present in font array (usually 127) |
369 unsigned char lastch; // last ascii code present in font array (usually 127) |
355 bool auto_up; // autoupdate flag for LCD |
370 bool auto_up; // autoupdate flag for LCD |
356 bool fontprop; |
371 bool fontprop; |
357 |
372 |
358 |
373 |
359 }; |
374 }; |
360 |
375 |
361 #endif |
376 #endif |