From daa4e8bbd78ebe4a84234de266006d1a23697657 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sat, 9 Nov 2013 19:17:22 +1000 Subject: [PATCH] Add support for a portrait and landscape orientation modes. --- include/gdisp/gdisp.h | 4 +++- src/gdisp/gdisp.c | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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) {