From efcbb38663415c7624c74b94c8f52373a39e0f4e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 27 Nov 2017 06:49:38 -0600 Subject: [PATCH] apps/graphics/pdcurs34: Add some convenience definitions. --- graphics/pdcurs34/nuttx/pdcdisp.c | 12 ++++++------ graphics/pdcurs34/nuttx/pdcnuttx.h | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/graphics/pdcurs34/nuttx/pdcdisp.c b/graphics/pdcurs34/nuttx/pdcdisp.c index 06accfdd4..aedd99622 100644 --- a/graphics/pdcurs34/nuttx/pdcdisp.c +++ b/graphics/pdcurs34/nuttx/pdcdisp.c @@ -239,7 +239,7 @@ static inline void PDC_set_bg(FAR struct pdc_fbstate_s *fbstate, #if PDCURSES_BPP == 1 /* Get the start and end column in pixels (relative to the start position) */ - startcol = col & 7; + startcol = col & PDCURSES_PPB_MASK; endcol = startcol + fbstate->fwidth - 1; /* Get the masks that we will need to perform the read-modify-write @@ -258,12 +258,12 @@ static inline void PDC_set_bg(FAR struct pdc_fbstate_s *fbstate, * the final byte than may have fewer than 8 pixels in it). */ - endcol = (endcol + 7) >> 3; + endcol = (endcol + PDCURSES_PPB_MASK) >> PDCURSES_PPB_SHIFT; #elif PDCURSES_BPP == 2 /* Get the start and end colum in pixels (relative to the start position) */ - startcol = col & 3; + startcol = col & PDCURSES_PPB_MASK; endcol = startcol + fbstate->fwidth - 1; /* Get the masks that we will need to perform the read-modify-write @@ -282,12 +282,12 @@ static inline void PDC_set_bg(FAR struct pdc_fbstate_s *fbstate, * the final byte than may have fewer than 4 pixels in it). */ - endcol = (endcol + 3) >> 2; + endcol = (endcol + PDCURSES_PPB_MASK) >> PDCURSES_PPB_SHIFT; #elif PDCURSES_BPP == 4 /* Get the start and end colum in pixels (relative to the start position) */ - startcol = col & 1; + startcol = col & PDCURSES_PPB_MASK; endcol = startcol + fbstate->fwidth - 1; /* Get the masks that we will need to perform the read-modify-write @@ -306,7 +306,7 @@ static inline void PDC_set_bg(FAR struct pdc_fbstate_s *fbstate, * the final byte than may have only one pixel in it). */ - endcol = (endcol + 1) >> 1; + endcol = (endcol + PDCURSES_PPB_MASK) >> PDCURSES_PPB_SHIFT; #endif /* Now copy the color into the entire glyph region */ diff --git a/graphics/pdcurs34/nuttx/pdcnuttx.h b/graphics/pdcurs34/nuttx/pdcnuttx.h index 07a32d3a4..8eccb562c 100644 --- a/graphics/pdcurs34/nuttx/pdcnuttx.h +++ b/graphics/pdcurs34/nuttx/pdcnuttx.h @@ -113,18 +113,24 @@ # define PDCURSES_COLORFMT FB_FMT_Y1 # define PDCURSES_BPP 1 # define PDCURSES_PPB 8 +# define PDCURSES_PPB_MASK (PDCURSES_PPB - 1) +# define PDCURSES_PPB_SHIFT 3 # define PDCURSES_INIT_COLOR CONFIG_PDCURSES_BGCOLOR_GREYLEVEL # define PDCURSES_MONOCHROME 2 #elif defined(CONFIG_PDCURSES_COLORFMT_Y2) # define PDCURSES_COLORFMT FB_FMT_Y2 # define PDCURSES_BPP 2 # define PDCURSES_PPB 4 +# define PDCURSES_PPB_MASK (PDCURSES_PPB - 1) +# define PDCURSES_PPB_SHIFT 2 # define PDCURSES_INIT_COLOR CONFIG_PDCURSES_BGCOLOR_GREYLEVEL # define PDCURSES_MONOCHROME 1 #elif defined(CONFIG_PDCURSES_COLORFMT_Y4) # define PDCURSES_COLORFMT FB_FMT_Y4 # define PDCURSES_BPP 4 # define PDCURSES_PPB 2 +# define PDCURSES_PPB_MASK (PDCURSES_PPB - 1) +# define PDCURSES_PPB_SHIFT 1 # define PDCURSES_INIT_COLOR CONFIG_PDCURSES_BGCOLOR_GREYLEVEL # define PDCURSES_MONOCHROME 1 #elif defined(CONFIG_PDCURSES_COLORFMT_RGB332)