aboutsummaryrefslogtreecommitdiffstats
path: root/halext/include/glcd.h
diff options
context:
space:
mode:
Diffstat (limited to 'halext/include/glcd.h')
-rw-r--r--halext/include/glcd.h61
1 files changed, 46 insertions, 15 deletions
diff --git a/halext/include/glcd.h b/halext/include/glcd.h
index 54c5158d..670d160e 100644
--- a/halext/include/glcd.h
+++ b/halext/include/glcd.h
@@ -24,6 +24,8 @@
some code changes may be necessary.
Note it does not replicate the GLCD low level driver, just
the high level interface.
+ You may also need to define the various GDISP_NEED_XXX in your
+ halconf.h in order to turn on the functionality you need.
*/
#ifndef GLCD_H
@@ -38,10 +40,8 @@
#define RGB565CONVERT(r, g, b) RGB2COLOR(r,g,b)
-enum orientation {portrait, landscape, portraitInv, landscapeInv};
enum filled {frame, filled};
enum transparency {solid, transparent};
-enum powermode {powerOff, powerOn, sleepOn, sleepOff};
#define sleepOn powerSleep
#define sleepOff powerOn
@@ -70,14 +70,33 @@ typedef enum glcd_result glcd_result_t;
/* Core functions */
#define lcdInit(dvr) gdispInit(dvr)
-#define lcdClear(color) (gdispClear(color), GLCD_DONE)
-#define lcdSetOrientation(newO) (gdispControl(GDISP_CONTROL_ORIENTATION, (void *)(int)newO), (GDISP1.Orientation == (newO) ? GLCD_DONE : GLCD_FAILED))
-#define lcdFillArea(x0,y0,x1,y1,c) (gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c)), GLCD_DONE)
-#define lcdWriteArea(x0,y0,x1,y1,b,n) (gdispBlitArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(b)), GLCD_DONE)
-#define lcdSetPowerMode(pm) (gdispControl(GDISP_CONTROL_POWER, (void *)(int)pm), (GDISP1.Powermode == (pm) ? GLCD_DONE : GLCD_FAILED))
+static __inline glcd_result_t lcdClear(color_t color) {
+ gdispClear(color);
+ return GLCD_DONE;
+}
+static __inline glcd_result_t lcdSetOrientation(enum orientation newO) {
+ gdispControl(GDISP_CONTROL_ORIENTATION, (void *)(int)newO);
+ return ((enum orientation)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION)) == (newO) ? GLCD_DONE : GLCD_FAILED;
+}
+static __inline glcd_result_t lcdFillArea(coord_t x0, coord_t y0, coord_t x1, coord_t y1,color_t c) {
+ gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c));
+ return GLCD_DONE;
+}
+static __inline glcd_result_t lcdWriteArea(coord_t x0, coord_t y0, coord_t x1, coord_t y1, const pixel_t *b, coord_t n) {
+ (void)n;
+ gdispBlitArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(b));
+ return GLCD_DONE;
+}
+static __inline glcd_result_t lcdSetPowerMode(enum powermode pm) {
+ gdispControl(GDISP_CONTROL_POWER, (void *)(int)pm);
+ return ((enum powermode)(unsigned)gdispQuery(GDISP_QUERY_POWER)) == (pm) ? GLCD_DONE : GLCD_FAILED;
+}
/* Drawing functions */
-#define lcdDrawPixel(x,y,c) (gdispDrawPixel((x),(y),(c)), GLCD_DONE)
+static __inline glcd_result_t lcdDrawPixel(coord_t x, coord_t y, color_t c) {
+ gdispDrawPixel((x),(y),(c));
+ return GLCD_DONE;
+}
#define lcdDrawLine(x0,y0,x1,y1,c) gdispDrawLine((x0),(y0),(x1),(y1),(c))
#define lcdDrawRect(x0,y0,x1,y1,f,c) {if(f) gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c)); else gdispDrawBox((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c));}
#define lcdDrawRectString(x0,y0,x1,y1,s,f,c,b) gdispFillStringBox((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(s),(f),(c),(b),justifyLeft)
@@ -85,18 +104,30 @@ typedef enum glcd_result glcd_result_t;
#define lcdDrawEllipse(x,y,a,b,f,c) {if(f) gdispFillEllipse((x),(y),(a),(b),(c)); else gdispDrawEllipse((x),(y),(a),(b),(c));}
/* Text Rendering Functions */
-#define lcdDrawChar(x,y,h,f,c,b,t) ({if(t) gdispDrawChar((x),(y),(h),(f),(c)); else gdispFillChar((x),(y),(h),(f),(c),(b));}, (gdispGetCharWidth((h),(f))+(f)->charPadding))
-#define lcdDrawString(x,y,s,f,c,b,t) ({if(t) gdispDrawString((x),(y),(s),(f),(c)); else gdispFillString((x),(y),(s),(f),(c),(b));}, (gdispGetStringWidth((s),(f))+(f)->charPadding))
+static __inline coord_t lcdDrawChar(coord_t x, coord_t y, char h, font_t f, color_t c, color_t b, bool_t t) {
+ if (t)
+ gdispDrawChar((x),(y),(h),(f),(c));
+ else
+ gdispFillChar((x),(y),(h),(f),(c),(b));
+ return gdispGetCharWidth((h),(f))+gdispGetFontMetric((f), fontCharPadding);
+}
+static __inline coord_t lcdDrawString(coord_t x, coord_t y, const char *s, font_t f, color_t c, color_t b, bool_t t) {
+ if (t)
+ gdispDrawString((x),(y),(s),(f),(c));
+ else
+ gdispFillString((x),(y),(s),(f),(c),(b));
+ return gdispGetStringWidth((s),(f))+gdispGetFontMetric((f), fontCharPadding);
+}
/* Character measuring functions */
-#define lcdMeasureChar(h,f) (gdispGetCharWidth((h),(f))+(f)->charPadding)
-#define lcdMeasureString(s,f) (gdispGetStringWidth((s),(f))+(f)->charPadding)
+#define lcdMeasureChar(h,f) (gdispGetCharWidth((h),(f))+gdispGetFontMetric((f), fontCharPadding))
+#define lcdMeasureString(s,f) (gdispGetStringWidth((s),(f))+gdispGetFontMetric((f), fontCharPadding))
#define lcdGetFontHeight(f) gdispGetFontMetric((f), fontHeight)
/* Size and orientation related */
-#define lcdGetHeight() (GDISP.Height)
-#define lcdGetWidth() (GDISP.Width)
-#define lcdGetOrientation() (GDISP.Orientation)
+#define lcdGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT))
+#define lcdGetWidth() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_WIDTH))
+#define lcdGetOrientation() ((enum orientation)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION))
/* BGR->RGB and pixel readback */
#define lcdBGR2RGB(c) RGB2COLOR(BLUE_OF(c),GREEN_OF(c),RED_OF(c))