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
This commit is contained in:
parent
0cfb54eff4
commit
1936763df6
@ -314,10 +314,11 @@ examples/nxtest
|
|||||||
The text display will continue to update while the pop-up is visible.
|
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
|
NOTE: This example will *only* work with FB drivers and with LCD
|
||||||
drivers that support reading the contents of the internal LCD memory.
|
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
|
*unless* you define CONFIG_EXAMPLES_NXTEXT_NOGETRUN. If you notice
|
||||||
the display should scroll, it is probably because you have an LCD
|
garbage on the display or a failure at the point where the display
|
||||||
driver that is write-only.
|
should scroll, it is probably because you have an LCD driver that is
|
||||||
|
write-only.
|
||||||
|
|
||||||
The following configuration options can be selected:
|
The following configuration options can be selected:
|
||||||
|
|
||||||
@ -335,6 +336,9 @@ examples/nxtest
|
|||||||
background window. Default depends on CONFIG_EXAMPLES_NXTEXT_BPP.
|
background window. Default depends on CONFIG_EXAMPLES_NXTEXT_BPP.
|
||||||
CONFIG_EXAMPLES_NXTEXT_BPP -- Pixels per pixel to use. Valid options
|
CONFIG_EXAMPLES_NXTEXT_BPP -- Pixels per pixel to use. Valid options
|
||||||
include 2, 4, 8, 16, 24, and 32. Default is 32.
|
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
|
CONFIG_EXAMPLES_NXTEXT_EXTERNINIT - The driver for the graphics device on
|
||||||
this platform requires some unusual initialization. This is the
|
this platform requires some unusual initialization. This is the
|
||||||
for, for example, SPI LCD/OLED devices. If this configuration is
|
for, for example, SPI LCD/OLED devices. If this configuration is
|
||||||
|
@ -196,15 +196,111 @@ static void nxbg_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#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
|
* Name: nxbg_scroll
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static inline void nxbg_scroll(NXWINDOW hwnd, int lineheight)
|
static inline void nxbg_scroll(NXWINDOW hwnd, int lineheight)
|
||||||
{
|
{
|
||||||
struct nxgl_rect_s rect;
|
|
||||||
struct nxgl_point_s offset;
|
|
||||||
int ret;
|
|
||||||
int i;
|
int i;
|
||||||
int j;
|
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? */
|
/* 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 */
|
/* 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;
|
g_bgstate.fpos.y -= lineheight;
|
||||||
|
|
||||||
/* Move the display in the range of 0-height up one lineheight. The
|
/* Move the display in the range of 0-height up one lineheight. */
|
||||||
* line at the bottom will be reset to the background color automatically.
|
|
||||||
*
|
|
||||||
* The source rectangle to be moved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rect.pt1.x = 0;
|
nxbg_movedisplay(hwnd, g_bgstate.fpos.y, lineheight);
|
||||||
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 */
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -242,9 +242,9 @@ struct nxtext_state_s
|
|||||||
|
|
||||||
/* These describe all text already added to the display */
|
/* 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 maxglyphs; /* Size of the glyph array */
|
uint16_t maxchars; /* Size of the bm[] array */
|
||||||
uint8_t nchars; /* Number of chars already displayed */
|
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_bitmap_s *bm; /* List of characters on the display */
|
||||||
FAR struct nxtext_glyph_s *glyph; /* Cache of rendered fonts in use */
|
FAR struct nxtext_glyph_s *glyph; /* Cache of rendered fonts in use */
|
||||||
|
@ -99,30 +99,30 @@
|
|||||||
static const uint8_t g_pumsg[] = "Pop-Up!";
|
static const uint8_t g_pumsg[] = "Pop-Up!";
|
||||||
static const char *g_bgmsg[BGMSG_LINES] =
|
static const char *g_bgmsg[BGMSG_LINES] =
|
||||||
{
|
{
|
||||||
"\nJULIET\n",
|
"\nJULIET\n", /* Line 1 */
|
||||||
"Wilt thou be gone?\n",
|
"Wilt thou be gone?\n", /* Line 2 */
|
||||||
" It is not yet near day:\n",
|
" It is not yet near day:\n", /* Line 3 */
|
||||||
"It was the nightingale,\n",
|
"It was the nightingale,\n", /* Line 4 */
|
||||||
" and not the lark,\n",
|
" and not the lark,\n", /* Line 5 */
|
||||||
"That pierced the fearful hollow\n",
|
"That pierced the fearful hollow\n", /* Line 6 */
|
||||||
" of thine ear;\n",
|
" of thine ear;\n", /* Line 7 */
|
||||||
"Nightly she sings\n",
|
"Nightly she sings\n", /* Line 8 */
|
||||||
" on yon pomegranate-tree:\n",
|
" on yon pomegranate-tree:\n", /* Line 9 */
|
||||||
"Believe me, love,\n",
|
"Believe me, love,\n", /* Line 10 */
|
||||||
" it was the nightingale.\n",
|
" it was the nightingale.\n", /* Line 11 */
|
||||||
"\nROMEO\n",
|
"\nROMEO\n", /* Line 12 */
|
||||||
"It was the lark,\n",
|
"It was the lark,\n", /* Line 13 */
|
||||||
" the herald of the morn,\n",
|
" the herald of the morn,\n", /* Line 14 */
|
||||||
"No nightingale:\n",
|
"No nightingale:\n", /* Line 15 */
|
||||||
" look, love, what envious streaks\n",
|
" look, love, what envious streaks\n", /* Line 16 */
|
||||||
"Do lace the severing clouds\n",
|
"Do lace the severing clouds\n", /* Line 17 */
|
||||||
" in yonder east:\n",
|
" in yonder east:\n", /* Line 18 */
|
||||||
"Night's candles are burnt out,\n",
|
"Night's candles are burnt out,\n", /* Line 19 */
|
||||||
" and jocund day\n",
|
" and jocund day\n", /* Line 20 */
|
||||||
"Stands tiptoe\n",
|
"Stands tiptoe\n", /* Line 21 */
|
||||||
" on the misty mountain tops.\n",
|
" on the misty mountain tops.\n", /* Line 22 */
|
||||||
"I must be gone and live,\n",
|
"I must be gone and live,\n", /* Line 23 */
|
||||||
" or stay and die.\n"
|
" or stay and die.\n" /* Line 24 */
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -440,7 +440,8 @@ int user_start(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Give another line of text to the background window. Force this
|
/* 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]));
|
nxbg_write(g_bgwnd, (FAR const uint8_t *)g_bgmsg[bkgndx], strlen(g_bgmsg[bkgndx]));
|
||||||
|
@ -572,7 +572,7 @@ void nxtext_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
|||||||
|
|
||||||
if (!nxgl_nullrect(&intersection))
|
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 */
|
/* Find (or create) the glyph that goes with this font */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user