diff --git a/graphics/pdcurs34/nuttx/pdcdisp.c b/graphics/pdcurs34/nuttx/pdcdisp.c index 115899c07..765bad82d 100644 --- a/graphics/pdcurs34/nuttx/pdcdisp.c +++ b/graphics/pdcurs34/nuttx/pdcdisp.c @@ -637,11 +637,11 @@ void PDC_clear_screen(FAR struct pdc_fbstate_s *fbstate) /* Get the background color and display width */ - bgcolor = PDCURSES_INIT_COLOR; - width = fbstate->xres; + bgcolor = PDCURSES_INIT_COLOR; /* Background color for one pixel */ + width = fbstate->xres; /* Width in units of pixels */ #if PDCURSES_BPP < 8 - /* Pack multiple pixels into one byte */ + /* Pack multiple pixels into one byte. Works for BPP={1,2,4} */ #if PDCURSES_BPP == 1 /* BPP = 1 */ bgcolor &= 1; /* Isolate 0 */ @@ -656,9 +656,10 @@ void PDC_clear_screen(FAR struct pdc_fbstate_s *fbstate) bgcolor &= 15; /* Isolate 0-3 */ bgcolor = bgcolor << 4 | bgcolor; /* Replicate 0-3 to 4-7 */ #endif + /* Convert the width of the display to units of bytes. */ - width /= PDCURSES_PPB; + width = (width + PDCURSES_PPB - 1) / PDCURSES_PPB; #endif /* Write the initial color into the entire framebuffer */ diff --git a/graphics/pdcurs34/nuttx/pdckbd.c b/graphics/pdcurs34/nuttx/pdckbd.c index c27b9e0e6..86a8e58ed 100644 --- a/graphics/pdcurs34/nuttx/pdckbd.c +++ b/graphics/pdcurs34/nuttx/pdckbd.c @@ -399,3 +399,21 @@ int PDC_input_open(FAR struct pdc_fbstate_s *fbstate) return OK; } #endif + +/**************************************************************************** + * Name: PDC_input_close + * + * Description: + * Close any input devices and release any resources committed by + * PDC_input_open() + * + ****************************************************************************/ + +#ifdef CONFIG_PDCURSES_HAVE_INPUT +void PDC_input_close(FAR struct pdc_fbstate_s *fbstate) +{ +#ifdef CONFIG_PDCURSES_DJOYSTICK + close(fbstate->djfd); +#endif +} +#endif diff --git a/graphics/pdcurs34/nuttx/pdcnuttx.h b/graphics/pdcurs34/nuttx/pdcnuttx.h index 403e451b0..07a32d3a4 100644 --- a/graphics/pdcurs34/nuttx/pdcnuttx.h +++ b/graphics/pdcurs34/nuttx/pdcnuttx.h @@ -313,6 +313,19 @@ void PDC_clear_screen(FAR struct pdc_fbstate_s *fbstate); int PDC_input_open(FAR struct pdc_fbstate_s *fbstate); #endif +/**************************************************************************** + * Name: PDC_input_close + * + * Description: + * Close any input devices and release any resources committed by + * PDC_input_open() + * + ****************************************************************************/ + +#ifdef CONFIG_PDCURSES_HAVE_INPUT +void PDC_input_close(FAR struct pdc_fbstate_s *fbstate); +#endif + #undef EXTERN #if defined(__cplusplus) } diff --git a/graphics/pdcurs34/nuttx/pdcscrn.c b/graphics/pdcurs34/nuttx/pdcscrn.c index 103c7b04a..e0ee85a5a 100644 --- a/graphics/pdcurs34/nuttx/pdcscrn.c +++ b/graphics/pdcurs34/nuttx/pdcscrn.c @@ -87,6 +87,9 @@ void PDC_scr_free(void) fbstate = &fbscreen->fbstate; close(fbstate->fbfd); +#ifdef CONFIG_PDCURSES_HAVE_INPUT + PDC_input_close(fbstate); +#endif free(fbscreen); SP = NULL; }