µGFX  2.9
version 2.9
gdisp.h
Go to the documentation of this file.
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.io/license.html
6  */
7 
8 /**
9  * @file src/gdisp/gdisp.h
10  * @brief GDISP Graphic Driver subsystem header file.
11  *
12  * @addtogroup GDISP
13  *
14  * @brief Module to interface graphic / pixel oriented displays
15  *
16  * @details The GDISP module provides high level abstraction to interface pixel oriented graphic displays.
17  *
18  * @pre GFX_USE_GDISP must be set to GFXON in gfxconf.h
19  *
20  * @note Each drawing routine supports a gdispXXXX and a gdispGXXXX function. The difference is that the
21  * gdispXXXX function does not require a display to be specified. Note there is a slight anomaly
22  * in the naming with gdispGBlitArea() vs gdispBlitAreaEx() and gdispBlitArea(), the latter of
23  * which is now deprecated.
24  * @{
25  */
26 
27 #ifndef _GDISP_H
28 #define _GDISP_H
29 
30 #include "../../gfx.h"
31 
32 /* This type definition is defined here as it gets used in other gfx sub-systems even
33  * if GFX_USE_GDISP is GFXOFF.
34  */
35 
36 /**
37  * @brief The type for a coordinate or length on the screen.
38  */
39 typedef gI16 gCoord;
40 
41 #if GFX_USE_GDISP || defined(__DOXYGEN__)
42 
43 /*===========================================================================*/
44 /* Type definitions */
45 /*===========================================================================*/
46 
47 /**
48  * @struct gPoint
49  * @brief Type for a 2D point on the screen.
50  */
51 typedef struct gPoint {
52  gCoord x; /**< The x coordinate of the point. */
53  gCoord y; /**< The y coordinate of the point. */
54 } gPoint;
55 
56 /**
57  * @enum gJustify
58  * @brief Type for the text justification.
59  */
60 typedef enum gJustify {
61  gJustifyLeft = 0x00, /**< Justify Left (the default) */
62  gJustifyCenter = 0x01, /**< Justify Center */
63  gJustifyRight = 0x02, /**< Justify Right */
64  gJustifyTop = 0x10, /**< Justify Top */
65  gJustifyMiddle = 0x00, /**< Justify Middle (the default) */
66  gJustifyBottom = 0x20, /**< Justify Bottom */
67  gJustifyWordWrap = 0x00, /**< Word wrap (the default if GDISP_NEED_TEXT_WORDWRAP is on) */
68  gJustifyNoWordWrap = 0x40, /**< No word wrap */
69  gJustifyPad = 0x00, /**< Pad the text box (the default) */
70  gJustifyNoPad = 0x04 /**< No padding the text box */
72 #define JUSTIFYMASK_HORIZONTAL (gJustifyLeft|gJustifyCenter|gJustifyRight)
73 #define JUSTIFYMASK_VERTICAL (gJustifyTop|gJustifyMiddle|gJustifyBottom)
74 
75 /**
76  * @enum gFontmetric
77  * @brief Type for the font metric.
78  */
79 typedef enum gFontmetric {
80  gFontHeight, /**< The height of the font */
81  gFontDescendersHeight, /**< The descenders height */
82  gFontLineSpacing, /**< The line spacing */
83  gFontCharPadding, /**< The char padding */
84  gFontMinWidth, /**< The minimum width */
85  gFontMaxWidth, /**< The maximum width */
86  gFontBaselineX, /**< The base line in x direction */
87  gFontBaselineY /**< The base line in y direction */
89 
90 /**
91  * @brief The type of a font.
92  */
93 typedef const struct mf_font_s* gFont;
94 
95 /**
96  * @enum gOrientation
97  * @brief Type for the screen orientation.
98  * @note gOrientationLandscape and gOrientationPortrait are internally converted to the
99  * most appropriate other orientation.
100  */
101 typedef enum gOrientation {
102  gOrientation0 = 0, /**< Don't rotate. This is the displays native orientation. */
103  gOrientation90 = 90, /**< Rotate by 90 degrees absolute to the native rotation. */
104  gOrientation180 = 180, /**< Rotate by 180 degrees absolute to the native rotation. */
105  gOrientation270 = 270, /**< Rotate by 270 degrees absolute to the native rotation. */
106  gOrientationPortrait = 1000, /**< Put the display into portrait mode. */
107  gOrientationLandscape = 1001 /**< Put the display into landscape mode. */
109 
110 /**
111  * @enum gPowermode
112  * @brief Type for the available power modes for the screen.
113  */
114 typedef enum gPowermode {
115  gPowerOff, /**< Turn the display off. */
116  gPowerSleep, /**< Put the display into sleep mode. */
117  gPowerDeepSleep, /**< Put the display into deep-sleep mode. */
118  gPowerOn /**< Turn the display on. */
120 
121 /*
122  * Our black box display structure.
123  */
124 typedef struct GDisplay GDisplay;
125 
126 /**
127  * @brief The default screen to use for the gdispXXXX calls.
128  * @note This is set by default to the first display in the system. You can change
129  * it by calling @p gdispSetDisplay().
130  */
131 extern GDisplay *GDISP;
132 
133 /*===========================================================================*/
134 /* Constants. */
135 /*===========================================================================*/
136 
137 /**
138  * @brief Driver Control Constants
139  * @details Unsupported control codes are ignored.
140  * @note The value parameter should always be typecast to (void *).
141  * @note There are some predefined and some specific to the low level driver.
142  * @note GDISP_CONTROL_POWER - Takes a gPowermode
143  * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t
144  * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver
145  * that only supports off/on anything other
146  * than zero is on.
147  * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
148  * GDISP_CONTROL_LLD - Low level driver control constants start at
149  * this value.
150  */
151 #define GDISP_CONTROL_POWER 0
152 #define GDISP_CONTROL_ORIENTATION 1
153 #define GDISP_CONTROL_BACKLIGHT 2
154 #define GDISP_CONTROL_CONTRAST 3
155 #define GDISP_CONTROL_LLD 1000
156 
157 /*===========================================================================*/
158 /* Defines relating to the display hardware */
159 /*===========================================================================*/
160 
161 #if !defined(GDISP_DRIVER_LIST)
162  // Pull in the default hardware configuration for a single controller.
163  // If we have multiple controllers the settings must be set in the
164  // users gfxconf.h file.
165  // Use the compiler include path to find it
166  #include "gdisp_lld_config.h"
167 
168  // Unless the user has specified a specific pixel format, use
169  // the native format for the controller.
170  #if !defined(GDISP_PIXELFORMAT) && defined(GDISP_LLD_PIXELFORMAT)
171  #define GDISP_PIXELFORMAT GDISP_LLD_PIXELFORMAT
172  #endif
173 #endif
174 
175 /**
176  * @name GDISP pixel format choices
177  * @{
178  */
179  /**
180  * @brief The pixel format.
181  * @details It generally defaults to the hardware pixel format.
182  * @note This doesn't need to match the hardware pixel format.
183  * It is definitely more efficient when it does.
184  * @note When GDISP_DRIVER_LIST is defined, this must
185  * be explicitly defined and you should ensure the best match
186  * with your hardware across all devices.
187  */
188  #ifndef GDISP_PIXELFORMAT
189  #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_ERROR
190  #endif
191  /**
192  * @brief Do pixels require packing for a blit
193  * @note Is only valid for a pixel format that doesn't fill it's datatype. eg formats:
194  * GDISP_PIXELFORMAT_RGB888
195  * GDISP_PIXELFORMAT_RGB444
196  * GDISP_PIXELFORMAT_RGB666
197  * GDISP_PIXELFORMAT_CUSTOM
198  * @note Very few cases should actually require packed pixels as the low
199  * level driver can also pack on the fly as it is sending it
200  * to the graphics device.
201  * @note Packed pixels are not really supported at this point.
202  */
203  #ifndef GDISP_PACKED_PIXELS
204  #define GDISP_PACKED_PIXELS GFXOFF
205  #endif
206 
207  /**
208  * @brief Do lines of pixels require packing for a blit
209  * @note Ignored if GDISP_PACKED_PIXELS is GFXOFF
210  */
211  #ifndef GDISP_PACKED_LINES
212  #define GDISP_PACKED_LINES GFXOFF
213  #endif
214 /** @} */
215 
216 /*===========================================================================*/
217 /* Defines related to the pixel format */
218 /*===========================================================================*/
219 
220 /* Load our color definitions and pixel formats */
221 #include "gdisp_colors.h"
222 
223 /**
224  * @brief The type of a pixel.
225  */
226 typedef gColor gPixel;
227 
228 /* Color Utility Functions */
229 
230 /**
231  * @brief Blend 2 colors according to the alpha
232  * @return The combined color
233  *
234  * @param[in] fg The foreground color
235  * @param[in] bg The background color
236  * @param[in] alpha The alpha value (0-255). 0 is all background, 255 is all foreground.
237  *
238  * @api
239  */
240 gColor gdispBlendColor(gColor fg, gColor bg, gU8 alpha);
241 
242 /**
243  * @brief Find a contrasting color
244  * @return The contrasting color
245  *
246  * @param[in] color The color to contrast
247  *
248  * @api
249  */
251 
252 /* Base Functions */
253 
254 /**
255  * @brief Get the specified display
256  * @return The pointer to the display or NULL if the display doesn't exist
257  * @note The GDISP variable contains the display used by the gdispXxxx routines
258  * as opposed to the gdispGXxxx routines which take an explicit display
259  * parameter.
260  * @note Displays are numbered from 0 to @p gdispGetDisplayCount() - 1
261  *
262  * @param[in] display The display number (0..n)
263  *
264  * @api
265  */
266 GDisplay *gdispGetDisplay(unsigned display);
267 
268 /**
269  * @brief Set the current default display to the specified display
270  * @note The default display is used for the gdispXxxx functions.
271  * @note The default display is contained in the variable GDISP. Using
272  * this function to set it protects against it being set to a NULL
273  * value.
274  * @note If a NULL is passed for the dispay this call is ignored.
275  *
276  * @param[in] g The display to use
277  *
278  * @api
279  */
280 void gdispSetDisplay(GDisplay *g);
281 
282 /**
283  * @brief Get the count of currently active displays
284  * @return The count of displays currently in the system
285  *
286  * @note Displays are numbered from 0 to @p gdispGetDisplayCount() - 1
287  */
288 unsigned gdispGetDisplayCount(void);
289 
290 /* Property Functions */
291 
292 /**
293  * @brief Get the display width in pixels.
294  *
295  * @param[in] g The display to use
296  *
297  * @return The width of the display
298  *
299  * @api
300  */
301 gCoord gdispGGetWidth(GDisplay *g);
302 #define gdispGetWidth() gdispGGetWidth(GDISP)
303 
304 /**
305  * @brief Get the display height in pixels.
306  *
307  * @param[in] g The display to use
308  *
309  * @return The height of the display
310  *
311  * @api
312  */
313 gCoord gdispGGetHeight(GDisplay *g);
314 #define gdispGetHeight() gdispGGetHeight(GDISP)
315 
316 /**
317  * @brief Get the current display power mode.
318  *
319  * @param[in] g The display to use
320  *
321  * @return The current power mode
322  *
323  * @api
324  */
326 #define gdispGetPowerMode() gdispGGetPowerMode(GDISP)
327 
328 /**
329  * @brief Get the current display orientation.
330  *
331  * @param[in] g The display to use
332  *
333  * @return The current orientation
334  *
335  * @api
336  */
338 #define gdispGetOrientation() gdispGGetOrientation(GDISP)
339 
340 /**
341  * @brief Get the current display backlight brightness.
342  *
343  * @param[in] g The display to use
344  *
345  * @return The current backlight value
346  *
347  * @api
348  */
349 gU8 gdispGGetBacklight(GDisplay *g);
350 #define gdispGetBacklight() gdispGGetBacklight(GDISP)
351 
352 /**
353  * @brief Get the current display contrast.
354  *
355  * @param[in] g The display to use
356  *
357  * @return The current contrast value
358  *
359  * @api
360  */
361 gU8 gdispGGetContrast(GDisplay *g);
362 #define gdispGetContrast() gdispGGetContrast(GDISP)
363 
364 /* Drawing Functions */
365 
366 /**
367  * @brief Flush current drawing operations to the display
368  * @note Some low level drivers do not update the display until
369  * the display is flushed. For others it is optional but can
370  * help prevent tearing effects. For some it is ignored.
371  * Calling it at the end of a logic set of drawing operations
372  * in your application will ensure controller portability. If you
373  * know your controller does not need to be flushed there is no
374  * need to call it (which is in reality most controllers).
375  * @note Even for displays that require flushing, there is no need to
376  * call this function if GDISP_NEED_AUTOFLUSH is GFXON.
377  * Calling it again won't hurt though.
378  *
379  *
380  * @param[in] g The display to use
381  *
382  * @api
383  */
384 void gdispGFlush(GDisplay *g);
385 #define gdispFlush() gdispGFlush(GDISP)
386 
387 /**
388  * @brief Clear the display to the specified color.
389  *
390  * @param[in] g The display to use
391  * @param[in] color The color to use when clearing the screen
392  *
393  * @api
394  */
395 void gdispGClear(GDisplay *g, gColor color);
396 #define gdispClear(c) gdispGClear(GDISP, c)
397 
398 /**
399  * @brief Set a pixel in the specified color.
400  *
401  * @param[in] g The display to use
402  * @param[in] x,y The position to set the pixel.
403  * @param[in] color The color to use
404  *
405  * @api
406  */
407 void gdispGDrawPixel(GDisplay *g, gCoord x, gCoord y, gColor color);
408 #define gdispDrawPixel(x,y,c) gdispGDrawPixel(GDISP,x,y,c)
409 
410 /**
411  * @brief Draw a line.
412  *
413  * @param[in] g The display to use
414  * @param[in] x0,y0 The start position
415  * @param[in] x1,y1 The end position
416  * @param[in] color The color to use
417  *
418  * @api
419  */
420 void gdispGDrawLine(GDisplay *g, gCoord x0, gCoord y0, gCoord x1, gCoord y1, gColor color);
421 #define gdispDrawLine(x0,y0,x1,y1,c) gdispGDrawLine(GDISP,x0,y0,x1,y1,c)
422 
423 /**
424  * @brief Fill an area with a color.
425  *
426  * @param[in] g The display to use
427  * @param[in] x,y The start position
428  * @param[in] cx,cy The size of the box (outside dimensions)
429  * @param[in] color The color to use
430  *
431  * @api
432  */
433 void gdispGFillArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor color);
434 #define gdispFillArea(x,y,cx,cy,c) gdispGFillArea(GDISP,x,y,cx,cy,c)
435 
436 /**
437  * @brief Fill an area using the supplied bitmap.
438  * @details The bitmap is in the pixel format specified by the low level driver
439  * @note If a packed pixel format is used and the width doesn't
440  * match a whole number of bytes, the next line will start on a
441  * non-byte boundary (no end-of-line padding).
442  * @note If GDISP_NEED_ASYNC is defined then the buffer must be static
443  * or at least retained until this call has finished the blit. You can
444  * tell when all graphics drawing is finished by @p gdispIsBusy() going gFalse.
445  *
446  * @param[in] g The display to use
447  * @param[in] x,y The start position
448  * @param[in] cx,cy The size of the filled area
449  * @param[in] srcx,srcy The bitmap position to start the fill form
450  * @param[in] srccx The width of a line in the bitmap
451  * @param[in] buffer The bitmap in the driver's pixel format
452  *
453  * @api
454  */
455 void gdispGBlitArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const gPixel *buffer);
456 #define gdispBlitAreaEx(x,y,cx,cy,sx,sy,rx,b) gdispGBlitArea(GDISP,x,y,cx,cy,sx,sy,rx,b)
457 
458 /**
459  * @brief Draw a rectangular box.
460  *
461  * @param[in] g The display to use
462  * @param[in] x,y The start position
463  * @param[in] cx,cy The size of the box (outside dimensions)
464  * @param[in] color The color to use
465  *
466  * @api
467  */
468 void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor color);
469 #define gdispDrawBox(x,y,cx,cy,c) gdispGDrawBox(GDISP,x,y,cx,cy,c)
470 
471 /* Streaming Functions */
472 
473 #if GDISP_NEED_STREAMING || defined(__DOXYGEN__)
474  /**
475  * @brief Start a streaming operation.
476  * @details Stream data to a window on the display sequentially and very fast.
477  * @pre GDISP_NEED_STREAMING must be GFXON in your gfxconf.h
478  * @note While streaming is in operation - no other calls to GDISP functions
479  * can be made (with the exception of @p gdispBlendColor() and streaming
480  * functions). If a call is made (eg in a multi-threaded application) the other
481  * call is blocked waiting for the streaming operation to finish.
482  * @note @p gdispStreamStop() must be called to finish the streaming operation.
483  * @note If more data is written than the defined area then the results are unspecified.
484  * Some drivers may wrap back to the beginning of the area, others may just
485  * ignore subsequent data.
486  * @note Unlike most operations that clip the defined area to the display to generate
487  * a smaller active area, this call will just silently fail if any of the stream
488  * region lies outside the current clipping area.
489  * @note A streaming operation may be terminated early (without writing to every location
490  * in the stream area) by calling @p gdispStreamStop().
491  *
492  * @param[in] g The display to use
493  * @param[in] x,y The start position
494  * @param[in] cx,cy The size of the streamable area
495  *
496  * @api
497  */
498  void gdispGStreamStart(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy);
499  #define gdispStreamStart(x,y,cx,cy) gdispGStreamStart(GDISP,x,y,cx,cy)
500 
501  /**
502  * @brief Send pixel data to the stream.
503  * @details Write a pixel to the next position in the streamed area and increment the position
504  * @pre GDISP_NEED_STREAMING must be GFXON in your gfxconf.h
505  * @pre @p gdispStreamStart() has been called.
506  * @note If the gdispStreamStart() has not been called (or failed due to clipping), the
507  * data provided here is simply thrown away.
508  *
509  * @param[in] g The display to use
510  * @param[in] color The color of the pixel to write
511  *
512  * @api
513  */
514  void gdispGStreamColor(GDisplay *g, gColor color);
515  #define gdispStreamColor(c) gdispGStreamColor(GDISP,c)
516 
517  /**
518  * @brief Finish the current streaming operation.
519  * @details Completes the current streaming operation and allows other GDISP calls to operate again.
520  * @pre GDISP_NEED_STREAMING must be GFXON in your gfxconf.h
521  * @pre @p gdispStreamStart() has been called.
522  * @note If the gdispStreamStart() has not been called (or failed due to clipping), this
523  * call is simply ignored.
524  *
525  * @param[in] g The display to use
526  *
527  * @api
528  */
529  void gdispGStreamStop(GDisplay *g);
530  #define gdispStreamStop() gdispGStreamStop(GDISP)
531 #endif
532 
533 /* Clipping Functions */
534 
535 #if GDISP_NEED_CLIP || defined(__DOXYGEN__)
536  /**
537  * @brief Clip all drawing to the defined area.
538  * @pre GDISP_NEED_CLIP must be GFXON in your gfxconf.h
539  *
540  * @param[in] g The display to use
541  * @param[in] x,y The start position
542  * @param[in] cx,cy The size of the clip area
543  *
544  * @api
545  */
546  void gdispGSetClip(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy);
547  #define gdispSetClip(x,y,cx,cy) gdispGSetClip(GDISP,x,y,cx,cy)
548 #endif
549 
550 /* Circle Functions */
551 
552 #if GDISP_NEED_CIRCLE || defined(__DOXYGEN__)
553  /**
554  * @brief Draw a circle.
555  * @pre GDISP_NEED_CIRCLE must be GFXON in your gfxconf.h
556  *
557  * @param[in] g The display to use
558  * @param[in] x,y The center of the circle
559  * @param[in] radius The radius of the circle
560  * @param[in] color The color to use
561  *
562  * @api
563  */
564  void gdispGDrawCircle(GDisplay *g, gCoord x, gCoord y, gCoord radius, gColor color);
565  #define gdispDrawCircle(x,y,r,c) gdispGDrawCircle(GDISP,x,y,r,c)
566 
567  /**
568  * @brief Draw a filled circle.
569  * @pre GDISP_NEED_CIRCLE must be GFXON in your gfxconf.h
570  *
571  * @param[in] g The display to use
572  * @param[in] x,y The center of the circle
573  * @param[in] radius The radius of the circle
574  * @param[in] color The color to use
575  *
576  * @api
577  */
578  void gdispGFillCircle(GDisplay *g, gCoord x, gCoord y, gCoord radius, gColor color);
579  #define gdispFillCircle(x,y,r,c) gdispGFillCircle(GDISP,x,y,r,c)
580 #endif
581 
582 #if GDISP_NEED_DUALCIRCLE || defined(__DOXYGEN__)
583  /**
584  * @brief Draw two filled circles with the same centre.
585  * @pre GDISP_NEED_DUALCIRCLE must be GFXON in your gfxconf.h
586  *
587  * @param[in] g The display to use
588  * @param[in] x,y The center of the circle
589  * @param[in] radius1 The radius of the larger circle
590  * @param[in] color1 The color to use for the larger circle
591  * @param[in] radius2 The radius of the smaller circle
592  * @param[in] color2 The color to use for the smaller circle
593  *
594  * @api
595  */
596  void gdispGFillDualCircle(GDisplay *g, gCoord x, gCoord y, gCoord radius1, gColor color1, gCoord radius2, gColor color2);
597  #define gdispFillDualCircle(x,y,r1,c1,r2,c2) gdispGFillDualCircle(GDISP,x,y,r1,c1,r2,c2)
598 #endif
599 
600 /* Ellipse Functions */
601 
602 #if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__)
603  /**
604  * @brief Draw an ellipse.
605  * @pre GDISP_NEED_ELLIPSE must be GFXON in your gfxconf.h
606  *
607  * @param[in] g The display to use
608  * @param[in] x,y The center of the ellipse
609  * @param[in] a,b The dimensions of the ellipse
610  * @param[in] color The color to use
611  *
612  * @api
613  */
614  void gdispGDrawEllipse(GDisplay *g, gCoord x, gCoord y, gCoord a, gCoord b, gColor color);
615  #define gdispDrawEllipse(x,y,a,b,c) gdispGDrawEllipse(GDISP,x,y,a,b,c)
616 
617  /**
618  * @brief Draw a filled ellipse.
619  * @pre GDISP_NEED_ELLIPSE must be GFXON in your gfxconf.h
620  *
621  * @param[in] g The display to use
622  * @param[in] x,y The center of the ellipse
623  * @param[in] a,b The dimensions of the ellipse
624  * @param[in] color The color to use
625  *
626  * @api
627  */
628  void gdispGFillEllipse(GDisplay *g, gCoord x, gCoord y, gCoord a, gCoord b, gColor color);
629  #define gdispFillEllipse(x,y,a,b,c) gdispGFillEllipse(GDISP,x,y,a,b,c)
630 #endif
631 
632 /* Arc Functions */
633 #if GDISP_NEED_ARCSECTORS || defined(__DOXYGEN__)
634  /**
635  * @brief Draw a selection of 45 degree arcs of a circle
636  * @pre GDISP_NEED_ARCSECTORS must be GFXON in your gfxconf.h
637  *
638  * @param[in] g The display to use
639  * @param[in] x,y The center of the circle
640  * @param[in] radius The radius of the circle
641  * @param[in] sectors Bits determine which sectors are drawn.
642  * Bits go anti-clockwise from the 0 degree mark (y = 0, x is positive), as follows:
643  * bit 0 - upper right right -----
644  * bit 1 - upper upper right /2 1\
645  * bit 2 - upper upper left /3 0\
646  * bit 3 - upper left left \4 7/
647  * bit 4 - lower left left \5 6/
648  * bit 5 - lower lower left -----
649  * bit 6 - lower lower right
650  * bit 7 - lower left left
651  * @param[in] color The color to use
652  *
653  * @note This is a more limited versions of the general arc drawing routine. It
654  * doesn't require trig libraries or tables or floating point and is smaller in code size.
655  * There is probably little point in including both this and the general
656  * arc routine as the general arc routine can do everything this can do.
657  *
658  * @api
659  */
660  void gdispGDrawArcSectors(GDisplay *g, gCoord x, gCoord y, gCoord radius, gU8 sectors, gColor color);
661  #define gdispDrawArcSectors(x,y,r,s,c) gdispGDrawArcSectors(GDISP,x,y,r,s,c)
662 
663  /**
664  * @brief Fill a selection of 45 degree arcs of a circle
665  * @pre GDISP_NEED_ARCSECTORS must be GFXON in your gfxconf.h
666  *
667  * @param[in] g The display to use
668  * @param[in] x,y The center of the circle
669  * @param[in] radius The radius of the circle
670  * @param[in] sectors Bits determine which sectors are drawn.
671  * Bits go anti-clockwise from the 0 degree mark (y = 0, x is positive), as follows:
672  * bit 0 - upper right right -----
673  * bit 1 - upper upper right /2 1\
674  * bit 2 - upper upper left /3 0\
675  * bit 3 - upper left left \4 7/
676  * bit 4 - lower left left \5 6/
677  * bit 5 - lower lower left -----
678  * bit 6 - lower lower right
679  * bit 7 - lower left left
680  * @param[in] color The color to use
681  *
682  * @note This is a more limited versions of the general arc filling routine. It
683  * doesn't require trig libraries or tables or floating point and is smaller in code size.
684  * There is probably little point in including both this and the general
685  * arc routine as the general arc routine can do everything this can do.
686  *
687  * @api
688  */
689  void gdispGFillArcSectors(GDisplay *g, gCoord x, gCoord y, gCoord radius, gU8 sectors, gColor color);
690  #define gdispFillArcSectors(x,y,r,s,c) gdispGFillArcSectors(GDISP,x,y,r,s,c)
691 #endif
692 
693 #if GDISP_NEED_ARC || defined(__DOXYGEN__)
694  /**
695  * @brief Draw an arc.
696  * @pre GDISP_NEED_ARC must be GFXON in your gfxconf.h
697  *
698  * @param[in] g The display to use
699  * @param[in] x,y The center point
700  * @param[in] radius The radius of the arc
701  * @param[in] startangle The start angle (0 to 360)
702  * @param[in] endangle The end angle (0 to 360)
703  * @param[in] color The color of the arc
704  *
705  * @note If you are just doing 45 degree angles consider using @p gdispDrawArcSectors() instead.
706  * @note This routine requires trig support. It can either come from your C runtime library
707  * cos() and sin() which requires floating point support (and is slow), or you can define GFX_USE_GMISC
708  * and either GMISC_NEED_FIXEDTRIG or GMISC_NEED_FASTTRIG.
709  * GMISC_NEED_FASTTRIG uses table based floating point trig operations.
710  * GMISC_NEED_FIXEDTRIG uses fixed point integer trig operations.
711  * Note accuracy on both the table based options are more than adequate for the one degree
712  * resolution provided by these arc routines. Both are much faster than your C runtime library.
713  *
714  * @api
715  */
716  void gdispGDrawArc(GDisplay *g, gCoord x, gCoord y, gCoord radius, gCoord startangle, gCoord endangle, gColor color);
717  #define gdispDrawArc(x,y,r,s,e,c) gdispGDrawArc(GDISP,x,y,r,s,e,c)
718 
719  /**
720  * @brief Draw a thick arc.
721  * @pre GDISP_NEED_ARC must be GFXON in your gfxconf.h
722  *
723  * @param[in] g The display to use
724  * @param[in] xc,yc The center point
725  * @param[in] startradius The inner radius of the thick arc
726  * @param[in] endradius The outer radius of the thick arc
727  * @param[in] startangle The start angle (0 to 360)
728  * @param[in] endangle The end angle (0 to 360)
729  * @param[in] color The color of the arc
730  *
731  * @note This routine requires trig support. It can either come from your C runtime library
732  * cos() and sin() which requires floating point support (and is slow), or you can define GFX_USE_GMISC
733  * and either GMISC_NEED_FIXEDTRIG or GMISC_NEED_FASTTRIG.
734  * GMISC_NEED_FASTTRIG uses table based floating point trig operations.
735  * GMISC_NEED_FIXEDTRIG uses fixed point integer trig operations.
736  * Note accuracy on both the table based options are more than adequate for the one degree
737  * resolution provided by these arc routines. Both are much faster than your C runtime library.
738  *
739  * @api
740  */
741  void gdispGDrawThickArc(GDisplay *g, gCoord xc, gCoord yc, gCoord startradius, gCoord endradius, gCoord startangle, gCoord endangle, gColor color);
742  #define gdispDrawThickArc(x,y,rs,re,s,e,c) gdispGDrawThickArc(GDISP,x,y,rs,re,s,e,c)
743 
744  /**
745  * @brief Draw a filled arc.
746  * @pre GDISP_NEED_ARC must be GFXON in your gfxconf.h
747  *
748  * @param[in] g The display to use
749  * @param[in] x,y The center point
750  * @param[in] radius The radius of the arc
751  * @param[in] startangle The start angle (0 to 360)
752  * @param[in] endangle The end angle (0 to 360)
753  * @param[in] color The color of the arc
754  *
755  * @note If you are just doing 45 degree angles consider using @p gdispFillArcSectors() instead.
756  * @note This routine requires trig support. It can either come from your C runtime library
757  * cos() and sin() which requires floating point support (and is slow), or you can define GFX_USE_GMISC
758  * and either GMISC_NEED_FIXEDTRIG or GMISC_NEED_FASTTRIG.
759  * GMISC_NEED_FASTTRIG uses table based floating point trig operations.
760  * GMISC_NEED_FIXEDTRIG uses fixed point integer trig operations.
761  * Note accuracy on both the table based options are more than adequate for the one degree
762  * resolution provided by these arc routines. Both are much faster than your C runtime library.
763  *
764  * @api
765  */
766  void gdispGFillArc(GDisplay *g, gCoord x, gCoord y, gCoord radius, gCoord startangle, gCoord endangle, gColor color);
767  #define gdispFillArc(x,y,r,s,e,c) gdispGFillArc(GDISP,x,y,r,s,e,c)
768 #endif
769 
770 /* Read a pixel Function */
771 
772 #if GDISP_NEED_PIXELREAD || defined(__DOXYGEN__)
773  /**
774  * @brief Get the color of a pixel.
775  * @return The color of the pixel.
776  * @pre GDISP_NEED_PIXELREAD must be GFXON in your gfxconf.h
777  *
778  * @param[in] g The display to use
779  * @param[in] x,y The position of the pixel
780  *
781  * @api
782  */
784  #define gdispGetPixelColor(x,y) gdispGGetPixelColor(GDISP,x,y)
785 #endif
786 
787 /* Scrolling Function - clears the area scrolled out */
788 
789 #if GDISP_NEED_SCROLL || defined(__DOXYGEN__)
790  /**
791  * @brief Scroll vertically a section of the screen.
792  * @pre GDISP_NEED_SCROLL must be set to GFXON in gfxconf.h
793  * @note Optional.
794  * @note If lines is >= cy, it is equivelent to an area fill with bgcolor.
795  *
796  * @param[in] g The display to use
797  * @param[in] x, y The start of the area to be scrolled
798  * @param[in] cx, cy The size of the area to be scrolled
799  * @param[in] lines The number of lines to scroll (Can be positive or negative)
800  * @param[in] bgcolor The color to fill the newly exposed area.
801  *
802  * @api
803  */
804  void gdispGVerticalScroll(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, int lines, gColor bgcolor);
805  #define gdispVerticalScroll(x,y,cx,cy,l,b) gdispGVerticalScroll(GDISP,x,y,cx,cy,l,b)
806 #endif
807 
808 /* Set driver specific control */
809 
810 #if GDISP_NEED_CONTROL || defined(__DOXYGEN__)
811  /**
812  * @brief Control hardware specific parts of the display. eg powermodes, backlight etc
813  * @pre GDISP_NEED_CONTROL must be GFXON in your gfxconf.h
814  * @note Depending on the hardware implementation this function may not
815  * support some codes. They will be ignored.
816  *
817  * @param[in] g The display to use
818  * @param[in] what what you want to control
819  * @param[in] value The value to be assigned
820  *
821  * @api
822  */
823  void gdispGControl(GDisplay *g, unsigned what, void *value);
824  #define gdispControl(w,v) gdispGControl(GDISP,w,v)
825 #endif
826 
827 /* Query driver specific data */
828 
829 #if GDISP_NEED_QUERY || defined(__DOXYGEN__)
830  /**
831  * @brief Query a property of the display.
832  * @pre GDISP_NEED_QUERY must be GFXON in your gfxconf.h
833  * @note The result must be typecast to the correct type.
834  * @note An unsupported query will return (void *)-1.
835  *
836  * @param[in] g The display to use
837  * @param[in] what What to query
838  *
839  * @api
840  */
841  void *gdispGQuery(GDisplay *g, unsigned what);
842  #define gdispQuery(w) gdispGQuery(GDISP,w)
843 #endif
844 
845 #if GDISP_NEED_CONVEX_POLYGON || defined(__DOXYGEN__)
846  /**
847  * @brief Draw an enclosed polygon (convex, non-convex or complex).
848  * @pre GDISP_NEED_CONVEX_POLYGON must be GFXON in your gfxconf.h
849  *
850  * @param[in] g The display to use
851  * @param[in] tx, ty Transform all points in pntarray by tx, ty
852  * @param[in] pntarray An array of points
853  * @param[in] cnt The number of points in the array
854  * @param[in] color The color to use
855  *
856  * @api
857  */
858  void gdispGDrawPoly(GDisplay *g, gCoord tx, gCoord ty, const gPoint *pntarray, unsigned cnt, gColor color);
859  #define gdispDrawPoly(x,y,p,i,c) gdispGDrawPoly(GDISP,x,y,p,i,c)
860 
861  /**
862  * @brief Fill a convex polygon
863  * @details Doesn't handle non-convex or complex polygons.
864  * @pre GDISP_NEED_CONVEX_POLYGON must be GFXON in your gfxconf.h
865  *
866  * @param[in] g The display to use
867  * @param[in] tx, ty Transform all points in pntarray by tx, ty
868  * @param[in] pntarray An array of points
869  * @param[in] cnt The number of points in the array
870  * @param[in] color The color to use
871  *
872  * @note Convex polygons are those that have no internal angles. That is;
873  * you can draw a line from any point on the polygon to any other point
874  * on the polygon without it going outside the polygon. In our case we generalise
875  * this a little by saying that an infinite horizontal line (at any y value) will cross
876  * no more than two edges on the polygon. Some non-convex polygons do fit this criteria
877  * and can therefore be drawn.
878  * @note This routine is designed to be very efficient with even simple display hardware.
879  *
880  * @api
881  */
882  void gdispGFillConvexPoly(GDisplay *g, gCoord tx, gCoord ty, const gPoint *pntarray, unsigned cnt, gColor color);
883  #define gdispFillConvexPoly(x,y,p,i,c) gdispGFillConvexPoly(GDISP,x,y,p,i,c)
884 
885  /**
886  * @brief Draw a line with a specified thickness
887  * @details The line thickness is specified in pixels. The line ends can
888  * be selected to be either flat or round.
889  * @pre GDISP_NEED_CONVEX_POLYGON must be GFXON in your gfxconf.h
890  * @note Uses gdispGFillConvexPoly() internally to perform the drawing.
891  *
892  * @param[in] g The display to use
893  * @param[in] x0,y0 The start position
894  * @param[in] x1,y1 The end position
895  * @param[in] color The color to use
896  * @param[in] width The width of the line
897  * @param[in] round Use round ends for the line
898  *
899  * @api
900  */
901  void gdispGDrawThickLine(GDisplay *g, gCoord x0, gCoord y0, gCoord x1, gCoord y1, gColor color, gCoord width, gBool round);
902  #define gdispDrawThickLine(x0,y0,x1,y1,c,w,r) gdispGDrawThickLine(GDISP,x0,y0,x1,y1,c,w,r)
903 #endif
904 
905 /* Text Functions */
906 
907 #if GDISP_NEED_TEXT || defined(__DOXYGEN__)
908  /**
909  * @brief Draw a text character.
910  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
911  *
912  * @param[in] g The display to use
913  * @param[in] x,y The position for the text
914  * @param[in] c The character to draw
915  * @param[in] font The font to use
916  * @param[in] color The color to use
917  *
918  * @api
919  */
920  void gdispGDrawChar(GDisplay *g, gCoord x, gCoord y, gU16 c, gFont font, gColor color);
921  #define gdispDrawChar(x,y,s,f,c) gdispGDrawChar(GDISP,x,y,s,f,c)
922 
923  /**
924  * @brief Draw a text character with a filled background.
925  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
926  *
927  * @param[in] g The display to use
928  * @param[in] x,y The position for the text
929  * @param[in] c The character to draw
930  * @param[in] font The font to use
931  * @param[in] color The color to use
932  * @param[in] bgcolor The background color to use
933  *
934  * @api
935  */
936  void gdispGFillChar(GDisplay *g, gCoord x, gCoord y, gU16 c, gFont font, gColor color, gColor bgcolor);
937  #define gdispFillChar(x,y,s,f,c,b) gdispGFillChar(GDISP,x,y,s,f,c,b)
938 
939  /**
940  * @brief Draw a text string.
941  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
942  *
943  * @param[in] g The display to use
944  * @param[in] x,y The position for the text
945  * @param[in] str The string to draw
946  * @param[in] font The font to use
947  * @param[in] color The color to use
948  *
949  * @api
950  */
951  void gdispGDrawString(GDisplay *g, gCoord x, gCoord y, const char *str, gFont font, gColor color);
952  #define gdispDrawString(x,y,s,f,c) gdispGDrawString(GDISP,x,y,s,f,c)
953 
954  /**
955  * @brief Draw a text string.
956  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
957  *
958  * @param[in] g The display to use
959  * @param[in] x,y The position for the text
960  * @param[in] str The string to draw
961  * @param[in] font The font to use
962  * @param[in] color The color to use
963  * @param[in] bgcolor The background color to use
964  *
965  * @api
966  */
967  void gdispGFillString(GDisplay *g, gCoord x, gCoord y, const char *str, gFont font, gColor color, gColor bgcolor);
968  #define gdispFillString(x,y,s,f,c,b) gdispGFillString(GDISP,x,y,s,f,c,b)
969 
970  /**
971  * @brief Draw a text string vertically centered within the specified box.
972  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
973  *
974  * @param[in] g The display to use
975  * @param[in] x,y The position for the text (need to define top-right or base-line - check code)
976  * @param[in] cx,cy The width and height of the box
977  * @param[in] str The string to draw
978  * @param[in] font The font to use
979  * @param[in] color The color to use
980  * @param[in] justify Justify the text left, center or right within the box
981  *
982  * @api
983  */
984  void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, gFont font, gColor color, gJustify justify);
985  #define gdispDrawStringBox(x,y,cx,cy,s,f,c,j) gdispGDrawStringBox(GDISP,x,y,cx,cy,s,f,c,j)
986 
987  /**
988  * @brief Draw a text string vertically centered within the specified box. The box background is filled with the specified background color.
989  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
990  * @note The entire box is filled
991  *
992  * @param[in] g The display to use
993  * @param[in] x,y The position for the text (need to define top-right or base-line - check code)
994  * @param[in] cx,cy The width and height of the box
995  * @param[in] str The string to draw
996  * @param[in] font The font to use
997  * @param[in] color The color to use
998  * @param[in] bgColor The background color to use
999  * @param[in] justify Justify the text left, center or right within the box
1000  *
1001  * @api
1002  */
1003  void gdispGFillStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, gFont font, gColor color, gColor bgColor, gJustify justify);
1004  #define gdispFillStringBox(x,y,cx,cy,s,f,c,b,j) gdispGFillStringBox(GDISP,x,y,cx,cy,s,f,c,b,j)
1005 
1006  /**
1007  * @brief Get a metric of a font.
1008  * @return The metric requested in pixels.
1009  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
1010  *
1011  * @param[in] font The font to test
1012  * @param[in] metric The metric to measure
1013  *
1014  * @api
1015  */
1017 
1018  /**
1019  * @brief Get the pixel width of a character.
1020  * @return The width of the character in pixels. Does not include any between character padding.
1021  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
1022  *
1023  * @param[in] c The character to draw
1024  * @param[in] font The font to use
1025  *
1026  * @api
1027  */
1029 
1030  /**
1031  * @brief Get the pixel width of a string of a given character length.
1032  * @return The width of the string in pixels.
1033  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
1034  *
1035  * @note Passing 0 to count has the same effect as calling gdispGetStringWidt()
1036  *
1037  * @param[in] str The string to measure
1038  * @param[in] font The font to use
1039  * @param[in] count The number of characters to take into account
1040  *
1041  * @api
1042  */
1043  gCoord gdispGetStringWidthCount(const char* str, gFont font, gU16 count);
1044 
1045  /**
1046  * @brief Get the pixel width of an entire string.
1047  * @return The width of the string in pixels.
1048  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
1049  *
1050  * @param[in] str The string to measure
1051  * @param[in] font The font to use
1052  *
1053  * @api
1054  */
1055  gCoord gdispGetStringWidth(const char* str, gFont font);
1056 
1057  /**
1058  * @brief Find a font and return it.
1059  * @details The supplied name is matched against the font name. A '*' will replace 0 or more characters.
1060  * @return Returns a font or NULL if no matching font could be found.
1061  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
1062  *
1063  * @param[in] name The font name to find.
1064  *
1065  * @note Wildcard matching will match the shortest possible match.
1066  *
1067  * @api
1068  */
1069  gFont gdispOpenFont(const char *name);
1070 
1071  /**
1072  * @brief Release a font after use.
1073  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
1074  *
1075  * @param[in] font The font to release.
1076  *
1077  * @api
1078  */
1079  void gdispCloseFont(gFont font);
1080 
1081  /**
1082  * @brief Make a scaled copy of an existing font.
1083  * @details Allocates memory for new font metadata using gfxAlloc, remember to close font after use!
1084  * @return A new font or NULL if out of memory.
1085  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
1086  * @note A scaled font should probably not be added to the font list as it will prevent the
1087  * unscaled font of the same name being found as it will be the scaled version that will be found.
1088  *
1089  * @param[in] font The base font to use.
1090  * @param[in] scale_x The scale factor in horizontal direction.
1091  * @param[in] scale_y The scale factor in vertical direction.
1092  */
1093  gFont gdispScaleFont(gFont font, gU8 scale_x, gU8 scale_y);
1094 
1095  /**
1096  * @brief Get the name of the specified font.
1097  * @returns The name of the font.
1098  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
1099  *
1100  * @param[in] font The font to get the name for.
1101  *
1102  * @api
1103  */
1104  const char *gdispGetFontName(gFont font);
1105 
1106  /**
1107  * @brief Add a font permanently to the font list.
1108  * @returns gTrue on success. Reasons it may fail: out of memory, if it is already on the list, it is not a font loaded in RAM.
1109  * @pre GDISP_NEED_TEXT must be GFXON in your gfxconf.h
1110  *
1111  * @param[in] font The font to add to the font list.
1112  *
1113  * @api
1114  */
1115  gBool gdispAddFont(gFont font);
1116 #endif
1117 
1118 /* Extra Arc Functions */
1119 
1120 #if GDISP_NEED_ARC || GDISP_NEED_ARCSECTORS || defined(__DOXYGEN__)
1121  /**
1122  * @brief Draw a rectangular box with rounded corners
1123  * @pre GDISP_NEED_ARC or GDISP_NEED_ARCSECTORS must be GFXON in your gfxconf.h
1124  *
1125  * @param[in] g The display to use
1126  * @param[in] x,y The start position
1127  * @param[in] cx,cy The size of the box (outside dimensions)
1128  * @param[in] radius The radius of the rounded corners
1129  * @param[in] color The color to use
1130  *
1131  * @api
1132  */
1133  void gdispGDrawRoundedBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord radius, gColor color);
1134  #define gdispDrawRoundedBox(x,y,cx,cy,r,c) gdispGDrawRoundedBox(GDISP,x,y,cx,cy,r,c)
1135 
1136  /**
1137  * @brief Draw a filled rectangular box with rounded corners
1138  * @pre GDISP_NEED_ARC or GDISP_NEED_ARCSECTORS must be GFXON in your gfxconf.h
1139  *
1140  * @param[in] g The display to use
1141  * @param[in] x,y The start position
1142  * @param[in] cx,cy The size of the box (outside dimensions)
1143  * @param[in] radius The radius of the rounded corners
1144  * @param[in] color The color to use
1145  *
1146  * @api
1147  */
1148  void gdispGFillRoundedBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord radius, gColor color);
1149  #define gdispFillRoundedBox(x,y,cx,cy,r,c) gdispGFillRoundedBox(GDISP,x,y,cx,cy,r,c)
1150 #endif
1151 
1152 /*
1153  * Macro definitions
1154  */
1155 
1156 /* Now obsolete functions */
1157 #define gdispBlitArea(x, y, cx, cy, buffer) gdispGBlitArea(GDISP, x, y, cx, cy, 0, 0, cx, buffer)
1158 
1159 /* Macro definitions for common gets and sets */
1160 
1161 /**
1162  * @brief Set the display power mode.
1163  * @note Ignored if not supported by the display.
1164  *
1165  * @param[in] g The display to use
1166  * @param[in] powerMode The new power mode
1167  *
1168  * @api
1169  */
1170 #define gdispGSetPowerMode(g, powerMode) gdispGControl((g), GDISP_CONTROL_POWER, (void *)(gPowermode)(powerMode))
1171 #define gdispSetPowerMode(powerMode) gdispGControl(GDISP, GDISP_CONTROL_POWER, (void *)(gPowermode)(powerMode))
1172 
1173 /**
1174  * @brief Set the display orientation.
1175  * @note Ignored if not supported by the display.
1176  *
1177  * @param[in] g The display to use
1178  * @param[in] newOrientation The new orientation
1179  *
1180  * @api
1181  */
1182 #define gdispGSetOrientation(g, newOrientation) gdispGControl((g), GDISP_CONTROL_ORIENTATION, (void *)(unsigned)(newOrientation))
1183 #define gdispSetOrientation(newOrientation) gdispGControl(GDISP, GDISP_CONTROL_ORIENTATION, (void *)(unsigned)(newOrientation))
1184 
1185 /**
1186  * @brief Set the display backlight.
1187  * @note Ignored if not supported by the display.
1188  *
1189  * @param[in] g The display to use
1190  * @param[in] percent The new brightness (0 - 100%)
1191  *
1192  * @note For displays that only support backlight off and on,
1193  * 0 = off, anything else = on
1194  *
1195  * @api
1196  */
1197 #define gdispGSetBacklight(g, percent) gdispGControl((g), GDISP_CONTROL_BACKLIGHT, (void *)(unsigned)(percent))
1198 #define gdispSetBacklight(percent) gdispGControl(GDISP, GDISP_CONTROL_BACKLIGHT, (void *)(unsigned)(percent))
1199 
1200 /**
1201  * @brief Set the display contrast.
1202  * @note Ignored if not supported by the display.
1203  *
1204  * @param[in] g The display to use
1205  * @param[in] percent The new contrast (0 - 100%)
1206  *
1207  * @api
1208  */
1209 #define gdispGSetContrast(g, percent) gdispGControl((g), GDISP_CONTROL_CONTRAST, (void *)(unsigned)(percent))
1210 #define gdispSetContrast(percent) gdispGControl(GDISP, GDISP_CONTROL_CONTRAST, (void *)(unsigned)(percent))
1211 
1212 /* More interesting macros */
1213 
1214 /**
1215  * @brief Reset the clip area to the full screen
1216  *
1217  * @param[in] g The display to use
1218  *
1219  * @api
1220  */
1221 #define gdispGUnsetClip(g) gdispGSetClip((g),0,0,gdispGGetWidth(g),gdispGGetHeight(g))
1222 #define gdispUnsetClip() gdispGUnsetClip(GDISP)
1223 
1224 #if GDISP_NEED_IMAGE || defined(__DOXYGEN__)
1225  #include "gdisp_image.h"
1226 #endif
1227 #if GDISP_NEED_PIXMAP || defined(__DOXYGEN__)
1228  #include "gdisp_pixmap.h"
1229 #endif
1230 
1231 /* V2 compatibility */
1232 #if GFX_COMPAT_V2
1233  typedef gColorformat colorformat;
1234  typedef gColor color_t;
1235  typedef gPixel pixel_t;
1236  typedef gCoord coord_t;
1237  typedef gPoint point, point_t;
1238  typedef gFont font_t;
1239  typedef gPowermode powermode_t;
1240  #define powerOff gPowerOff
1241  #define powerDeepSleep gPowerDeepSleep
1242  #define powerSleep gPowerSleep
1243  #define powerOn gPowerOn
1244  typedef gOrientation orientation_t;
1245  #define GDISP_ROTATE_0 gOrientation0
1246  #define GDISP_ROTATE_90 gOrientation90
1247  #define GDISP_ROTATE_180 gOrientation180
1248  #define GDISP_ROTATE_270 gOrientation270
1249  #define GDISP_ROTATE_PORTRAIT gOrientationPortrait
1250  #define GDISP_ROTATE_LANDSCAPE gOrientationLandscape
1251  typedef gJustify justify_t;
1252  #define justifyLeft gJustifyLeft
1253  #define justifyCenter gJustifyCenter
1254  #define justifyRight gJustifyRight
1255  #define justifyTop gJustifyTop
1256  #define justifyMiddle gJustifyMiddle
1257  #define justifyBottom gJustifyBottom
1258  #define justifyWordWrap gJustifyWordWrap
1259  #define justifyNoWordWrap gJustifyNoWordWrap
1260  #define justifyPad gJustifyPad
1261  #define justifyNoPad gJustifyNoPad
1262  #define JUSTIFYMASK_LEFTRIGHT JUSTIFYMASK_HORIZONTAL
1263  #define JUSTIFYMASK_TOPBOTTOM JUSTIFYMASK_VERTICAL
1264  typedef gFontmetric fontmetric_t;
1265  #define fontHeight gFontHeight
1266  #define fontDescendersHeight gFontDescendersHeight
1267  #define fontLineSpacing gFontLineSpacing
1268  #define fontCharPadding gFontCharPadding
1269  #define fontMinWidth gFontMinWidth
1270  #define fontMaxWidth gFontMaxWidth
1271  #define fontBaselineX gFontBaselineX
1272  #define fontBaselineY gFontBaselineY
1273  #if GDISP_NEED_IMAGE || defined(__DOXYGEN__)
1274  typedef gImage gdispImage;
1275  #endif
1276 #endif
1277 
1278 #endif /* GFX_USE_GDISP */
1279 
1280 #endif /* _GDISP_H */
1281 /** @} */
COLOR_TYPE gColor
The color type definition.
Definition: gdisp_colors.h:437
GDisplay * gdispGetDisplay(unsigned display)
Get the specified display.
gFont gdispOpenFont(const char *name)
Find a font and return it.
void gdispGDrawArcSectors(GDisplay *g, gCoord x, gCoord y, gCoord radius, gU8 sectors, gColor color)
Draw a selection of 45 degree arcs of a circle.
gU8 gdispGGetBacklight(GDisplay *g)
Get the current display backlight brightness.
gColor gdispBlendColor(gColor fg, gColor bg, gU8 alpha)
Blend 2 colors according to the alpha.
void gdispGVerticalScroll(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, int lines, gColor bgcolor)
Scroll vertically a section of the screen.
gCoord gdispGetCharWidth(char c, gFont font)
Get the pixel width of a character.
void gdispGDrawPixel(GDisplay *g, gCoord x, gCoord y, gColor color)
Set a pixel in the specified color.
void gdispGFillChar(GDisplay *g, gCoord x, gCoord y, gU16 c, gFont font, gColor color, gColor bgcolor)
Draw a text character with a filled background.
gCoord gdispGetFontMetric(gFont font, gFontmetric metric)
Get a metric of a font.
void gdispGClear(GDisplay *g, gColor color)
Clear the display to the specified color.
void gdispGSetClip(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy)
Clip all drawing to the defined area.
GDisplay * GDISP
The default screen to use for the gdispXXXX calls.
void gdispGFillCircle(GDisplay *g, gCoord x, gCoord y, gCoord radius, gColor color)
Draw a filled circle.
void gdispGDrawPoly(GDisplay *g, gCoord tx, gCoord ty, const gPoint *pntarray, unsigned cnt, gColor color)
Draw an enclosed polygon (convex, non-convex or complex).
void gdispCloseFont(gFont font)
Release a font after use.
void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char *str, gFont font, gColor color, gJustify justify)
Draw a text string vertically centered within the specified box.
void gdispGDrawRoundedBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord radius, gColor color)
Draw a rectangular box with rounded corners.
gBool gdispAddFont(gFont font)
Add a font permanently to the font list.
void gdispGDrawEllipse(GDisplay *g, gCoord x, gCoord y, gCoord a, gCoord b, gColor color)
Draw an ellipse.
const struct mf_font_s * gFont
The type of a font.
Definition: gdisp.h:93
void gdispGFlush(GDisplay *g)
Flush current drawing operations to the display.
void * gdispGQuery(GDisplay *g, unsigned what)
Query a property of the display.
void gdispGBlitArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const gPixel *buffer)
Fill an area using the supplied bitmap.
gColor gPixel
The pixel format.
Definition: gdisp.h:226
gU8 gdispGGetContrast(GDisplay *g)
Get the current display contrast.
void gdispGStreamStart(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy)
Start a streaming operation.
gJustify
Type for the text justification.
Definition: gdisp.h:60
void gdispGFillArcSectors(GDisplay *g, gCoord x, gCoord y, gCoord radius, gU8 sectors, gColor color)
Fill a selection of 45 degree arcs of a circle.
void gdispGControl(GDisplay *g, unsigned what, void *value)
Control hardware specific parts of the display. eg powermodes, backlight etc.
void gdispGDrawThickArc(GDisplay *g, gCoord xc, gCoord yc, gCoord startradius, gCoord endradius, gCoord startangle, gCoord endangle, gColor color)
Draw a thick arc.
gOrientation
Type for the screen orientation.
Definition: gdisp.h:101
gOrientation gdispGGetOrientation(GDisplay *g)
Get the current display orientation.
void gdispGFillEllipse(GDisplay *g, gCoord x, gCoord y, gCoord a, gCoord b, gColor color)
Draw a filled ellipse.
void gdispGDrawCircle(GDisplay *g, gCoord x, gCoord y, gCoord radius, gColor color)
Draw a circle.
gCoord gdispGGetWidth(GDisplay *g)
Get the display width in pixels.
gColor gdispContrastColor(gColor color)
Find a contrasting color.
void gdispGFillArc(GDisplay *g, gCoord x, gCoord y, gCoord radius, gCoord startangle, gCoord endangle, gColor color)
Draw a filled arc.
const char * gdispGetFontName(gFont font)
Get the name of the specified font.
gPowermode
Type for the available power modes for the screen.
Definition: gdisp.h:114
void gdispGFillArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor color)
Fill an area with a color.
void gdispGDrawChar(GDisplay *g, gCoord x, gCoord y, gU16 c, gFont font, gColor color)
Draw a text character.
void gdispSetDisplay(GDisplay *g)
Set the current default display to the specified display.
void gdispGDrawLine(GDisplay *g, gCoord x0, gCoord y0, gCoord x1, gCoord y1, gColor color)
Draw a line.
void gdispGStreamStop(GDisplay *g)
Finish the current streaming operation.
void gdispGFillRoundedBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord radius, gColor color)
Draw a filled rectangular box with rounded corners.
void gdispGDrawArc(GDisplay *g, gCoord x, gCoord y, gCoord radius, gCoord startangle, gCoord endangle, gColor color)
Draw an arc.
unsigned gdispGetDisplayCount(void)
Get the count of currently active displays.
void gdispGFillStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char *str, gFont font, gColor color, gColor bgColor, gJustify justify)
Draw a text string vertically centered within the specified box. The box background is filled with th...
gColor gdispGGetPixelColor(GDisplay *g, gCoord x, gCoord y)
Get the color of a pixel.
gCoord gdispGetStringWidthCount(const char *str, gFont font, gU16 count)
Get the pixel width of a string of a given character length.
void gdispGDrawString(GDisplay *g, gCoord x, gCoord y, const char *str, gFont font, gColor color)
Draw a text string.
gPowermode gdispGGetPowerMode(GDisplay *g)
Get the current display power mode.
void gdispGDrawThickLine(GDisplay *g, gCoord x0, gCoord y0, gCoord x1, gCoord y1, gColor color, gCoord width, gBool round)
Draw a line with a specified thickness.
gCoord gdispGGetHeight(GDisplay *g)
Get the display height in pixels.
void gdispGFillDualCircle(GDisplay *g, gCoord x, gCoord y, gCoord radius1, gColor color1, gCoord radius2, gColor color2)
Draw two filled circles with the same centre.
void gdispGFillString(GDisplay *g, gCoord x, gCoord y, const char *str, gFont font, gColor color, gColor bgcolor)
Draw a text string.
gI16 gCoord
The type for a coordinate or length on the screen.
Definition: gdisp.h:39
gCoord gdispGetStringWidth(const char *str, gFont font)
Get the pixel width of an entire string.
void gdispGStreamColor(GDisplay *g, gColor color)
Send pixel data to the stream.
void gdispGFillConvexPoly(GDisplay *g, gCoord tx, gCoord ty, const gPoint *pntarray, unsigned cnt, gColor color)
Fill a convex polygon.
void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor color)
Draw a rectangular box.
gFont gdispScaleFont(gFont font, gU8 scale_x, gU8 scale_y)
Make a scaled copy of an existing font.
gFontmetric
Type for the font metric.
Definition: gdisp.h:79
@ gJustifyWordWrap
Definition: gdisp.h:67
@ gJustifyCenter
Definition: gdisp.h:62
@ gJustifyBottom
Definition: gdisp.h:66
@ gJustifyTop
Definition: gdisp.h:64
@ gJustifyLeft
Definition: gdisp.h:61
@ gJustifyMiddle
Definition: gdisp.h:65
@ gJustifyRight
Definition: gdisp.h:63
@ gJustifyNoPad
Definition: gdisp.h:70
@ gJustifyNoWordWrap
Definition: gdisp.h:68
@ gJustifyPad
Definition: gdisp.h:69
@ gOrientation180
Definition: gdisp.h:104
@ gOrientation0
Definition: gdisp.h:102
@ gOrientationLandscape
Definition: gdisp.h:107
@ gOrientation90
Definition: gdisp.h:103
@ gOrientationPortrait
Definition: gdisp.h:106
@ gOrientation270
Definition: gdisp.h:105
@ gPowerSleep
Definition: gdisp.h:116
@ gPowerOff
Definition: gdisp.h:115
@ gPowerDeepSleep
Definition: gdisp.h:117
@ gPowerOn
Definition: gdisp.h:118
@ gFontBaselineX
Definition: gdisp.h:86
@ gFontDescendersHeight
Definition: gdisp.h:81
@ gFontBaselineY
Definition: gdisp.h:87
@ gFontMaxWidth
Definition: gdisp.h:85
@ gFontMinWidth
Definition: gdisp.h:84
@ gFontHeight
Definition: gdisp.h:80
@ gFontLineSpacing
Definition: gdisp.h:82
@ gFontCharPadding
Definition: gdisp.h:83
The structure for an image.
Definition: gdisp_image.h:59
Type for a 2D point on the screen.
Definition: gdisp.h:51
gCoord y
Definition: gdisp.h:53
gCoord x
Definition: gdisp.h:52