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