apps/examples/pwfb: Change b32_t's to b16_t's; don't need so much precision. Some improvements to motion. Add VERBOSE debug output. Still lots of bugs.
This commit is contained in:
parent
98b4394c9d
commit
9cd5d5c9ac
@ -64,6 +64,10 @@ config EXAMPLES_PWFB_BPP
|
||||
Pixels per pixel to use. Valid options include 2, 4, 8, 16, 24,
|
||||
and 32. Default is 32.
|
||||
|
||||
config EXAMPLES_PWFB_VERBOSE
|
||||
bool "Verbose output"
|
||||
default n
|
||||
|
||||
comment "NX Server Options"
|
||||
|
||||
config EXAMPLES_PWFB_STACKSIZE
|
||||
|
@ -108,12 +108,14 @@ static void pwfb_position(NXTKWINDOW hwnd, FAR const struct nxgl_size_s *size,
|
||||
{
|
||||
FAR struct pwfb_state_s *st = (FAR struct pwfb_state_s *)arg;
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_PWFB_VERBOSE
|
||||
/* Report the position */
|
||||
|
||||
printf("pwfb_position: 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);
|
||||
#endif
|
||||
|
||||
/* Have we picked off the window bounds yet? */
|
||||
|
||||
|
@ -135,12 +135,12 @@ struct pwfb_window_s
|
||||
NXTKWINDOW hwnd; /* Window handle */
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]; /* Window color */
|
||||
FCACHE fcache; /* Font cache handle */
|
||||
b32_t xmax; /* Max X position */
|
||||
b32_t ymax; /* Max Y position */
|
||||
b32_t xpos; /* Current X position */
|
||||
b32_t ypos; /* Current Y position */
|
||||
b32_t deltax; /* Current X speed */
|
||||
b32_t deltay; /* Current Y speed */
|
||||
b16_t xmax; /* Max X position */
|
||||
b16_t ymax; /* Max Y position */
|
||||
b16_t xpos; /* Current X position */
|
||||
b16_t ypos; /* Current Y position */
|
||||
b16_t deltax; /* Current X speed */
|
||||
b16_t deltay; /* Current Y speed */
|
||||
};
|
||||
|
||||
/* Describes the overall state of the example */
|
||||
|
@ -434,12 +434,12 @@ static bool pwfb_configure_window(FAR struct pwfb_state_s *st, int wndx,
|
||||
|
||||
/* Set up for motion */
|
||||
|
||||
wndo->xmax = itob32(st->xres - size->w - 1);
|
||||
wndo->ymax = itob32(st->yres - size->h - 1);
|
||||
wndo->ypos = itob32(pos->y);
|
||||
wndo->xpos = itob32(pos->x);
|
||||
wndo->deltax = dtob32(deltax);
|
||||
wndo->deltay = dtob32(deltay);
|
||||
wndo->xmax = itob16(st->xres - size->w - 1);
|
||||
wndo->ymax = itob16(st->yres - size->h - 1);
|
||||
wndo->ypos = itob16(pos->y);
|
||||
wndo->xpos = itob16(pos->x);
|
||||
wndo->deltax = dtob16(deltax);
|
||||
wndo->deltay = dtob16(deltay);
|
||||
|
||||
return true;
|
||||
|
||||
@ -554,10 +554,10 @@ int pwfb_main(int argc, char *argv[])
|
||||
size.w = wstate.xres / 2;
|
||||
size.h = wstate.yres / 2;
|
||||
|
||||
pos.x = wstate.xres / 4;
|
||||
pos.y = wstate.yres / 4;
|
||||
pos.x = wstate.xres / 8;
|
||||
pos.y = wstate.yres / 8;
|
||||
|
||||
if (!pwfb_configure_window(&wstate, 0, &size, &pos, g_wndomsg1, 1.58, 4.5))
|
||||
if (!pwfb_configure_window(&wstate, 0, &size, &pos, g_wndomsg1, 4.200, 4.285))
|
||||
{
|
||||
printf("pwfb_main: ERROR: "
|
||||
"pwfb_configure_window failed for window 1\n");
|
||||
@ -585,7 +585,7 @@ int pwfb_main(int argc, char *argv[])
|
||||
pos.x = wstate.xres / 4;
|
||||
pos.y = wstate.yres / 4;
|
||||
|
||||
if (!pwfb_configure_window(&wstate, 1, &size, &pos, g_wndomsg2, -1.13, 5.0))
|
||||
if (!pwfb_configure_window(&wstate, 1, &size, &pos, g_wndomsg2, -3.317, 5.0))
|
||||
{
|
||||
printf("pwfb_main: ERROR: "
|
||||
"pwfb_configure_window failed for window 2\n");
|
||||
@ -613,7 +613,7 @@ int pwfb_main(int argc, char *argv[])
|
||||
pos.x = (3 * wstate.xres) / 8;
|
||||
pos.y = (3 * wstate.yres) / 8;
|
||||
|
||||
if (!pwfb_configure_window(&wstate, 2, &size, &pos, g_wndomsg3, -1.13, 5.0))
|
||||
if (!pwfb_configure_window(&wstate, 2, &size, &pos, g_wndomsg3, 4.600, -3.852))
|
||||
{
|
||||
printf("pwfb_main: ERROR: "
|
||||
"pwfb_configure_window failed for window 2\n");
|
||||
|
@ -60,11 +60,24 @@ static inline bool pwfb_move_window(FAR struct pwfb_state_s *st, int wndx)
|
||||
{
|
||||
FAR struct pwfb_window_s *wndo = &st->wndo[wndx];
|
||||
FAR struct nxgl_point_s pos;
|
||||
b32_t newx;
|
||||
b32_t newy;
|
||||
b16_t newx;
|
||||
b16_t newy;
|
||||
bool hit = false;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_PWFB_VERBOSE
|
||||
printf("pwfb_move_window: Velocity: (%lx.%04lx,%lx.%04lx)\n",
|
||||
(unsigned long)wndo->deltax >> 16,
|
||||
(unsigned long)wndo->deltax & 0xffff,
|
||||
(unsigned long)wndo->deltay >> 16,
|
||||
(unsigned long)wndo->deltay & 0xffff);
|
||||
printf("pwfb_move_window: Max: (%lx.%04lx,%lx.%04lx)\n",
|
||||
(unsigned long)wndo->xmax >> 16,
|
||||
(unsigned long)wndo->xmax & 0xffff,
|
||||
(unsigned long)wndo->ymax >> 16,
|
||||
(unsigned long)wndo->ymax & 0xffff);
|
||||
#endif
|
||||
|
||||
/* Update X position */
|
||||
|
||||
newx = wndo->xpos + wndo->deltax;
|
||||
@ -84,8 +97,6 @@ static inline bool pwfb_move_window(FAR struct pwfb_state_s *st, int wndx)
|
||||
hit = true;
|
||||
}
|
||||
|
||||
wndo->xpos = newx;
|
||||
|
||||
/* Update Y position */
|
||||
|
||||
newy = wndo->ypos + wndo->deltay;
|
||||
@ -105,12 +116,29 @@ static inline bool pwfb_move_window(FAR struct pwfb_state_s *st, int wndx)
|
||||
hit = true;
|
||||
}
|
||||
|
||||
wndo->ypos = newy;
|
||||
#ifdef CONFIG_EXAMPLES_PWFB_VERBOSE
|
||||
printf("pwfb_move_window: Old pos: (%lx.%04lx,%lx.%04lx) "
|
||||
"New pos: (%lx.%04lx,%lx.%04lx)\n",
|
||||
(unsigned long)wndo->xpos >> 16,
|
||||
(unsigned long)wndo->xpos & 0xffff,
|
||||
(unsigned long)wndo->ypos >> 16,
|
||||
(unsigned long)wndo->ypos & 0xffff,
|
||||
(unsigned long)newx >> 16,
|
||||
(unsigned long)newx & 0xffff,
|
||||
(unsigned long)newy >> 16,
|
||||
(unsigned long)newy & 0xffff);
|
||||
#endif
|
||||
|
||||
/* Set the new window position */
|
||||
|
||||
pos.x = b32toi(newx);
|
||||
pos.y = b32toi(newy);
|
||||
wndo->xpos = newx;
|
||||
wndo->ypos = newy;
|
||||
|
||||
pos.x = b16toi(newx);
|
||||
pos.y = b16toi(newy);
|
||||
|
||||
printf("pwfb_move_window: Set position (%d,%d)\n", pos.x, pos.y);
|
||||
|
||||
ret = nxtk_setposition(wndo->hwnd, &pos);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -124,6 +152,15 @@ static inline bool pwfb_move_window(FAR struct pwfb_state_s *st, int wndx)
|
||||
|
||||
if (hit)
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_PWFB_VERBOSE
|
||||
printf("pwfb_move_window: New velocity: (%lx.%04lx,%lx.%04lx)\n",
|
||||
(unsigned long)wndo->deltax >> 16,
|
||||
(unsigned long)wndo->deltax & 0xffff,
|
||||
(unsigned long)wndo->deltay >> 16,
|
||||
(unsigned long)wndo->deltay & 0xffff);
|
||||
printf("pwfb_move_window: Raising window\n");
|
||||
#endif
|
||||
|
||||
ret = nxtk_raise(wndo->hwnd);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user