From fcb3f0be7cf755c09970aef69d46c183779dc6f7 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 10 Jul 2011 22:35:35 +0000 Subject: Fix more NXTEXT bugs -- seems to be working now git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3768 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/README.txt | 12 ++- apps/examples/nxtext/nxtext_bkgd.c | 126 +++++++++++++++++++++------ apps/examples/nxtext/nxtext_internal.h | 6 +- apps/examples/nxtext/nxtext_main.c | 51 +++++------ apps/examples/nxtext/nxtext_putc.c | 2 +- nuttx/configs/stm3210e-eval/nxtext/defconfig | 4 + nuttx/configs/stm3210e-eval/src/up_lcd.c | 40 +++++++-- 7 files changed, 175 insertions(+), 66 deletions(-) diff --git a/apps/examples/README.txt b/apps/examples/README.txt index d3306f3a9..07d92a76d 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -314,10 +314,11 @@ examples/nxtest The text display will continue to update while the pop-up is visible. NOTE: This example will *only* work with FB drivers and with LCD - drivers that support reading the contents of the internal LCD memory. - If you notice garbage on the display or a failure at the point where - the display should scroll, it is probably because you have an LCD - driver that is write-only. + drivers that support reading the contents of the internal LCD memory + *unless* you define CONFIG_EXAMPLES_NXTEXT_NOGETRUN. If you notice + garbage on the display or a failure at the point where the display + should scroll, it is probably because you have an LCD driver that is + write-only. The following configuration options can be selected: @@ -335,6 +336,9 @@ examples/nxtest background window. Default depends on CONFIG_EXAMPLES_NXTEXT_BPP. CONFIG_EXAMPLES_NXTEXT_BPP -- Pixels per pixel to use. Valid options include 2, 4, 8, 16, 24, and 32. Default is 32. + CONFIG_EXAMPLES_NXTEXT_NOGETRUN -- If your display is read-only OR if + reading is not reliable, then select this configuration to avoid + reading from the display. CONFIG_EXAMPLES_NXTEXT_EXTERNINIT - The driver for the graphics device on this platform requires some unusual initialization. This is the for, for example, SPI LCD/OLED devices. If this configuration is diff --git a/apps/examples/nxtext/nxtext_bkgd.c b/apps/examples/nxtext/nxtext_bkgd.c index ca8451a92..d75dfae04 100644 --- a/apps/examples/nxtext/nxtext_bkgd.c +++ b/apps/examples/nxtext/nxtext_bkgd.c @@ -197,14 +197,110 @@ static void nxbg_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, #endif /**************************************************************************** - * Name: nxbg_scroll + * Name: nxbg_movedisplay + * + * Description: + * This function implements the data movement for the scroll operation. If + * we can read the displays framebuffer memory, then the job is pretty + * easy. However, many displays (such as SPI-based LCDs) are often read- + * only. ****************************************************************************/ -static inline void nxbg_scroll(NXWINDOW hwnd, int lineheight) +#ifdef CONFIG_EXAMPLES_NXTEXT_NOGETRUN +static inline void nxbg_movedisplay(NXWINDOW hwnd, int bottom, int lineheight) +{ + FAR struct nxtext_bitmap_s *bm; + struct nxgl_rect_s rect; + nxgl_coord_t row; + int ret; + int i; + + /* Move each row, one at a time. They could all be moved at once (by calling + * nxbg_redrawrect), but the since the region is cleared, then re-written, the + * effect would not be good. Below the region is also cleared and re-written, + * however, in much smaller chunks. + */ + + rect.pt1.x = 0; + rect.pt2.x = g_bgstate.wsize.w - 1; + + for (row = LINE_SEPARATION; row < bottom; row += lineheight) + { + /* Create a bounding box the size of one row of characters */ + + rect.pt1.y = row; + rect.pt2.y = row + lineheight - 1; + + /* Clear the region */ + + ret = nx_fill(hwnd, &rect, g_bgstate.wcolor); + if (ret < 0) + { + message("nxbg_movedisplay: nx_fill failed: %d\n", errno); + } + + /* Fill each character that might lie within in the bounding box */ + + for (i = 0; i < g_bgstate.nchars; i++) + { + bm = &g_bgstate.bm[i]; + if (bm->pos.y <= rect.pt2.y && bm->pos.y + g_bgstate.fheight >= rect.pt1.y) + { + nxtext_fillchar(hwnd, &rect, &g_bgstate, bm); + } + } + } + + /* Finally, clear the bottom part of the display */ + + rect.pt1.y = bottom; + rect.pt2.y = g_bgstate.wsize.h- 1; + + ret = nx_fill(hwnd, &rect, g_bgstate.wcolor); + if (ret < 0) + { + message("nxbg_movedisplay: nx_fill failed: %d\n", errno); + } +} +#else +static inline void nxbg_movedisplay(NXWINDOW hwnd, int bottom, int lineheight) { struct nxgl_rect_s rect; struct nxgl_point_s offset; int ret; + + /* Move the display in the range of 0-height up one lineheight. The + * line at the bottom will be reset to the background color automatically. + * + * The source rectangle to be moved. + */ + + rect.pt1.x = 0; + rect.pt1.y = lineheight + LINE_SEPARATION; + rect.pt2.x = g_bgstate.wsize.w - 1; + rect.pt2.y = g_bgstate.wsize.h - 1; + + /* The offset that determines how far to move the source rectangle */ + + offset.x = 0; + offset.y = -lineheight; + + /* Move the source rectangle */ + + ret = nx_move(hwnd, &rect, &offset); + if (ret < 0) + { + message("nxbg_redrawrect: nx_move failed: %d\n", errno); + } +} +#endif + +/**************************************************************************** + * Name: nxbg_scroll + ****************************************************************************/ + +static inline void nxbg_scroll(NXWINDOW hwnd, int lineheight) +{ int i; int j; @@ -216,7 +312,7 @@ static inline void nxbg_scroll(NXWINDOW hwnd, int lineheight) /* Has any part of this character scrolled off the screen? */ - if (bm->pos.y < lineheight) + if (bm->pos.y < lineheight + LINE_SEPARATION) { /* Yes... Delete the character by moving all of the data */ @@ -250,29 +346,9 @@ static inline void nxbg_scroll(NXWINDOW hwnd, int lineheight) g_bgstate.fpos.y -= lineheight; - /* Move the display in the range of 0-height up one lineheight. The - * line at the bottom will be reset to the background color automatically. - * - * The source rectangle to be moved. - */ - - rect.pt1.x = 0; - rect.pt1.y = lineheight; - rect.pt2.x = g_bgstate.wsize.w - 1; - rect.pt2.y = g_bgstate.wsize.h - 1; - - /* The offset that determines how far to move the source rectangle */ + /* Move the display in the range of 0-height up one lineheight. */ - offset.x = 0; - offset.y = -lineheight; - - /* Move the source rectangle */ - - ret = nx_move(hwnd, &rect, &offset); - if (ret < 0) - { - message("nxbg_redrawrect: nx_move failed: %d\n", errno); - } + nxbg_movedisplay(hwnd, g_bgstate.fpos.y, lineheight); } /**************************************************************************** diff --git a/apps/examples/nxtext/nxtext_internal.h b/apps/examples/nxtext/nxtext_internal.h index af0cd0310..3bcbb1aa1 100644 --- a/apps/examples/nxtext/nxtext_internal.h +++ b/apps/examples/nxtext/nxtext_internal.h @@ -242,9 +242,9 @@ struct nxtext_state_s /* These describe all text already added to the display */ - uint16_t maxchars; /* Size of the mb array */ - uint8_t maxglyphs; /* Size of the glyph array */ - uint8_t nchars; /* Number of chars already displayed */ + uint8_t maxglyphs; /* Size of the glyph[] array */ + uint16_t maxchars; /* Size of the bm[] array */ + uint16_t nchars; /* Number of chars in the bm[] array */ FAR struct nxtext_bitmap_s *bm; /* List of characters on the display */ FAR struct nxtext_glyph_s *glyph; /* Cache of rendered fonts in use */ diff --git a/apps/examples/nxtext/nxtext_main.c b/apps/examples/nxtext/nxtext_main.c index 9f8f674a5..a3027165d 100644 --- a/apps/examples/nxtext/nxtext_main.c +++ b/apps/examples/nxtext/nxtext_main.c @@ -99,30 +99,30 @@ static const uint8_t g_pumsg[] = "Pop-Up!"; static const char *g_bgmsg[BGMSG_LINES] = { - "\nJULIET\n", - "Wilt thou be gone?\n", - " It is not yet near day:\n", - "It was the nightingale,\n", - " and not the lark,\n", - "That pierced the fearful hollow\n", - " of thine ear;\n", - "Nightly she sings\n", - " on yon pomegranate-tree:\n", - "Believe me, love,\n", - " it was the nightingale.\n", - "\nROMEO\n", - "It was the lark,\n", - " the herald of the morn,\n", - "No nightingale:\n", - " look, love, what envious streaks\n", - "Do lace the severing clouds\n", - " in yonder east:\n", - "Night's candles are burnt out,\n", - " and jocund day\n", - "Stands tiptoe\n", - " on the misty mountain tops.\n", - "I must be gone and live,\n", - " or stay and die.\n" + "\nJULIET\n", /* Line 1 */ + "Wilt thou be gone?\n", /* Line 2 */ + " It is not yet near day:\n", /* Line 3 */ + "It was the nightingale,\n", /* Line 4 */ + " and not the lark,\n", /* Line 5 */ + "That pierced the fearful hollow\n", /* Line 6 */ + " of thine ear;\n", /* Line 7 */ + "Nightly she sings\n", /* Line 8 */ + " on yon pomegranate-tree:\n", /* Line 9 */ + "Believe me, love,\n", /* Line 10 */ + " it was the nightingale.\n", /* Line 11 */ + "\nROMEO\n", /* Line 12 */ + "It was the lark,\n", /* Line 13 */ + " the herald of the morn,\n", /* Line 14 */ + "No nightingale:\n", /* Line 15 */ + " look, love, what envious streaks\n", /* Line 16 */ + "Do lace the severing clouds\n", /* Line 17 */ + " in yonder east:\n", /* Line 18 */ + "Night's candles are burnt out,\n", /* Line 19 */ + " and jocund day\n", /* Line 20 */ + "Stands tiptoe\n", /* Line 21 */ + " on the misty mountain tops.\n", /* Line 22 */ + "I must be gone and live,\n", /* Line 23 */ + " or stay and die.\n" /* Line 24 */ }; #endif @@ -440,7 +440,8 @@ int user_start(int argc, char *argv[]) } /* Give another line of text to the background window. Force this - * text to go the background by calling the kbdin method directly. + * text to go the background by calling the background window interfaces + * directly. */ nxbg_write(g_bgwnd, (FAR const uint8_t *)g_bgmsg[bkgndx], strlen(g_bgmsg[bkgndx])); diff --git a/apps/examples/nxtext/nxtext_putc.c b/apps/examples/nxtext/nxtext_putc.c index 81fe3aae2..b9c9417a8 100644 --- a/apps/examples/nxtext/nxtext_putc.c +++ b/apps/examples/nxtext/nxtext_putc.c @@ -572,7 +572,7 @@ void nxtext_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, if (!nxgl_nullrect(&intersection)) { - FAR const void *src = (FAR const void *)glyph->bitmap; + FAR const void *src; /* Find (or create) the glyph that goes with this font */ diff --git a/nuttx/configs/stm3210e-eval/nxtext/defconfig b/nuttx/configs/stm3210e-eval/nxtext/defconfig index c82856953..bc36b9731 100644 --- a/nuttx/configs/stm3210e-eval/nxtext/defconfig +++ b/nuttx/configs/stm3210e-eval/nxtext/defconfig @@ -962,6 +962,9 @@ CONFIG_EXAMPLES_NX_EXTERNINIT=n # background window. Default depends on CONFIG_EXAMPLES_NXTEXT_BPP. # CONFIG_EXAMPLES_NXTEXT_BPP -- Pixels per pixel to use. Valid options # include 2, 4, 8, 16, 24, and 32. Default is 32. +# CONFIG_EXAMPLES_NXTEXT_NOGETRUN -- If your display is read-only OR if +# reading is not reliable, then select this configuration to avoid +# reading from the display. # CONFIG_EXAMPLES_NXTEXT_EXTERNINIT - The driver for the graphics device on # this platform requires some unusual initialization. This is the # for, for example, SPI LCD/OLED devices. @@ -985,6 +988,7 @@ CONFIG_EXAMPLES_NXTEXT_BGFONTCOLOR=0xffdf CONFIG_EXAMPLES_NXTEXT_PUCOLOR=0xfd20 CONFIG_EXAMPLES_NXTEXT_PUFONTCOLOR=0x001f CONFIG_EXAMPLES_NXTEXT_BPP=16 +CONFIG_EXAMPLES_NXTEXT_NOGETRUN=y CONFIG_EXAMPLES_NXTEXT_EXTERNINIT=n CONFIG_EXAMPLES_NXTEXT_BMCACHE=512 CONFIG_EXAMPLES_NXTEXT_GLCACHE=16 diff --git a/nuttx/configs/stm3210e-eval/src/up_lcd.c b/nuttx/configs/stm3210e-eval/src/up_lcd.c index 588890e50..a888f31e5 100755 --- a/nuttx/configs/stm3210e-eval/src/up_lcd.c +++ b/nuttx/configs/stm3210e-eval/src/up_lcd.c @@ -498,6 +498,36 @@ static void stm3210e_setcursor(uint16_t col, uint16_t row) stm3210e_writereg(LCD_REG_33, col); /* GRAM vertical address */ } +/************************************************************************************** + * Name: stm3210e_dumprun + * + * Description: + * Dump the contexts of the run buffer: + * + * run - The buffer in containing the run read to be dumped + * npixels - The number of pixels to dump + * + **************************************************************************************/ + +#if 0 /* Sometimes useful */ +static void stm3210e_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels) +{ + int i, j; + + lib_rawprintf("\n%s:\n", msg); + for (i = 0; i < npixels; i += 16) + { + up_putc(' '); + lib_rawprintf(" "); + for (j = 0; j < 16; j++) + { + lib_rawprintf(" %04x", *run++); + } + up_putc('\n'); + } +} +#endif + /************************************************************************************** * Name: stm3210e_putrun * @@ -591,14 +621,7 @@ static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, lcddbg("row: %d col: %d npixels: %d\n", row, col, npixels); DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0); - /* Set up to read the run. */ - - stm3210e_setcursor(col, row); - - /* Read the run from GRAM. The LCD is configured so the X corresponds to rows and - * Y corresponds to columns. (0, STM3210E_XRES-1) is the upper left hand corner. Y - * autodecrements. - */ + /* Read the run from GRAM. */ #ifdef CONFIG_LCD_LANDSCAPE /* Convert coordinates -- Which edge of the display is the "top?" Here the edge @@ -638,6 +661,7 @@ static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, col++; } #endif + return OK; } -- cgit v1.2.3