aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-11-09 19:17:22 +1000
committerinmarket <andrewh@inmarket.com.au>2013-11-09 19:17:22 +1000
commitdaa4e8bbd78ebe4a84234de266006d1a23697657 (patch)
treed6cfb8843a3f9683b027460b1e6f33e1f56d3f5b
parent53408e2cb3d0705f261e9756bcf6f3f6c90c3fe9 (diff)
downloaduGFX-daa4e8bbd78ebe4a84234de266006d1a23697657.tar.gz
uGFX-daa4e8bbd78ebe4a84234de266006d1a23697657.tar.bz2
uGFX-daa4e8bbd78ebe4a84234de266006d1a23697657.zip
Add support for a portrait and landscape orientation modes.
-rw-r--r--include/gdisp/gdisp.h4
-rw-r--r--src/gdisp/gdisp.c10
2 files changed, 13 insertions, 1 deletions
diff --git a/include/gdisp/gdisp.h b/include/gdisp/gdisp.h
index 3d617e50..51415805 100644
--- a/include/gdisp/gdisp.h
+++ b/include/gdisp/gdisp.h
@@ -62,8 +62,10 @@ typedef enum fontmetric { fontHeight, fontDescendersHeight, fontLineSpacing, fon
typedef const struct mf_font_s* font_t;
/**
* @brief Type for the screen orientation.
+ * @note GDISP_ROTATE_LANDSCAPE and GDISP_ROTATE_PORTRAIT are internally converted to the
+ * most appropriate other orientation.
*/
-typedef enum orientation { GDISP_ROTATE_0=0, GDISP_ROTATE_90=90, GDISP_ROTATE_180=180, GDISP_ROTATE_270=270 } orientation_t;
+typedef enum orientation { GDISP_ROTATE_0=0, GDISP_ROTATE_90=90, GDISP_ROTATE_180=180, GDISP_ROTATE_270=270, GDISP_ROTATE_PORTRAIT=1000, GDISP_ROTATE_LANDSCAPE=1001 } orientation_t;
/**
* @brief Type for the available power modes for the screen.
*/
diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c
index b08fe627..7eade99c 100644
--- a/src/gdisp/gdisp.c
+++ b/src/gdisp/gdisp.c
@@ -2367,6 +2367,16 @@ void gdispGBlitArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, c
MUTEX_ENTER(g);
g->p.x = what;
g->p.ptr = value;
+ if (what == GDISP_CONTROL_ORIENTATION) {
+ switch ((orientation_t) value) {
+ case GDISP_ROTATE_LANDSCAPE:
+ g->p.ptr = g->g.Width >= g->g.Height ? GDISP_ROTATE_0 : GDISP_ROTATE_90;
+ break;
+ case GDISP_ROTATE_PORTRAIT:
+ g->p.ptr = g->g.Width >= g->g.Height ? GDISP_ROTATE_90 : GDISP_ROTATE_0;
+ break;
+ }
+ }
gdisp_lld_control(g);
#if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION
if (what == GDISP_CONTROL_ORIENTATION) {