diff options
author | Andrew Hannam <andrewh@inmarket.com.au> | 2012-08-09 17:12:45 +1000 |
---|---|---|
committer | Andrew Hannam <andrewh@inmarket.com.au> | 2012-08-09 17:18:32 +1000 |
commit | 8f9c956810cc2cc66306d41b8501b366eab9c035 (patch) | |
tree | bf7590abc8a9d1a64ee961755f61ab2c8ecc0107 /halext/templates | |
parent | fb070f8d2cb31481c4a80f4a56e86fb9cc9bf4cc (diff) | |
download | uGFX-8f9c956810cc2cc66306d41b8501b366eab9c035.tar.gz uGFX-8f9c956810cc2cc66306d41b8501b366eab9c035.tar.bz2 uGFX-8f9c956810cc2cc66306d41b8501b366eab9c035.zip |
Multi-thread, Async Multi-thread & VMT
Diffstat (limited to 'halext/templates')
-rw-r--r-- | halext/templates/gdispXXXXX/gdisp_lld.c | 99 | ||||
-rw-r--r-- | halext/templates/gdispXXXXX/gdisp_lld_config.h | 14 |
2 files changed, 69 insertions, 44 deletions
diff --git a/halext/templates/gdispXXXXX/gdisp_lld.c b/halext/templates/gdispXXXXX/gdisp_lld.c index cb465915..81e96894 100644 --- a/halext/templates/gdispXXXXX/gdisp_lld.c +++ b/halext/templates/gdispXXXXX/gdisp_lld.c @@ -32,27 +32,17 @@ #if HAL_USE_GDISP || defined(__DOXYGEN__)
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
-#ifdef UNUSED
-#elif defined(__GNUC__)
-# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
-#elif defined(__LCLINT__)
-# define UNUSED(x) /*@unused@*/ x
-#else
-# define UNUSED(x) x
-#endif
-
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
-#if !defined(__DOXYGEN__)
- GDISPDriver GDISP;
-#endif
-
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
@@ -61,7 +51,9 @@ /* Driver local functions. */
/*===========================================================================*/
-#include "gdisp_fonts.h"
+#if GDISP_NEED_TEXT
+ #include "gdisp_fonts.h"
+#endif
/* All the board specific code should go in these include file so the driver
* can be ported to another board just by creating a suitable file.
@@ -88,11 +80,12 @@ */
/**
- * @brief Low level GDISP driver initialization.
+ * @brief Low level GDISP driver initialisation.
+ * @return TRUE if successful, FALSE on error.
*
* @notapi
*/
-void gdisp_lld_init(void) {
+bool_t GDISP_LLD(init)(void) {
/* Initialise your display */
/* Initialise the GDISP structure to match */
@@ -100,6 +93,9 @@ void gdisp_lld_init(void) { GDISP.Height = SCREEN_HEIGHT;
GDISP.Orientation = portrait;
GDISP.Powermode = powerOn;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
}
/**
@@ -111,7 +107,7 @@ void gdisp_lld_init(void) { *
* @notapi
*/
-void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
+void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
#if GDISP_NEED_VALIDATION
if (x >= GDISP.Width || y >= GDISP.Height) return;
#endif
@@ -128,11 +124,11 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { Don't bother coding for obvious similar routines if
there is no performance penalty as the emulation software
makes a good job of using similar routines.
- eg. If gdisp_lld_fillarea() is defined there is little
- point in defining gdisp_lld_clear() unless the
+ eg. If fillarea() is defined there is little
+ point in defining clear() unless the
performance bonus is significant.
For good performance it is suggested to implement
- gdisp_lld_fillarea() and gdisp_lld_blitarea().
+ fillarea() and blitarea().
*/
#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
@@ -144,7 +140,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_clear(color_t color) {
+ void GDISP_LLD(clear)(color_t color) {
/* Code here */
}
#endif
@@ -160,7 +156,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_drawline(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
#if GDISP_NEED_VALIDATION
/* Need to clip to screen */
#endif
@@ -179,7 +175,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_fillarea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
#if GDISP_NEED_VALIDATION
if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
if (x+cx > GDISP.Width) cx = GDISP.Width - x;
@@ -200,7 +196,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_blitarea(coord_t x, coord_t y, coord_t cx, coord_t cy, pixel_t *buffer) {
+ void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) {
#if GDISP_NEED_VALIDATION
if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
if (x+cx > GDISP.Width) return;
@@ -224,7 +220,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_drawcircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -245,7 +241,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_fillcircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -266,7 +262,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_drawellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -287,7 +283,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_fillellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -306,7 +302,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_drawchar(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -326,7 +322,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_fillchar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
#if GDISP_NEED_VALIDATION
/* Code here */
#endif
@@ -339,12 +335,13 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { * @brief Get the color of a particular pixel.
* @note Optional.
* @note If x,y is off the screen, the result is undefined.
+ * @return The color of the specified pixel.
*
* @param[in] x, y The start of the text
*
* @notapi
*/
- color_t gdisp_lld_getpixelcolor(coord_t x, coord_t y) {
+ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) {
#if GDISP_NEED_VALIDATION
if (x >= GDISP.Width || y >= GDISP.Height) return 0;
#endif
@@ -366,7 +363,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_verticalscroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
#if GDISP_NEED_VALIDATION
if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
if (x+cx > GDISP.Width) cx = GDISP.Width - x;
@@ -376,7 +373,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { }
#endif
-#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__)
+#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__)
/**
* @brief Driver Control
* @detail Unsupported control codes are ignored.
@@ -396,7 +393,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { *
* @notapi
*/
- void gdisp_lld_control(int what, void *value) {
+ void GDISP_LLD(control)(unsigned what, void *value) {
switch(what) {
case GDISP_CONTROL_POWER:
if (GDISP.Powermode == (gdisp_powermode_t)value)
@@ -409,7 +406,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { /* Code here */
/* You may need this ---
if (GDISP.Powermode != powerSleep)
- gdisp_lld_init();
+ GDISP_LLD(init)();
*/
break;
case powerSleep:
@@ -457,5 +454,37 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) { }
#endif
+#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__)
+/**
+ * @brief Query a driver value.
+ * @detail Typecase the result to the type you want.
+ * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen
+ * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen
+ * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode
+ * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation
+ * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100)
+ * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100).
+ * GDISP_QUERY_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to Query
+ *
+ * @notapi
+ */
+void *GDISP_LLD(query)(unsigned what) {
+ switch(what) {
+ case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width;
+ case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height;
+ case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode;
+ case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation;
+ case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight;
+ case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast;
+ case GDISP_QUERY_LLD+0:
+ /* Code here */
+ default: return (void *)-1;
+ }
+}
+#endif
+
#endif /* HAL_USE_GDISP */
/** @} */
diff --git a/halext/templates/gdispXXXXX/gdisp_lld_config.h b/halext/templates/gdispXXXXX/gdisp_lld_config.h index 0caf3f4c..81a6826f 100644 --- a/halext/templates/gdispXXXXX/gdisp_lld_config.h +++ b/halext/templates/gdispXXXXX/gdisp_lld_config.h @@ -35,6 +35,9 @@ /* Driver hardware support. */
/*===========================================================================*/
+#define GDISP_DRIVER_NAME "YourDriverName"
+#define GDISP_LLD(x) gdisp_lld_##x##_YourDriverName
+
#define GDISP_HARDWARE_LINES FALSE
#define GDISP_HARDWARE_CLEARS FALSE
#define GDISP_HARDWARE_FILLS FALSE
@@ -48,22 +51,15 @@ #define GDISP_HARDWARE_SCROLL FALSE
#define GDISP_HARDWARE_PIXELREAD FALSE
#define GDISP_HARDWARE_CONTROL FALSE
+#define GDISP_HARDWARE_QUERY FALSE
#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
-#define GDISP_PIXELFORMAT_RGB565
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
#define GDISP_PACKED_PIXELS FALSE
#define GDISP_PACKED_LINES FALSE
-/*===========================================================================*/
-/* Extra fields for the GDISPDriver structure */
-/*===========================================================================*/
-
-/*
-#define GDISP_DRIVER_EXT_FIELDS int abc; int def;
-*/
-
#endif /* HAL_USE_GDISP */
#endif /* _GDISP_LLD_CONFIG_H */
|