diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-04-23 03:29:51 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-04-23 03:29:51 +0000 |
commit | c44875bf6618c6785ef58a734f47155ece14a30f (patch) | |
tree | fee9ac9d15177db27956eda28e54d36e7cd90f34 | |
parent | 72c0c33d10e26f4ac9026c66cd3cf69478a31bc9 (diff) | |
download | nuttx-c44875bf6618c6785ef58a734f47155ece14a30f.tar.gz nuttx-c44875bf6618c6785ef58a734f47155ece14a30f.tar.bz2 nuttx-c44875bf6618c6785ef58a734f47155ece14a30f.zip |
More NX LCD fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2624 42af7a65-404d-4744-a932-0658087f49c3
-rwxr-xr-x | nuttx/configs/sam3u-ek/nx/defconfig | 4 | ||||
-rwxr-xr-x | nuttx/configs/sam3u-ek/src/up_lcd.c | 109 | ||||
-rw-r--r-- | nuttx/examples/nx/nx_kbdin.c | 1 | ||||
-rw-r--r-- | nuttx/examples/nx/nx_main.c | 6 | ||||
-rwxr-xr-x | nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c | 4 | ||||
-rw-r--r-- | nuttx/graphics/nxtk/nxtk_events.c | 8 |
6 files changed, 100 insertions, 32 deletions
diff --git a/nuttx/configs/sam3u-ek/nx/defconfig b/nuttx/configs/sam3u-ek/nx/defconfig index f4f7e86ee..7c944798b 100755 --- a/nuttx/configs/sam3u-ek/nx/defconfig +++ b/nuttx/configs/sam3u-ek/nx/defconfig @@ -715,8 +715,8 @@ CONFIG_NX_PACKEDMSFIRST=n CONFIG_NX_LCDDRIVER=y CONFIG_LCD_MAXPOWER=31 CONFIG_LCD_MAXCONTRAST=1 -CONFIG_NX_MOUSE=n -CONFIG_NX_KBD=n +CONFIG_NX_MOUSE=y +CONFIG_NX_KBD=y #CONFIG_NXTK_BORDERWIDTH=4 #CONFIG_NXTK_BORDERCOLOR1 #CONFIG_NXTK_BORDERCOLOR2 diff --git a/nuttx/configs/sam3u-ek/src/up_lcd.c b/nuttx/configs/sam3u-ek/src/up_lcd.c index 61f77ade7..971d8d885 100755 --- a/nuttx/configs/sam3u-ek/src/up_lcd.c +++ b/nuttx/configs/sam3u-ek/src/up_lcd.c @@ -167,10 +167,19 @@ /* Graphics Capbilities ***************************************************************/ -/* LCD resolution: 240 (rows) x 320 (columns) */ +/* LCD resolution: 320 (columns) by 240 (rows). The physical dimensions of the device + * are really 240 (columns) by 320 (rows), but unless CONFIG_SAM3U_240x320 is defined, + * we swap rows and columns in setcursor to make things behave nicer (there IS a + * performance hit for this swap!). + */ -#define SAM3UEK_XRES 320 -#define SAM3UEK_YRES 240 +#ifdef CONFIG_SAM3U_240x320 +# define SAM3UEK_XRES 240 +# define SAM3UEK_YRES 320 +#else +# define SAM3UEK_XRES 320 +# define SAM3UEK_YRES 240 +#endif /* Color depth and format. BPP=16 R=6, G=6, B=5: RRRR RBBB BBBG GGGG */ @@ -301,7 +310,7 @@ static uint16_t sam3u_getreg(uint16_t reg); /* Misc. LCD Helper Functions */ -static void sam3u_setcursor(fb_coord_t x, fb_coord_t y); +static void sam3u_setcursor(fb_coord_t row, fb_coord_t col); static inline void sam3u_wrsetup(void); static inline void sam3u_wrram(uint16_t color); static inline uint16_t sam3u_rdram(void); @@ -451,17 +460,22 @@ static uint16_t sam3u_getreg(uint16_t reg) * **************************************************************************************/ -static void sam3u_setcursor(fb_coord_t x, fb_coord_t y) +static void sam3u_setcursor(fb_coord_t row, fb_coord_t col) { - uint8_t x1; - uint8_t x2; - uint8_t y1; - uint8_t y2; + uint8_t x1; + uint8_t x2; + uint8_t y1; + uint8_t y2; + + /* Get the upper and lower x and y positions */ - x1 = (uint8_t) x & 0xff; - x2 = ((uint16_t)x & 0xff00) >> 8; - y1 = (uint8_t) y & 0xff; - y2 = ((uint16_t)y & 0xff00) >> 8; + x1 = (uint8_t)col; + x2 = (uint8_t)((uint16_t)col >> 8); + + y1 = (uint8_t)row; + y2 = (uint8_t)((uint16_t)row >> 8); + + /* Then set the cursor position */ sam3u_putreg(HX8347_R02H, x2); /* column high */ sam3u_putreg(HX8347_R03H, x1); /* column low */ @@ -592,19 +606,44 @@ static int sam3u_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffe gvdbg("row: %d col: %d npixels: %d\n", row, col, npixels); DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0); - /* Write the run to GRAM */ +#ifdef CONFIG_SAM3U_240x320 + /* Set up to write the run. */ + + sam3u_setcursor(row, col); + sam3u_wrsetup(); + + /* Write the run to GRAM. */ for (i = 0; i < npixels; i++) { - /* Set up for the write */ + /* Write the pixel pixel to GRAM */ - sam3u_setcursor(row, col++); + sam3u_wrram(*run++); + } +#else + /* Write the run to GRAM. Because rows and colums are swapped, we need to reset + * the cursor position for every pixel. We could do this much faster if we + * adapted to the strange device aspect ratio. + */ + + col = 319-col; + for (i = 0; i < npixels; i++) + { + /* Set up to write the next pixel. Swapping x and y orientations so that the image + * comes out with the 320x240 aspect ratio (not the native 240x320). That is: + * + * row: 0-239 maps to x: 0-239 + * col: 0-319 maps to y: 319-0 + */ + + sam3u_setcursor(col--, row); sam3u_wrsetup(); - /* Write the pixel to GRAM */ + /* Write the pixel pixel to GRAM */ sam3u_wrram(*run++); } +#endif return OK; } @@ -633,16 +672,39 @@ static int sam3u_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, gvdbg("row: %d col: %d npixels: %d\n", row, col, npixels); DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0); - /* Set up for the read */ +#ifdef CONFIG_SAM3U_240x320 + /* Set up to read the run */ sam3u_setcursor(row, col); - /* Read the run from GRAM */ + /* Read the run from GRAM. */ for (i = 0; i < npixels; i++) { - sam3u_wrram(*run++); + /* Read the next pixel */ + + *run++ = sam3u_rdram(); + } +#else + /* Read the run from GRAM Because rows and colums are swapped, we need to reset + * the cursor position for every pixel. We could do this much faster if we + * adapted to the strange device aspect ratio. + */ + + col = 319 - col; + for (i = 0; i < npixels; i++) + { + /* Read the next pixel.. Swapping x and y orientations so that the image + * comes out with the 320x240 aspect ratio (not the native 240x320). That is: + * + * row: 0-239 maps to x: 0-239 + * col: 0-319 maps to y: 319-0 + */ + + sam3u_setcursor(col--, row); + *run++ = sam3u_rdram(); } +#endif return OK; } @@ -741,6 +803,13 @@ static int sam3u_setpower(struct lcd_dev_s *dev, int power) sam3u_gpiowrite(GPIO_LCD_BKL, true);; } + /* This delay seems to be required... perhaps because of the big current jump? */ + + if (power != LCD_FULL_OFF) + { + up_mdelay(100); + } + priv->power = power; return OK; } diff --git a/nuttx/examples/nx/nx_kbdin.c b/nuttx/examples/nx/nx_kbdin.c index e1cc9cd2e..5b08cabbe 100644 --- a/nuttx/examples/nx/nx_kbdin.c +++ b/nuttx/examples/nx/nx_kbdin.c @@ -41,6 +41,7 @@ #include <stdint.h> #include <stdlib.h> +#include <stdio.h> #include <string.h> #include <ctype.h> #include <debug.h> diff --git a/nuttx/examples/nx/nx_main.c b/nuttx/examples/nx/nx_main.c index b63429a0f..4f5fe8cd4 100644 --- a/nuttx/examples/nx/nx_main.c +++ b/nuttx/examples/nx/nx_main.c @@ -443,7 +443,7 @@ static inline int nxeg_suinitialize(void) /* Turn the LCD on at 75% power */ - (void)dev->setpower(dev, (3*CONFIG_LCD_MAXPOWER/4)); + (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4)); #else /* Initialize the frame buffer device */ @@ -715,8 +715,8 @@ int user_start(int argc, char *argv[]) message("user_start: Create window #2\n"); nxeg_initstate(&g_wstate[1], 2, CONFIG_EXAMPLES_NX_COLOR2); hwnd2 = nxeg_openwindow(&g_nxcb, &g_wstate[1]); - message("user_start: hwnd1=%p\n", hwnd1); - if (!hwnd1) + message("user_start: hwnd2=%p\n", hwnd2); + if (!hwnd2) { goto errout_with_hwnd1; } diff --git a/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c b/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c index e3668c0ea..50ef7efbe 100755 --- a/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c +++ b/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c @@ -88,13 +88,11 @@ void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX) (FAR struct lcd_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color) { unsigned int ncols; - unsigned int nrows; unsigned int row; /* Get the dimensions of the rectange to fill in pixels */ ncols = rect->pt2.x - rect->pt1.x + 1; - nrows = rect->pt2.y - rect->pt1.y + 1; /* Fill the run buffer with the selected color */ @@ -102,7 +100,7 @@ void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX) /* Then fill the rectangle line-by-line */ - for (row = 0; row < nrows; row++) + for (row = rect->pt1.y; row <= rect->pt2.y; row++) { /* Draw the raster line at this row */ diff --git a/nuttx/graphics/nxtk/nxtk_events.c b/nuttx/graphics/nxtk/nxtk_events.c index 45ab1e8a5..cbcbabe4b 100644 --- a/nuttx/graphics/nxtk/nxtk_events.c +++ b/nuttx/graphics/nxtk/nxtk_events.c @@ -113,7 +113,7 @@ static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, DEBUGASSERT(hwnd && rect && fwnd->fwcb); - gvdbg("nxtk_redraw: hwnd=%p rect={(%d,%d),(%d,%d)} more=%d\n", + gvdbg("hwnd=%p rect={(%d,%d),(%d,%d)} more=%d\n", hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, more); /* The incoming rectangle (rect) is relative to the containing window @@ -131,7 +131,7 @@ static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, nxtk_containerclip(fwnd, &intersection, rect, &fwnd->fwrect); - gvdbg("nxtk_redraw: fwrect intersction={(%d,%d),(%d,%d)}\n", + gvdbg("fwrect intersction={(%d,%d),(%d,%d)}\n", intersection.pt1.x, intersection.pt1.y, intersection.pt2.x, intersection.pt2.y); @@ -154,7 +154,7 @@ static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, nxtk_containerclip(fwnd, &intersection, rect, &fwnd->tbrect); - gvdbg("nxtk_redraw: tbrect intersction={(%d,%d),(%d,%d)}\n", + gvdbg("tbrect intersction={(%d,%d),(%d,%d)}\n", intersection.pt1.x, intersection.pt1.y, intersection.pt2.x, intersection.pt2.y); @@ -181,7 +181,7 @@ static void nxtk_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; struct nxgl_size_s subwindowsize; - gvdbg("nxtk_position: hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n", + gvdbg("hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n", hwnd, size->w, size->h, pos->x, pos->y, bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y); |