summaryrefslogtreecommitdiff
path: root/apps/examples/nxtext
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-10 22:35:35 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-10 22:35:35 +0000
commitfcb3f0be7cf755c09970aef69d46c183779dc6f7 (patch)
tree7ab8ce071ef612193405dd334ff4af66bf98eaa9 /apps/examples/nxtext
parentbc4b6fcb861a7f143ddcc4aeef828cbab4006b51 (diff)
downloadnuttx-fcb3f0be7cf755c09970aef69d46c183779dc6f7.tar.gz
nuttx-fcb3f0be7cf755c09970aef69d46c183779dc6f7.tar.bz2
nuttx-fcb3f0be7cf755c09970aef69d46c183779dc6f7.zip
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
Diffstat (limited to 'apps/examples/nxtext')
-rw-r--r--apps/examples/nxtext/nxtext_bkgd.c126
-rw-r--r--apps/examples/nxtext/nxtext_internal.h6
-rw-r--r--apps/examples/nxtext/nxtext_main.c51
-rw-r--r--apps/examples/nxtext/nxtext_putc.c2
4 files changed, 131 insertions, 54 deletions
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 */