aboutsummaryrefslogtreecommitdiffstats
path: root/halext/drivers/gdispSsd1289/gdisp_lld.c
diff options
context:
space:
mode:
Diffstat (limited to 'halext/drivers/gdispSsd1289/gdisp_lld.c')
-rw-r--r--halext/drivers/gdispSsd1289/gdisp_lld.c89
1 files changed, 57 insertions, 32 deletions
diff --git a/halext/drivers/gdispSsd1289/gdisp_lld.c b/halext/drivers/gdispSsd1289/gdisp_lld.c
index f5c94bf1..7dfb83a7 100644
--- a/halext/drivers/gdispSsd1289/gdisp_lld.c
+++ b/halext/drivers/gdispSsd1289/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. */
/*===========================================================================*/
@@ -82,7 +72,7 @@
*
* @notapi
*/
-void gdisp_lld_init(void) {
+bool_t GDISP_LLD(init)(void) {
uint16_t deviceCode;
#ifdef LCD_USE_FSMC
@@ -153,6 +143,9 @@ void gdisp_lld_init(void) {
GDISP.Height = SCREEN_HEIGHT;
GDISP.Orientation = portrait;
GDISP.Powermode = powerOn;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
}
/**
@@ -164,7 +157,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
@@ -182,11 +175,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 gfillarea() 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__)
@@ -198,7 +191,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) {
unsigned i;
lld_lcdSetCursor(0, 0);
@@ -222,7 +215,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) {
/* NOT IMPLEMENTED */
}
#endif
@@ -238,7 +231,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;
@@ -268,7 +261,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) {
unsigned i, area;
#if GDISP_NEED_VALIDATION
@@ -301,7 +294,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) {
/* NOT IMPLEMENTED */
}
#endif
@@ -319,7 +312,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) {
/* NOT IMPLEMENTED */
}
#endif
@@ -337,7 +330,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) {
/* NOT IMPLEMENTED */
}
#endif
@@ -355,7 +348,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) {
/* NOT IMPLEMENTED */
}
#endif
@@ -375,7 +368,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) {
/* NOT IMPLEMENTED */
}
#endif
@@ -392,7 +385,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) {
/* NOT IMPLEMENTED */
}
#endif
@@ -407,7 +400,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
*
* @notapi
*/
- color_t gdisp_lld_getpixelcolor(coord_t x, coord_t y) {
+ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) {
color_t color;
#if GDISP_NEED_VALIDATION
@@ -440,7 +433,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) {
static color_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)];
coord_t row0, row1;
unsigned i, gap, abslines;
@@ -511,7 +504,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)
@@ -526,7 +519,7 @@ void gdisp_lld_drawpixel(coord_t x, coord_t y, color_t color) {
case powerOn:
lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode
if (GDISP.Powermode != powerSleep)
- gdisp_lld_init();
+ GDISP_LLD(init)();
break;
case powerSleep:
lld_lcdWriteReg(0x0010, 0x0001); // enter sleep mode
@@ -581,5 +574,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 */
/** @} */