NX Graphics SubsystemLast Updated: August 8, 2019 |
Table of Contents |
1.0 Introduction |
This document describes the tiny graphics support included in NuttX. It includes an overview description of that graphics support, detailed descriptions of the NuttX graphics APIs, and discussion of code organization, and OS configuration options.
The objective of this development was to provide a tiny windowing system in the spirit of X, but greatly scaled down and appropriate for most resource-limited embedded environments. The current NX implementation supports the general following, high-level features:
include/nuttx/video/fb.h
).
include/nuttx/lcd/lcd.h
).
By default, NX is configured to use the frame buffer driver unless CONFIG_NX_LCDDRIVER
is defined =y in your NuttX configuration file.
NX is organized into 6 (and perhaps someday 7 or 8) logical modules. These logical modules also correspond to the directory organization. That NuttX directory organization is discussed in Appendix B of this document. The logic modules are discussed in the following sub-paragraphs.
NXGL
)NXGLIB is a standalone library that contains low-level graphics utilities and direct framebuffer or LCD rendering logic. NX is built on top NXGLIB.
NXSU
and NXMU
)NX is the tiny NuttX windowing system for raw windows (i.e., simple regions of graphics memory). NX includes a small-footprint, multi-user implementation (NXMU as described below). NX can be used without NxWidgets and without NXTOOLKIT for raw window displays.
1NXMU and NXSU are interchangeable other than (1) certain start-up and initialization APIs (as described below), and (2) timing. With NXSU, NX APIs execute immediately; with NXMU, NX APIs defer and serialize the operations and, hence, introduce different timing and potential race conditions that you would not experience with NXSU.
NXNULL? At one time, I also envisioned a NULL front-end that did not support windowing at all but, rather, simply provided the entire framebuffer or LCD memory as one dumb window. This has the advantage that the same NX APIs can be used on the one dumb window as for the other NX windows. This would be in the NuttX spirit of scalability.
However, the same end result can be obtained by using the
nx_requestbkgd()
API.
It still may be possible to reduce the footprint in this usage case by developing
and even thinner NXNULL front-end.
That is a possible future development.
NXTK
)NXTK is a s set of C graphics tools that provide higher-level window drawing operations. This is the module where the framed windows and toolbar logic is implemented. NXTK is built on top of NX and does not depend on NxWidgets.
NXFONTS
)A set of C graphics tools for present (bitmap) font images. The font implementation is at a very low level or graphics operation, comparable to the logic in NXGLIB. NXFONTS does not depend on any NX module other than some utilities and types from NXGLIB.
NxWidgets
)
NxWidgets is a higher level, C++, object-oriented library for object-oriented access to graphical "widgets."
NxWidgets is provided as a separate library in the apps/
repository
NxWidgets is built on top of the core NuttX graphics subsystem, but is part of the application space rather than part of the core OS graphics subsystems.
NxTerm
)
NxTerm is a write-only character device (not shown) that is built on top of an NX window.
This character device can be used to provide stdout
and stderr
and, hence, can provide the output side of NuttX console.
).
2.0 NX User APIs |
include/nuttx/nx/nxglib.h
include/nuttx/nx/nx.h
include/nutt/nxtk.h
include/nutt/nxfont.h
NXGL
)
NXGL provides many APIs, some available for use internally by NX and
others for use by applications as well.
Only those APIs intended for application usage are documented here
See include/nuttx/nx/nxglib.h
for the full set of APIs;
those APIs might be of interest if you are rendering directly into
framebuffer or LCD memory.
nxgl_mxpixel_t
.
Holds one device pixel.
NXGLIB will select the smallest size for the nxgl_mxpixel_t
that just contains the pixel: byte
if 16, 24, and 32 resolution
support is disabled, uint16_t
if 24, and 32 resolution
support is disabled, or uint32_t
.
nxgl_coord_t
.
A given coordinate is limited to the screen height an width. If either
of those values exceed 32,767 pixels, then the following will have to need
to change:
typedef int16_t nxgl_coord_t;
struct nxgl_point_s
. Describes a point on the display:
struct nxgl_point_s { nxgl_coord_t x; /* X position, range: 0 to screen width - 1 */ nxgl_coord_t y; /* Y position, range: 0 to screen height - 1 */ };
struct nxgl_size_s
. Describes the size of a rectangular region.
struct nxgl_size_s { nxgl_coord_t w; /* Width in pixels */ nxgl_coord_t h; /* Height in rows */ };
struct nxgl_rect_s
. Describes a positioned rectangle on the display.
struct nxgl_rect_s { struct nxgl_point_s pt1; /* Upper, left-hand corner */ struct nxgl_point_s pt2; /* Lower, right-hand corner */ };
struct nxgl_run_s
.
Describes a run, i.e., a horizontal line. Note that the start/end positions
have fractional precision. This is necessary for good joining of trapezoids
when a more complex shape is decomposed into trapezoids
struct nxgl_run_s { b16_t x1; /* Left X position, range: 0 to x2 */ b16_t x2; /* Right X position, range: x1 to screen width - 1 */ nxgl_coord_t y; /* Top Y position, range: 0 to screen height - 1 */ };
struct nxgl_trapezoid_s
.
Describes a horizontal trapezoid on the display in terms the run at the
top of the trapezoid and the run at the bottom
struct nxgl_trapezoid_s { struct nxgl_run_s top; /* Top run */ struct nxgl_run_s bot; /* bottom run */ };
nxgl_rgb2yuv()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_rgb2yuv(uint8_t r, uint8_t g, uint8_t b, uint8_t *y, uint8_t *u, uint8_t *v);
Description: Convert 8-bit RGB triplet to 8-bit YUV triplet.
nxgl_yuv2rgb()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t *r, uint8_t *g, uint8_t *b);
Description: Convert 8-bit YUV triplet to 8-bit RGB triplet.
nxgl_rectcopy()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_rectcopy(FAR struct nxgl_rect_s *dest, FAR const struct nxgl_rect_s *src);
Description:
This is essentially memcpy()
for rectangles. We don't do structure
assignments because some compilers are not good at that.
nxgl_rectoffset()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_rectoffset(FAR struct nxgl_rect_s *dest, FAR const struct nxgl_rect_s *src, nxgl_coord_t dx, nxgl_coord_t dy);
Description: Offset the rectangle position by the specified dx, dy values.
nxgl_vectoradd()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_vectoradd(FAR struct nxgl_point_s *dest, FAR const struct nxgl_point_s *v1, FAR const struct nxgl_point_s *v2);
Description: Add two 2x1 vectors and save the result to a third.
nxgl_vectorsubtract()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_vectsubtract(FAR struct nxgl_point_s *dest, FAR const struct nxgl_point_s *v1, FAR const struct nxgl_point_s *v2);
Description:
Add subtract vector v2
from vector v1
and return the result in vector dest.
nxgl_rectintersect()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_rectintersect(FAR struct nxgl_rect_s *dest, FAR const struct nxgl_rect_s *src1, FAR const struct nxgl_rect_s *src2);
Description: Return the rectangle representing the intersection of the two rectangles.
nxgl_rectunion()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_rectunion(FAR struct nxgl_rect_s *dest, FAR const struct nxgl_rect_s *src1, FAR const struct nxgl_rect_s *src2);
Description:
Given two rectangles, src1
and src2
, return the larger rectangle that
contains both, dest
.
nxgl_nonintersecting()
Function Prototype:
#include <nuttx/nx/nxglib.h> nxgl_nonintersecting(FAR struct nxgl_rect_s result[4], FAR const struct nxgl_rect_s *rect1, FAR const struct nxgl_rect_s *rect2);
Description:
Return the regions of rectangle rect1
that do not intersect with
rect2
. This will four rectangles, some of which may be
degenerate (and can be picked off with nxgl_nullrect()
).
nxgl_rectoverlap()
Function Prototype:
#include <nuttx/nx/nxglib.h> bool nxgl_rectoverlap(FAR struct nxgl_rect_s *rect1, FAR struct nxgl_rect_s *rect2);
Description: Return true if the two rectangles overlap.
nxgl_rectinside()
Function Prototype:
#include <nuttx/nx/nxglib.h> bool nxgl_rectinside(FAR const struct nxgl_rect_s *rect, FAR const struct nxgl_point_s *pt);
Description:
Return true if the point pt
lies within rect
.
nxgl_rectsize()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_rectsize(FAR struct nxgl_size_s *size, FAR const struct nxgl_rect_s *rect);
Description: Return the size of the specified rectangle.
nxgl_nullrect()
Function Prototype:
#include <nuttx/nx/nxglib.h> bool nxgl_nullrect(FAR const struct nxgl_rect_s *rect);
Description: Return true if the area of the retangle is <= 0.
nxgl_runoffset()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_runoffset(FAR struct nxgl_run_s *dest, FAR const struct nxgl_run_s *src, nxgl_coord_t dx, nxgl_coord_t dy);
Description:
Offset the run position by the specified dx
, dy
values.
nxgl_runcopy()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_runcopy(FAR struct nxgl_run_s *dest, FAR const struct nxgl_run_s *src);
Description:
This is essentially memcpy()
for runs. We don't do structure assignments
because some compilers are not good at that.
nxgl_trapoffset()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_trapoffset(FAR struct nxgl_trapezoid_s *dest, FAR const struct nxgl_trapezoid_s *src, nxgl_coord_t dx, nxgl_coord_t dy);
Description:
Offset the trapezoid position by the specified dx
, dy
values.
nxgl_trapcopy()
Function Prototype:
#include <nuttx/nx/nxglib.h> void nxgl_trapcopy(FAR struct nxgl_trapezoid_s *dest, FAR const struct nxgl_trapezoid_s *src);
Description:
This is essentially memcpy()
for trapezoids. We don't do structure
assignments because some compilers are not good at that.
nxgl_colorcopy
Function Prototype:
#include <nuttx/nx/nxglib.h> nxgl_colorcopy(nxgl_mxpixel_t dest[CONFIG_NX_NPLANES], const nxgl_mxpixel_t src[CONFIG_NX_NPLANES]);
Description:
This is essentially memcpy()
for colors. This does very little for us
other than hide all of the conditional compilation for planar colors
in one place.
nxgl_splitline
Function Prototype:
#include <nuttx/nx/nxglib.h> int nxgl_splitline(FAR struct nxgl_vector_s *vector, FAR struct nxgl_trapezoid_s *traps, FAR struct nxgl_rect_s *rect, nxgl_coord_t linewidth);
Description: In the general case, a line with width can be represented as a parallelogram with a triangle at the top and bottom. Triangles and parallelograms are both degenerate versions of a trapezoid. This function breaks a wide line into triangles and trapezoids. This function also detects other degenerate cases:
y1 == y2
then the line is horizontal and is better represented as a rectangle.
x1 == x2
then the line is vertical and also better represented as a rectangle.
Input parameters:
vector
traps
rect
Returned value:
0
: Line successfully broken up into three trapezoids.
Values in traps[0]
, traps[1]
, and traps[2]
are valid.
1
: Line successfully represented by one trapezoid.
Value in traps[1]
is valid.
2
: Line successfully represented by one rectangle.
Value in rect
is valid
<0
: On errors, a negated errno
value is returned.
nxgl_circlepts
#include <nuttx/nx/nxglib.h> void nxgl_circlepts(FAR const struct nxgl_point_s *center, nxgl_coord_t radius, FAR struct nxgl_point_s *circle);
Description:
Given a description of a circle, return a set of 16 points on the circumference of the circle.
These points may then be used by nx_drawcircle()
or related APIs to draw a circle outline.
Input parameters:
center
radius
circle
Returned value: None
nxgl_circletraps
#include <nuttx/nx/nxglib.h> oid nxgl_circletraps(FAR const struct nxgl_point_s *center, nxgl_coord_t radius, FAR struct nxgl_trapezoid_s *circle);
Description:
Given a description of a a circle, return 8 trapezoids that can be used to fill the circle by nx_fillcircle()
and other interfaces.
Input parameters:
center
radius
circle
Returned value: None
The default server message queue name used by the
nx_run()
macro:
#define NX_DEFAULT_SERVER_MQNAME "/dev/nxs"
Mouse button bits:
#define NX_MOUSE_NOBUTTONS 0x00 #define NX_MOUSE_LEFTBUTTON 0x01 #define NX_MOUSE_CENTERBUTTON 0x02 #define NX_MOUSE_RIGHTBUTTON 0x04
The interface to the NX server is managed using a opaque handle:
typedef FAR void *NXHANDLE;
The interface to a specific window is managed using an opaque handle:
typedef FAR void *NXWINDOW;
These define callbacks that must be provided to nx_openwindow()
.
These callbacks will be invoked as part of the processing performed by nx_eventhandler()
.
struct nx_callback_s { void (*redraw)(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, bool more, FAR void *arg); void (*position)(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, FAR const struct nxgl_point_s *pos, FAR const struct nxgl_rect_s *bounds, FAR void *arg); #ifdef CONFIG_NX_XYINPUT void (*mousein)(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, uint8_t buttons, FAR void *arg); #endif #ifdef CONFIG_NX_KBD void (*kbdin)(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, FAR void *arg); #endif };
The NX Server is a kernel daemon that receives and serializes graphic commands. Before you can use the NX graphics system, you must first start this daemon. There are two ways that this can be done:
The NX server may be started in your board startup logic by simply calling the function nxmu_start()
.
The board startup logic usually resides the the boards/arch/chip/board/src
directory.
The board startup logic can run automatically during the early system if CONFIG_BOARD_LATE_INITIALIZE
is defined in the configuration.
Or, the board startup logic can execute under control of the application by calling the boardctl(BOARDIOC_INIT, arg)
OS interface.
The board initialization logic will run in either case and the simple call to nxmu_start()
will start the NX server.
boardctl(BOARDIOC_NX_START, arg)
nxmu_start()
Function Prototype:
#include <nuttx/nx/nx.h> int nxmu_start(int display, int plane);
Description:
nxmu_start()
provides a wrapper function to simplify and standardize the starting of the NX server.
Input Parameters:
display
plane
Returned Value:
Zero (OK
) is returned on success.
This indicates that the NX server has been successfully started, is running, and waiting to accept connections from NX clients.
A negated errno
value is returned on failure.
The errno
value indicates the nature of the failure.
boardctl()
Function Prototype:
#include <sys/boardctl.h>
Description:
boardctl()
is a generic NuttX interface that among many of it functions, may also be used to start the NX server.
ioctl()
calls.
This, however, may not be practical in many cases and will lead to "correct" but awkward implementations.
boardctl()
is non-standard OS interface to alleviate the problem.
It basically circumvents the normal device driver ioctl interlace and allows the application to perform direction IOCTL-like calls to the board-specific logic.
In it is especially useful for setting up board operational and test configurations.
When called with the cmd
of BOARDIOC_NX_START
, then the boardctl()
will call nxmu_start
indirectly on behalf of the application.
In this case the arg
parameter is ignored.
Input Parameters:
cmd
arg
Returned Value:
On success zero (OK
ERROR) is returned on failure with the errno
variable set to indicate the nature of the failure.
redraw()
Callback Function Prototype:
void redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, bool more, FAR void *arg);
Description: NX requests that the client re-draw the portion of the window within with rectangle.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
rect
more
arg
nx_openwindow()
)
Returned Value: None
position()
Callback Function Prototype:
void position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, FAR const struct nxgl_point_s *pos, FAR const struct nxgl_rect_s *bounds, FAR void *arg);
Description: The size or position of the window has changed (or the window was just created with zero size.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
size
pos
bounds
arg
nx_openwindow()
)
Returned Value: None
mousein()
Callback Function Prototype:
#ifdef CONFIG_NX_XYINPUT void mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, uint8_t buttons, FAR void *arg); #endif
Description: New mouse data is available for the window
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
pos
buttons
NX_MOUSE_*
definitions
arg
nx_openwindow()
)
Returned Value: None
kbdin()
Callback Function Prototype:
#ifdef CONFIG_NX_KBD void (*kbdin)(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, FAR void *arg); #endif
Description: New keyboard/keypad data is available for the window.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
nch
ch
arg
nx_openwindow()
)
Returned Value: None
2.3.4.5event()
event()
Callback Function Prototype:
void (*event)(NXWINDOW hwnd, enum nx_event_e event, FAR void *arg1, FAR void *arg2);
Description: This callback is used to communicate server events to the window listener.
nx_block()
, nxtk_block()
. Those blocking interfaces are used to assure that no further messages are directed to the window. Receipt of the blocked callback signifies that (1) there are no further pending callbacks and (2) that the window is now defunct and will receive no further callbacks.
This callback supports coordinated destruction of a window. In the multi-user mode, the client window logic must stay intact until all of the queued callbacks are processed. Then the window may be safely closed. Closing the window prior with pending callbacks can lead to bad behavior when the callback is executed.
nx_synch()
, or nxtk_synch()
. Those interfaces send a synchronization messages to the NX server which responds with this event. The sleeping client is awakened and continues graphics processing, completing the handshake.
Due to the highly asynchronous nature of client-server communications, synchronization is sometimes necessary to assure that the client and server are working together properly.
Input Parameters:
hwnd
event
arg1
nx_openwindow()
, nx_requestbkgd()
, or nxtk_opentoolbar()
)
arg2
nx_block()
, nxtk_block()
, nx_synch()
, or nxtk_synch()
)
Returned Value: None
nx_runinstance()
(and nx_run()
macro)Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb); #define nx_run(fb) nx_runinstance(NX_DEFAULT_SERVER_MQNAME, dev)
Description: This is the server entry point. It does not return; the calling thread is dedicated to supporting NX server.
NOTE that multiple instances of the NX server may run at the same time,
with different callback and message queue names.
nx_run()
is simply a macro that can be used when only one
server instance is required.
In that case, a default server name is used.
Input Parameters:
mqname
dev
Returned Value:
This function usually does not return. If it does return, it will
return ERROR
and errno
will be set appropriately.
nx_connectinstance()
(and nx_connect()
macro)Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> NXHANDLE nx_connectinstance(FAR const char *svrmqname); #define nx_connect(cb) nx_connectinstance(NX_DEFAULT_SERVER_MQNAME)
Description: Open a connection from a client to the NX server. One one client connection is normally needed per thread as each connection can host multiple windows.
NOTES:
nx_connect()
is simply a macro that can be used when only one
server instance is required. In that case, a default server name
is used.
Input Parameters:
svrmqname
Returned Value:
errno
is set appropriately.
nx_disconnect()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> void nx_disconnect(NXHANDLE handle);
Description:
Disconnect a client from the NX server and/or free resources reserved
by nx_connect()
/nx_connectinstance()
.
Input Parameters:
handle
nx_connect()
.
Returned Value: None.
nx_eventhandler()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_eventhandler(NXHANDLE handle);
Description:
The client code must call this function periodically to process
incoming messages from the server. If CONFIG_NX_BLOCKING
is defined,
then this function not return until a server message is received.
When CONFIG_NX_BLOCKING
is not defined, the client must exercise
caution in the looping to assure that it does not eat up all of
the CPU bandwidth calling nx_eventhandler repeatedly.
nx_eventnotify()
may be called to get a signal event whenever a new incoming server
event is available.
Input Parameters:
handle
nx_connect()
.
Returned Value:
OK
: No errors occurred. If CONFIG_NX_BLOCKING
is defined,
then one or more server messages were processed.
ERROR
: An error occurred and errno
has been set appropriately.
Of particular interest, it will return errno == EHOSTDOWN
when the
server is disconnected. After that event, the handle can no longer be used.
nx_eventnotify()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_eventnotify(NXHANDLE handle, int signo);
Description:
Rather than calling nx_eventhandler()
periodically,
the client may register to receive a signal when a server event is available.
The client can then call nv_eventhandler()
only when
incoming events are available.
The underlying implementation used mq_notifiy()
and, as a result,
the client must observe the rules for using mq_notifiy()
:
nx_eventnotify()
again.
Input Parameters:
handle
nx_connect()
.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_block()
Function Prototype:
#include <nuttx/nx/nx.h> int nx_block(NXWINDOW hwnd, FAR void *arg);
Description: The response to this function call is two things: (1) any queued callback messages to the window are 'blocked' and then (2) also subsequent window messaging is blocked.
The event
callback with the NXEVENT_BLOCKED
event is the response from nx_block()
. This blocking interface is used to assure that no further messages are are directed to the window. Receipt of the NXEVENT_BLOCKED
event signifies that (1) there are no further pending callbacks and (2) that the window is now defunct and will receive no further callbacks.
This callback supports coordinated destruction of a window. The client window logic must stay intact until all of the queued callbacks are processed. Then the window may be safely closed. Closing the window prior with pending callbacks can lead to bad behavior when the callback is executed.
Input Parameters:
wnd
arg
arg2
in the event callback).
Returned Value: OK on success; ERROR on failure with errno set appropriately.
nx_synch()
Function Prototype:
#include <nuttx/nx/nx.h> int nx_synch(NXWINDOW hwnd, FAR void *arg);
Description:
This interface can be used to synchronize the window client with the NX server. It really just implements an echo: A synch message is sent from the window client to the server which then responds immediately by sending the NXEVENT_SYNCHED
back to the windows client.
Due to the highly asynchronous nature of client-server communications, nx_synch()
is sometimes necessary to assure that the client and server are fully synchronized in time.
Usage by the window client might be something like this:
extern bool g_synched; extern sem_t g_synch_sem; g_synched = false; ret = nx_synch(hwnd, handle); if (ret < 0) { -- Handle the error -- } while (!g_synched) { ret = sem_wait(&g_sync_sem); if (ret < 0) { -- Handle the error -- } }
When the window listener thread receives the NXEVENT_SYNCHED
event, it would set g_synched
to true
and post g_synch_sem
, waking up the above loop.
Input Parameters:
wnd
arg
arg2
in the event callback).
Returned Value: OK on success; ERROR on failure with errno set appropriately
nx_openwindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> NXWINDOW nx_openwindow(NXHANDLE handle, uint8_t flags, FAR const struct nx_callback_s *cb, FAR void *arg);
Description: Create a new window.
Input Parameters:
handle
nx_connect()
.
flags
NXBE_WINDOW_RAMBACKED
: Creates a RAM backed window.
This option is only valid if CONFIG_NX_RAMBACKED
is enabled.
NXBE_WINDOW_HIDDEN
: The window is create in the HIDDEN state and can be made visible later with nx_setvisibility()
.
cb
arg
Returned Value:
errno
is set appropriately.
nx_closewindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_closewindow(NXWINDOW hwnd);
Description:
Destroy a window created by nx_openwindow()
window.
Input Parameters:
hwnd
nx_openwindow()
that identifies the window to be destroyed.
This handle must not have been one returned by
nx_requestbkgd()
.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_requestbkgd()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb, FAR void *arg);
Description: NX normally controls a separate window called the background window. It repaints the window as necessary using only a solid color fill. The background window always represents the entire screen and is always below other windows. It is useful for an application to control the background window in the following conditions:
This API only requests the handle of the background window. That handle will be returned asynchronously in a subsequent position and redraw callbacks.
Cautions:
nx_setposition()
,
nx_setsize()
,
nx_raise()
, or
nx_lower()
.
nx_modal()
.
nx_setvisibility()
.
nx_requestbkgd()
nor
nx_releasebkgd ()
should be called more than once.
Multiple instances of the background window are not supported.
Input Parameters:
handle
nx_connect()
.
cb
arg
nx_openwindow()
)
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_releasebkgd()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_releasebkgd(NXWINDOW hwnd);
Description:
Release the background window previously acquired using
nx_requestbkgd()
and return control of the background to NX.
Input Parameters:
handle
nx_requestbkgd()
.
This handle must not have been one created by
nx_openwindow()
.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_getposition()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_getposition(NXWINDOW hwnd);
Description: Request the position and size information for the selected window. The values will be return asynchronously through the client callback function pointer.
Input Parameters:
hwnd
nx_openwindow()
or
nx_requestbkgd()
.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_setposition()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_setposition(NXWINDOW hwnd, FAR struct nxgl_point_s *pos);
Description: Set the position and size for the selected window.
Input Parameters:
hwnd
nx_openwindow()
.
This handle must not have been created by
nx_requestbkgd()
.
pos
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_setsize()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_setsize(NXWINDOW hwnd, FAR struct nxgl_size_s *size);
Description: Set the size of the selected window.
Input Parameters:
hwnd
nx_openwindow()
.
This handle must not have been created by
nx_requestbkgd()
.
size
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_raise()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_raise(NXWINDOW hwnd);
Description: Bring the specified window to the top of the display.
Input Parameters:
hwnd
nx_openwindow()
.
This handle must not have been created by
nx_requestbkgd()
.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_lower()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_lower(NXWINDOW hwnd);
Description: Lower the specified window to the bottom of the display.
Input Parameters:
hwnd
nx_openwindow()
.
This handle must not have been created by
nx_requestbkgd()
.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_modal()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_modal(NXWINDOW hwnd, bool modal);
Description: May be used to either (1) raise a window to the top of the display and select modal behavior, or (2) disable modal behavior.
Input Parameters:
hwnd
nx_openwindow()
.
This handle must not have been created by
nx_requestbkgd()
.
modal
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_setvisibility()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_setvisibility(NXWINDOW hwnd, bool hide);
Description: Select if the window is visible or hidden. A hidden window is still present and will update normally, but will not be visible on the display until it is unhidden.
Input Parameters:
hwnd
nx_openwindow()
.
This handle must not have been created by
nx_requestbkgd()
.
hide
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_ishidden()
Function Prototype:
#include <nuttx/nx/nx.h> bool nx_ishidden(NXWINDOW hwnd);
Description: Return true if the window is hidden.
NOTE: There will be a delay between the time that the visibility of the window is changed via nx_setvisibily()
before that new setting is reported by nx_ishidden()
.
nx_synch()
may be used if temporal synchronization is required.
Input Parameters:
hwnd
nx_openwindow()
that identifies the window to be queried.
Returned Value: True: the window is hidden, false: the window is visible
nx_fill()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Fill the specified rectangle in the window with the specified color.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
rect
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_getrectangle()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> void nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, unsigned int plane, FAR uint8_t *dest, unsigned int deststride);
Description: Get the raw contents of graphic memory within a rectangular region. NOTE: Since raw graphic memory is returned, the returned memory content may be the memory of windows above this one and may not necessarily belong to this window unless you assure that this is the top window.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
rect
plane
dest
deststride
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_filltrapezoid()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip, FAR const struct nxgl_trapezoid_s *trap, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Fill the specified trapezoidal region in the window with the specified color.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
clip
trap
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_drawline()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_drawline(NXWINDOW hwnd, FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES], uint8_t caps);
Description:
Fill the specified trapezoidal region in the window with the specified color.
Fill the specified line in the window with the specified color.
This is simply a wrapper that uses nxgl_splitline()
to break the line into
trapezoids and then calls nx_filltrapezoid()
to render the line.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
vector
width
color
caps
/* Line caps */ #define NX_LINECAP_NONE 0x00, /* No line caps */ #define NX_LINECAP_PT1 0x01 /* Line cap on pt1 on of the vector only */ #define NX_LINECAP_PT2 0x02 /* Line cap on pt2 on of the vector only */ #define NX_LINECAP_BOTH 0x03 /* Line cap on both ends of the vector only */
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_drawcircle()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, nxgl_coord_t radius, nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Draw a circular outline using the specified line thickness and color.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
center
radius
width
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_fillcircle()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_fillcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, nxgl_coord_t radius, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Fill a circular region using the specified color.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
center
radius
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_setbgcolor()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_setbgcolor(NXHANDLE handle, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Set the color of the background.
Input Parameters:
handle
nx_openwindow()
or nx_requestbkgd()
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_move()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, FAR const struct nxgl_point_s *offset);
Description: Move a rectangular region within the window.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
that specifies
the window within which the move is to be done
rect
offset
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_bitmap()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest, FAR const void *src[CONFIG_NX_NPLANES], FAR const struct nxgl_point_s *origin, unsigned int stride);
Description: Copy a rectangular region of a larger image into the rectangle in the specified window.
Input Parameters:
hwnd
nx_openwindow()
or nx_requestbkgd()
that specifies the
window that will receive the bitmap image.
dest
src
CONFIG_NX_NPLANES
(probably 1).
origin
stride
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_kbdin()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #ifdef CONFIG_NX_KBD int nx_kbdchin(NXHANDLE handle, uint8_t ch); int nx_kbdin(NXHANDLE handle, uint8_t nch, FAR const uint8_t *ch); #endif
Description: Used by a thread or interrupt handler that manages some kind of keypad hardware to report text information to the NX server. That text data will be routed by the NX server to the appropriate window client.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nx_mousein()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #ifdef CONFIG_NX_XYINPUT int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons); #endif
Description: Used by a thread or interrupt handler that manages some kind of pointing hardware to report new positional data to the NX server. That positional data will be routed by the NX server to the appropriate window client.
Input Parameters:
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
NXTK
)NXTK implements where the framed window. NX framed windows consist of three components within one NX window:
Each sub-window represents a region within one window. Figure 1 shows some simple NX framed windows. NXTK allows these sub-windows to be managed more-or-less independently:
nxtk_openwindow()
;
Separate toolbar sub-window callbacks are reigistered when the toolbar
is added using nxtk_opentoolbar()
.
(NOTES: (1) only the client sub-window receives keyboard input and,
(2) border callbacks are not currently accessible by the user).
NXTK Types()
This is the handle that can be used to access the window data region.
typedef FAR void *NXTKWINDOW;
nxtk_block()
Function Prototype:
#include <nuttx/nx/nxtk.h> int nxtk_block(NXWINDOW hwnd, FAR void *arg);
Description: The response to this function call is two things: (1) any queued callback messages to the window are 'blocked' and then (2) also subsequent window messaging is blocked.
The event
callback with the NXEVENT_BLOCKED
event is the response from nxtk_block()
. This blocking interface is used to assure that no further messages are are directed to the window. Receipt of the NXEVENT_BLOCKED
event signifies that (1) there are no further pending callbacks and (2) that the window is now defunct and will receive no further callbacks.
This callback supports coordinated destruction of a window. The client window logic must stay intact until all of the queued callbacks are processed. Then the window may be safely closed. Closing the window prior with pending callbacks can lead to bad behavior when the callback is executed.
Input Parameters:
wnd
arg
arg2
in the event callback).
Returned Value: OK on success; ERROR on failure with errno set appropriately.
nxtk_synch()
Function Prototype:
#include <nuttx/nx/nxtk.h> int nxtk_synch(NXWINDOW hwnd, FAR void *arg);
Description:
This interface can be used to synchronize the window client with the NX server. It really just implements an echo: A synch message is sent from the window client to the server which then responds immediately by sending the NXEVENT_SYNCHED
back to the windows client.
Due to the highly asynchronous nature of client-server communications, nx_synch()
is sometimes necessary to assure that the client and server are fully synchronized in time.
Usage by the window client might be something like this:
extern bool g_synched; extern sem_t g_synch_sem; g_synched = false; ret = nxtk_synch(hfwnd, handle); if (ret < 0) { -- Handle the error -- } while (!g_synched) { ret = sem_wait(&g_sync_sem); if (ret < 0) { -- Handle the error -- } }
When the window listener thread receives the NXEVENT_SYNCHED
event, it would set g_synched
to true
and post g_synch_sem
, waking up the above loop.
Input Parameters:
wnd
arg
arg2
in the event callback).
Returned Value: OK on success; ERROR on failure with errno set appropriately
nxtk_openwindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> NXTKWINDOW nxtk_openwindow(NXHANDLE handle, uint8_t flags, FAR const struct nx_callback_s *cb, FAR void *arg);
Description: Create a new, framed window.
Input Parameters:
handle
nx_connect()
.
flags
NXBE_WINDOW_RAMBACKED
: Creates a RAM backed window.
This option is only valid if CONFIG_NX_RAMBACKED
is enabled.
NXBE_WINDOW_HIDDEN
: The window is create in the HIDDEN state and can be made visible later with nxtk_setvisibility()
.
cb
arg
nx_openwindow()
)
Returned Value:
errno
is set appropriately.
nxtk_closewindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_closewindow(NXTKWINDOW hfwnd);
Description:
Close the window opened by nxtk_openwindow()
.
Input Parameters:
hfwnd
nxtk_openwindow()
.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_getposition()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_getposition(NXTKWINDOW hfwnd);
Description: Request the position and size information for the selected framed window. The size/position for the client window and toolbar will be return asynchronously through the client callback function pointer.
Input Parameters:
hfwnd
nxtk_openwindow()
.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_setposition()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_setposition(NXTKWINDOW hfwnd, FAR struct nxgl_point_s *pos);
Description: Set the position for the selected client window. This position does not include the offsets for the borders nor for any toolbar. Those offsets will be added in to set the full window position.
Input Parameters:
hfwnd
nxtk_openwindow()
.
pos
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_setsize()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_setsize(NXTKWINDOW hfwnd, FAR struct nxgl_size_s *size);
Description: Set the size for the selected client window. This size does not include the sizes of the borders nor for any toolbar. Those sizes will be added in to set the full window size.
Input Parameters:
hfwnd
nxtk_openwindow()
.
size
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_raise()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_raise(NXTKWINDOW hfwnd);
Description: Bring the window containing the specified client sub-window to the top of the display.
Input Parameters:
hfwnd
nxtk_openwindow()
specifying the window to be raised.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_lower()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_lower(NXTKWINDOW hfwnd);
Description: Lower the window containing the specified client sub-window to the bottom of the display.
Input Parameters:
hfwnd
nxtk_openwindow()
specifying the window to be lowered.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_modal()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_modal(NXWINDOW hwnd, bool modal);
Description: May be used to either (1) raise a window to the top of the display and select modal behavior, or (2) disable modal behavior.
Input Parameters:
hwnd
nxtk_openwindow()
specifying the window to be modified.
modal
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_setvisibility()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_setvisibility(NXWINDOW hwnd, bool hide);
Description: Select if the window is visible or hidden. A hidden window is still present and will update normally, but will not be visible on the display until it is unhidden.
Input Parameters:
hwnd
nxtk_openwindow()
specifying the window to be modified.
hide
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_ishidden()
Function Prototype:
#include <nuttx/nx/nxtk.h> bool nxtk_ishidden(NXTKWINDOW hfwnd);
Description: Return true if the window is hidden.
NOTE: There will be a delay between the time that the visibility of the window is changed via nxtk_setvisibily()
before that new setting is reported by nxtk_ishidden()
.
nxtk_synch()
may be used if temporal synchronization is required.
Input Parameters:
hfwnd
nxtk_openwindow()
that identifies the window to be queried.
Returned Value: True: the window is hidden, false: the window is visible
nxtk_fillwindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_fillwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Fill the specified rectangle in the client window with the specified color.
Input Parameters:
hfwnd
nxtk_openwindow()
.
rect
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_getwindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> void nxtk_getwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, unsigned int plane, FAR uint8_t *dest, unsigned int deststride);
Description: Get the raw contents of graphic memory within a rectangular region. NOTE: Since raw graphic memory is returned, the returned memory content may be the memory of windows above this one and may not necessarily belong to this window unless you assure that this is the top window.
Input Parameters:
hfwnd
nxtk_openwindow()
.
rect
plane
dest
deststride
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_filltrapwindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_filltrapwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_trapezoid_s *trap, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Fill the specified trapezoid in the client window with the specified color
Input Parameters:
hfwnd
nxtk_openwindow()
.
trap
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_drawlinewindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_drawlinewindow(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES], uint8_t caps);
Description:
Fill the specified trapezoidal region in the window with the specified color.
Fill the specified line in the window with the specified color.
This is simply a wrapper that uses nxgl_splitline()
to break the line into
trapezoids and then calls nxtk_filltrapwindow()
to render the line.
Input Parameters:
hfwnd
nxtk_openwindow()
.
vector
width
color
caps
/* Line caps */ #define NX_LINECAP_NONE 0x00, /* No line caps */ #define NX_LINECAP_PT1 0x01 /* Line cap on pt1 on of the vector only */ #define NX_LINECAP_PT2 0x02 /* Line cap on pt2 on of the vector only */ #define NX_LINECAP_BOTH 0x03 /* Line cap on both ends of the vector only */
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_drawcirclewindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxtk.h> int nxtk_drawcirclewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *center, nxgl_coord_t radius, nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Draw a circular outline using the specified line thickness and color.
Input Parameters:
hfwnd
nxtk_openwindow()
.
center
radius
width
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_fillcirclewindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxtk.h> int nxtk_fillcirclewindow(NXWINDOW hfwnd, FAR const struct nxgl_point_s *center, nxgl_coord_t radius, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Fill a circular region using the specified color.
Input Parameters:
hfwnd
nxtk_openwindow()
.
center
radius
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_movewindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_movewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, FAR const struct nxgl_point_s *offset);
Description: Move a rectangular region within the client sub-window of a framed window.
Input Parameters:
hfwnd
nxtk_openwindow()
specifying the client sub-window within which the move is to be done.
rect
offset
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_bitmapwindow()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_bitmapwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *dest, FAR const void *src[CONFIG_NX_NPLANES], FAR const struct nxgl_point_s *origin, unsigned int stride);
Description: Copy a rectangular region of a larger image into the rectangle in the specified client sub-window.
Input Parameters:
hfwnd
nxtk_openwindow()
specifying the client sub-window that will receive the bitmap.
dest
src
CONFIG_NX_NPLANES
(probably 1).
origin
stride
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_opentoolbar()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_opentoolbar(NXTKWINDOW hfwnd, nxgl_coord_t height, FAR const struct nx_callback_s *cb, FAR void *arg);
Description: Create a tool bar at the top of the specified framed window.
Input Parameters:
hfwnd
nxtk_openwindow()
.
height
cb
arg
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_closetoolbar()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_closetoolbar(NXTKWINDOW hfwnd);
Description: Remove the tool bar at the top of the specified framed window.
Input Parameters:
hfwnd
nxtk_openwindow()
.
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_filltoolbar()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_filltoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Fill the specified rectangle in the toolbar sub-window with the specified color.
Input Parameters:
hfwnd
nxtk_openwindow()
.
rect
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_gettoolbar()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_gettoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, unsigned int plane, FAR uint8_t *dest, unsigned int deststride);
Description: Get the raw contents of graphic memory within a rectangular region. NOTE: Since raw graphic memory is returned, the returned memory content may be the memory of windows above this one and may not necessarily belong to this window unless you assure that this is the top window.
Input Parameters:
hfwnd
nxtk_openwindow()
.
rect
plane
dest
deststride
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_filltraptoolbar()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_filltraptoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_trapezoid_s *trap, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Fill the specified trapezoid in the toolbar sub-window with the specified color.
Input Parameters:
hfwnd
nxtk_openwindow()
.
trap
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_drawlinetoolbar()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_drawlinetoolbar(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES], uint8_t caps);
Description:
Fill the specified line in the toolbar sub-window with the specified color.
This is simply a wrapper that uses nxgl_splitline()
to break the line into
trapezoids and then calls nxtk_filltraptoolbar()
to render the line.
Input Parameters:
hfwnd
nxtk_openwindow()
.
vector
width
color
caps
/* Line caps */ #define NX_LINECAP_NONE 0x00, /* No line caps */ #define NX_LINECAP_PT1 0x01 /* Line cap on pt1 on of the vector only */ #define NX_LINECAP_PT2 0x02 /* Line cap on pt2 on of the vector only */ #define NX_LINECAP_BOTH 0x03 /* Line cap on both ends of the vector only */
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_drawcircletoolbar()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxtk.h> int nxtk_drawcircletoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *center, nxgl_coord_t radius, nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Draw a circular outline using the specified line thickness and color.
Input Parameters:
hfwnd
nxtk_openwindow()
.
center
radius
width
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_fillcircletoolbar()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxtk.h> int nxtk_fillcircletoolbar(NXWINDOW hfwnd, FAR const struct nxgl_point_s *center, nxgl_coord_t radius, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
Description: Fill a circular region using the specified color.
Input Parameters:
hfwnd
nxtk_openwindow()
.
center
radius
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_movetoolbar()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_movetoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, FAR const struct nxgl_point_s *offset);
Description: Move a rectangular region within the toolbar sub-window of a framed window.
Input Parameters:
hfwnd
nxtk_openwindow()
.
rect
offset
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
nxtk_bitmaptoolbar()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> int nxtk_bitmaptoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *dest, FAR const void *src[CONFIG_NX_NPLANES], FAR const struct nxgl_point_s *origin, unsigned int stride);
Description: Copy a rectangular region of a larger image into the rectangle in the specified toolbar sub-window.
Input Parameters:
hfwnd
nxtk_openwindow()
.
dest
src
origin
stride
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately
NXFONTS
)NXFONTS Types()
This structures provides the metrics for one glyph:
struct nx_fontmetric_s { uint32_t stride : 2; /* Width of one font row in bytes */ uint32_t width : 6; /* Width of the font in bits */ uint32_t height : 6; /* Height of the font in rows */ uint32_t xoffset : 6; /* Top, left-hand corner X-offset in pixels */ uint32_t yoffset : 6; /* Top, left-hand corner y-offset in pixels */ uint32_t unused : 6; };
This structure binds the glyph metrics to the glyph bitmap:
struct nx_fontbitmap_s { struct nx_fontmetric_s metric; /* Character metrics */ FAR const uint8_t *bitmap; /* Pointer to the character bitmap */ };
This structure describes one contiguous grouping of glyphs that
can be described by an array starting with encoding first
and
extending through (first
+ nchars
- 1).
struct nx_fontset_s { uint8_t first; /* First bitmap character code */ uint8_t nchars; /* Number of bitmap character codes */ FAR const struct nx_fontbitmap_s *bitmap; };
This structure describes the overall fontset:
struct nx_font_s { uint8_t mxheight; /* Max height of one glyph in rows */ uint8_t mxwidth; /* Max width of any glyph in pixels */ uint8_t mxbits; /* Max number of bits per character code */ uint8_t spwidth; /* The width of a space in pixels */ };
nxf_getfonthandle()
Function Prototype:
#include <nuttx/nx/nxfonts.h> NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid);
Description: Given a numeric font ID, return a handle that may be subsequently be used to access the font data sets.
Input Parameters:
fontid
Returned Value: A handle that may be subsequently be used to access the font data sets.
nxf_getfontset()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxfonts.h> FAR const struct nx_font_s *nxf_getfontset(NXHANDLE handle);
Description: Return information about the current font set.
Input Parameters:
handle
nxf_getfonthandle()
.
Returned Value:
An instance of struct nx_font_s
describing the font set.
nxf_getbitmap()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxfonts.h> FAR const struct nx_fontbitmap_s *nxf_getbitmap(NXHANDLE handle, uint16_t ch);
Description: Return font bitmap information for the selected character encoding.
Input Parameters:
ch
handle
nxf_getfonthandle()
.
Returned Value:
An instance of struct nx_fontbitmap_s
describing the glyph.
nxf_convert_*bpp()
Function Prototype:
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxfonts.h> int nxf_convert_2bpp(FAR uint8_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color); int nxf_convert_4bpp(FAR uint8_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color); int nxf_convert_8bpp(FAR uint8_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color); int nxf_convert_16bpp(FAR uint16_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color); int nxf_convert_24bpp(FAR uint32_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color); int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color);
Description: Convert the 1BPP font to a new pixel depth.
Input Parameters:
dest
height
width
stride
bm
color
Returned Value:
OK
on success;
ERROR
on failure with errno
set appropriately.
()
()
()
NXCURSOR
)nxcursor_enable()
Function Prototype:
#include <nuttx/nx/nxcursor.h> #ifdef CONFIG_NX_SWCURSOR int nxcursor_enable(NXHANDLE hnd, bool enable); #endif
Description: Enable/disable presentation of the cursor. The disabled cursor still exits and still may be controlled, but is not visible on the display.
Input Parameters:
hnd
nx_connect()
.
enable
Returned Value: OK on success; ERROR on failure with errno set appropriately.
nxcursor_setimage()
Function Prototype:
#include <nuttx/nx/nxcursor.h> #ifdef CONFIG_NX_SWCURSOR int nxcursor_setimage(NXHANDLE hnd, FAR const struct nx_cursorimage_s *image); #endif
Description: Set the cursor image.
The image is provided a a 2-bits-per-pixel image. The two bit incoding is as following:
NOTE: The NX logic will reference the user image buffer repeatedly. That image buffer must persist for as long as the NX server connection persists.
Input Parameters:
hnd
nx_connect()
.
image
struct struct nx_cursorimage_s
that describes the cursor image. See <nuttx/nx/nxcursor.h>
for the full description of this structure.
Returned Value: OK on success; ERROR on failure with errno set appropriately.
nxcursor_setposition()
Function Prototype:
#include <nuttx/nx/nxcursor.h> #ifdef CONFIG_NX_SWCURSOR int nxcursor_setposition(NXHANDLE hnd, FAR const struct nxgl_point_s *pos); #endif
Description: Move the cursor to the specified position.
Input Parameters:
hnd
nx_connect()
.
pos
Returned Value: OK on success; ERROR on failure with errno set appropriately.
apps/examples/nx*
.
No sample code is provided in this document.
However, examples can be found in the NuttX source tree at the follow locations:
That example code is intended to test NX.
Since it is test code, it is designed to exercise functionality and does not necessarily represent best NX coding practices.
apps/examples/nx
.
This is a test of windows, optionally with toolbars.
Two windows are created, re-sized, moved, raise lowered.
Simulated mouse and keyboard input is provided.
apps/examples/nxhello
.
This is intended to be simplest NX test:
It simply displays the words "Hello, World!" centered on the display.
apps/examples/nxtext
.
This illustrates how fonts may be managed to provide scrolling text windows.
Pop-up windows are included to verify the clipping and re-drawing of the text display.
In its current form, the NX graphics system provides a low level of graphics and window support. Most of the complexity of manage redrawing and handling mouse and keyboard events must be implemented by the NX client code.
Building apps/examples/nx
.
Testing was performed using the Linux/Cygwin-based NuttX simulator.
Instructions are provided for building that simulation are provided in
Appendix C of this document.
Appendix A
|
The graphics capability consist both of components internal to the RTOS and of user-callable interfaces.
In the NuttX kernel mode build there are some components of the graphics subsystem are callable in user mode and other components that are internal to the RTOS.
The directory nuttx/graphics
contains only those components that are internal to the RTOS.
User callable functions must be part of a library that can be linked against user applications.
This user callable interfaces are provided in sub-directories under nuttx/libnx
.
libnx/nx
graphics/nxglib
and libnx/nxglib
graphics/nxbe
nxmu
and nxsu
below).
It contains most of the important window management logic: clipping, window controls,
window drawing, etc.
graphics/nxmu
and libnx/nxmu
nxbe
), it implements a
multi-threaded, multi-user windowing system.
The files in this directory present the window APIs described in
include/nuttx/nx/nx.h
.
The multi-user front end includes a graphics server that executes on its own thread;
multiple graphics clients then communicate with the server via a POSIX message
queue to serialize window operations from many threads.
libnx/nxfonts
include/nuttx/nx/nxfonts.h
.
libnx/nxtk
include/nuttx/nx/nxtk.h
.
apps/graphics/NxWidgets
apps/
repository.
graphics/nxterm
include/nuttx/nx/nxterm.h
.
Appendix B NX Configuration Options |
CONFIG_NX
CONFIG_NX_RAMBACKED
The advantage of this option is that the application that manages window will no longer receive redraw() callbacks. Those calls normally occur, for example, when a window "above" moves exposing a portion of the window below. If this option is selected, then the system will redraw the exposed portion of the window from the backup framebuffer without intervention of the window applications. This greatly reduces the complexity of the application and performance of the window at the expense of increased memory usage.
An exception is the case when the window is resized to a wider and/or taller size. In that case, the redraw callback will till occur. It is necessary in that case to provide new graphic content for the extended window area.
Redraw requests in other cases are also suppressed: Changes to window position, size, etc.
CONFIG_NX_NPLANES
:
CONFIG_NX_DISABLE_1BPP
, CONFIG_NX_DISABLE_2BPP
,
CONFIG_NX_DISABLE_4BPP
, CONFIG_NX_DISABLE_8BPP
CONFIG_NX_DISABLE_16BPP
, CONFIG_NX_DISABLE_24BPP
, and
CONFIG_NX_DISABLE_32BPP
:
CONFIG_NX_PACKEDMSFIRST
:
CONFIG_NX_LCDDRIVER
:
include/nuttx/video/fb.h
).
If this option is defined, NX will build to use an LCD driver (see include/nuttx/lcd/lcd.h
).
CONFIG_NX_ANTIALIASING
:
CONFIG_NX_XYINPUT
:
CONFIG_NX_KBD
:
CONFIG_NX_WRITEONLY
:
CONFIG_NX_LCDDRIVER
and CONFIG_LCD_NOGETRUN
are defined.
CONFIG_NX_BLOCKING
nx_eventhandler()
will not return until a message is received and processed.
CONFIG_NX_MXSERVERMSGS
and CONFIG_NX_MXCLIENTMSGS
CONFIG_PREALLOC_MQ_MSGS
controls how many
messages are pre-allocated).
CONFIG_NXTK_BORDERWIDTH
:
CONFIG_NXTK_BORDERCOLOR1
, CONFIG_NXTK_BORDERCOLOR2
, and CONFIG_NXTK_BORDERCOLOR3
:
CONFIG_NXTK_BORDERCOLOR2
CONFIG_NXTK_BORDERCOLOR3
CONFIG_NXTK_AUTORAISE
:
CONFIG_NXFONTS_CHARBITS
:
CONFIG_NXFONT_SANS17X22
:
ID FONTID_SANS17X22
== 14).
CONFIG_NXFONT_SANS20X26
:
ID FONTID_SANS20X26
== 15).
CONFIG_NXFONT_SANS23X27
:
ID FONTID_SANS23X27
== 1).
CONFIG_NXFONT_SANS22X29
:
ID FONTID_SANS22X29
== 2).
CONFIG_NXFONT_SANS28X37
:
ID FONTID_SANS28X37
== 3).
CONFIG_NXFONT_SANS39X48
:
ID FONTID_SANS39X48
== 4).
CONFIG_NXFONT_SANS17X23B
:
ID FONTID_SANS17X23B
== 16).
CONFIG_NXFONT_SANS20X27B
:
ID FONTID_SANS20X27B
== 17).
CONFIG_NXFONT_SANS22X29B
:
FONTID_SANS22X29B
== 5).
CONFIG_NXFONT_SANS28X37B
:
FONTID_SANS28X37B
== 6).
CONFIG_NXFONT_SANS40X49B
:
FONTID_SANS40X49B
== 7).
CONFIG_NXFONT_SERIF22X29
:
FONTID_SERIF22X29
== 8).
CONFIG_NXFONT_SERIF29X37
:
FONTID_SERIF29X37
== 9).
CONFIG_NXFONT_SERIF38X48
:
FONTID_SERIF38X48
== 10).
CONFIG_NXFONT_SERIF22X28B
:
FONTID_SERIF22X28B
== 11).
CONFIG_NXFONT_SERIF27X38B
:
FONTID_SERIF27X38B
== 12).
CONFIG_NXFONT_SERIF38X49B
:
FONTID_SERIF38X49B
== 13).
General NxTerm settings.
CONFIG_NXTERM
:
NxTerm output text/graphics options:
CONFIG_NXTERM_BPP
:
CONFIG_NX_DISABLE_*BPP
)
CONFIG_NXTERM_CURSORCHAR
:
CONFIG_NXTERM_MXCHARS
:
CONFIG_NXTERM_CACHESIZE
:
CONFIG_NXTERM_CACHESIZE
setting will control the size of the font cache (in number of glyphs).
Only that number of the most recently used glyphs will be retained.
Default: 16.
NOTE: There can still be a race condition between the NxTerm driver and the NX task. If you every see character corruption (especially when printing a lot of data or scrolling), then increasing the value ofCONFIG_NXTERM_CACHESIZE
is something that you should try. Alternatively, you can reduce the size ofCONFIG_MQ_MAXMSGSIZE
which will force NxTerm task to pace the server task.CONFIG_NXTERM_CACHESIZE
should be larger thanCONFIG_MQ_MAXMSGSIZE
in any event.
CONFIG_NXTERM_LINESEPARATION
:
CONFIG_NXTERM_NOWRAP
:
NxTerm input options:
CONFIG_NXTERM_NXKBDIN
:
/dev/console
).
If this option is set, then the interfacenxterm_kdbin()
is enabled.
That interface may be driven by window callback functions so that keyboard input only goes to the top window.
CONFIG_NXTERM_KBDBUFSIZE
:
CONFIG_NXTERM_NXKBDIN
is enabled, then this value may be used to
define the size of the per-window keyboard input buffer. Default: 16
CONFIG_NXTERM_NPOLLWAITERS
:
Appendix C Installing New Fonts |
The BDF Font Converter.
There is a tool called bdf-converter in the directory tools/.
.
The bdf-converter program be used to convert fonts in Bitmap Distribution Format (BDF) into fonts that can be used in the NX graphics system.
The BDF format most well known as a font format traditionally used for X-11 bitmap fonts.
A Note about Font Copyrights: My understanding is that the underlying bitmap font data for traditional fonts cannot be copyrighted (the same is not true for scalable fonts). This is because a copyright covers only the form of delivery of the font and not the underlying font content and, at least for the traditional typefaces, the underlying font designs are ancient. There could be issues, however, if you convert from modern, trademarked images. However, remember that I am a programmer not an attorney and that my knowledge of font copyright issues is limited to what I glean by Googling.
Font Installation Steps, Below are general instructions for creating and installing a new font in the NX graphic system. The first two steps only apply if you are using the BDF font converter program.
Locate a font in BDF format. There are many good BDF bitmap fonts bundled with X-11. See this link, as an example,
Use the bdf-converter program to convert the BDF font to the NuttX font format.
This will result in a C header file containing definitions.
That header file should be installed at, for example, graphics/nxfonts/nxfonts_myfont.h
.
The remaining steps apply however you managed to create the NuttX C font header file.
After you have your C font header file, the next thing to do is to create a new NuttX configuration variable to select the font.
For example, suppose you define the following variable: CONFIG_NXFONT_MYFONT
.
Then you would need to:
Define CONFIG_NXFONT_MYFONT=y
in your NuttX configuration file.
A font ID number has to be assigned for each new font.
The font IDs are defined in the file include/nuttx/nx/nxfonts.h
.
Those definitions have to be extended to support your new font.
Look at how the font ID enabled by CONFIG_NXFONT_SANS23X27
is defined and add an ID for yournew font in a similar fashion:
include/nuttx/nx/nxfonts.h
. Add you new font as a possible system default font:
#if defined(CONFIG_NXFONT_SANS23X27) # define NXFONT_DEFAULT FONTID_SANS23X27 #elif defined(CONFIG_NXFONT_MYFONT) # define NXFONT_DEFAULT FONTID_MYFONT #endif
Then define the actual font ID. Make sure that the font ID value is unique:
enum nx_fontid_e { FONTID_DEFAULT = 0 /* The default font */ #ifdef CONFIG_NXFONT_SANS23X27 , FONTID_SANS23X27 = 1 /* The 23x27 sans serif font */ #endif #ifdef CONFIG_NXFONT_MYFONT , FONTID_MYFONT = 2 /* My shiny, new font */ #endif ...
New Add the font to the NX build system. There are several files that you have to modify to do this. Look how the build system uses the font CONFIG_NXFONT_SANS23X27 for examaples:
nuttx/graphics/Makefile
.
This file needs logic to auto-generate a C source file from the header file that you generated with the bdf-converter program.
Notice NXFONTS_FONTID=2
; this must be set to the same font ID value that you defined in the include/nuttx/nx/nxfonts.h
file.
genfontsources: ifeq ($(CONFIG_NXFONT_SANS23X27),y) @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=1 EXTRADEFINES=$(EXTRADEFINES) endif ifeq ($(CONFIG_NXFONT_MYFONT),y) @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=2 EXTRADEFINES=$(EXTRADEFINES) endif
nuttx/graphics/nxfonts/Make.defs
.
Set the make variable NXFSET_CSRCS
.
NXFSET_CSRCS
determines the name of the font C file to build when NXFONTS_FONTID=2
:
ifeq ($(CONFIG_NXFONT_SANS23X27),y) NXFSET_CSRCS += nxfonts_bitmaps_sans23x27.c endif ifeq ($(CONFIG_NXFONT_MYFONT),y) NXFSET_CSRCS += nxfonts_bitmaps_myfont.c endif
nuttx/graphics/nxfonts/Makefile.sources
.
This is the Makefile used in step 5 that will actually generate the font C file.
So, given your NXFONTS_FONTID=2, it needs to determine a prefix to use for auto-generated variable and function names and (again) the name of the autogenerated file to create (this must be the same name that was used in nuttx/graphics/nxfonts/Make.defs
):
ifeq ($(NXFONTS_FONTID),1) NXFONTS_PREFIX := g_sans23x27_ GEN_CSRC = nxfonts_bitmaps_sans23x27.c endif ifeq ($(NXFONTS_FONTID),2) NXFONTS_PREFIX := g_myfont_ GEN_CSRC = nxfonts_bitmaps_myfont.c endif
graphics/nxfonts/nxfonts_bitmaps.c
.
This is the file that contains the generic font structures.
It is used as a "template&qout; file by nuttx/graphics/nxfonts/Makefile.sources
to create your customized font data set at build time.
#if NXFONTS_FONTID == 1 # include "nxfonts_sans23x27.h" #elif NXFONTS_FONTID == 2 # include "nxfonts_myfont.h" #else # error "No font ID specified" #endif
Where nxfonts_myfont.h
is the NuttX font file that we generated in
step 2 using the bdf-converter tool.
graphics/nxfonts/nxfonts_getfont.c
.
Finally, we need to extend the logic that does the run-time font lookups so that can find our new font.
The lookup function is NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid)
.
Note that the lookup is based on the font ID that was defined in step 4.
The new font information needs to be added to data structures used by that function:
#ifdef CONFIG_NXFONT_SANS23X27 extern const struct nx_fontpackage_s g_sans23x27_package; #endif #ifdef CONFIG_NXFONT_MYFONT extern const struct nx_fontpackage_s g_myfont_package; #endif static FAR const struct nx_fontpackage_s *g_fontpackages[] = { #ifdef CONFIG_NXFONT_SANS23X27 &g_sans23x27_package, #endif #ifdef CONFIG_NXFONT_MYFONT &g_myfont_package, #endif NULL };
Appendix D NX Test Coverage |
apps/examples/nx
.
The primary test tool for debugging NX resides at apps/examples/nx
.
Building apps/examples/nx
.
NX testing was performed using apps/examples/nx
with the
Linux/Cygwin-based NuttX simulator.
Configuration files for building this test can be found in boards/sim/sim/sim/configs/nx
and boards/sim/sim/sim/configs/nx11
.
There are two alternative configurations for building the simulation:
boards/sim/sim/sim/configs/nx/defconfig
.
This default configuration exercises the NX logic a 8 BPP but provides no visual feedback.
In this configuration, a very simple, simulated framebuffer driver is used that is
based upon a simple region of memory posing as video memory.
That default configuration can be built as follows:
tools/configure.sh sim:nx make ./nuttx
The preferred configuration is at boards/sim/sim/sim/configs/nx11/defconfig
.
This configuration extends the test with a simulated framebuffer driver
that uses an X window as a framebuffer.
This is a superior test configuration because the X window appears at your desktop
and you can see the NX output.
This preferred configuration can be built as follows:
tools/configure sim:nx11 make ./nuttx
Update: The sim target has suffered some bit-rot over the years and so the following caveats need to be added:
The X target builds under recent Cygwin configurations, but does not execute.
(It fails inside of XOpenDisplay()
.
The X target does not build under current (9.09) Ubuntu distributions. I needed to make the following changes:
The build will also fail to locate the X header files unless you install an X11 development package.
The sim target itself is broken under 64-bit Linux. This is because the sim target is based upon some assembly language setjmp/longjmp logic that only works on 32-bit systems.
NOTE: There is a workaround in this case:
You can build for 32-bit execution on a 64-bit machine by adding -m3
to the CFLAGS
and -m32 -m elf_i386
to the LDFLAGS
.
The configuration/build system will do this for you;
you simply need to select CONFIG_SIM_M32=y
in your configuration file.
Refer to the readme file in sim configuration README.txt file for additional information.
Test Coverage.
At present, apps/examples/nx
t only exercises a subset of NX;
the remainder is essentially untested.
The following table describes the testing performed on each NX API:
Function | Special Setup/Notes | Verified |
---|---|---|
nxgl_rgb2yuv() |
NO | |
nxgl_yuv2rgb() |
NO | |
nxgl_rectcopy() |
YES | |
nxgl_rectoffset() |
YES | |
nxgl_vectoradd() |
YES | |
nxgl_vectorsubtract() |
YES | |
nxgl_rectintersect() |
YES | |
nxgl_rectunion() |
YES | |
nxgl_nonintersecting() |
YES | |
nxgl_rectoverlap() |
YES | |
nxgl_rectinside() |
YES | |
nxgl_rectsize() |
YES | |
nxgl_nullrect() |
YES | |
nxgl_runoffset() |
Verified by apps/examples/nxlines .
|
YES |
nxgl_runcopy() |
NO | |
nxgl_trapoffset() |
Verified by apps/examples/nxlines .
|
YES |
nxgl_trapcopy() |
Verified by apps/examples/nxlines .
|
YES |
nxgl_colorcopy |
YES | |
nxgl_splitline |
Verified using apps/examples/nxlines .
Generally works well, but has some accuracy/overflow problems wide lines
that are nearly horizontal.
There is a "fudge factor" that seems to eliminate the problem,
but there could still be issues in some configurations.
|
YES |
nxgl_circlepts |
Verified by apps/examples/nxlines .
|
YES |
nxgl_circletraps |
Verified by apps/examples/nxlines .
|
YES |
Function | Special Setup/Notes | Verified |
---|---|---|
redraw() |
YES | |
position() |
YES | |
mousein() |
YES | |
kbdin() |
YES |
Function | Special Setup/Notes | Verified |
---|---|---|
nx_runinstance() |
YES | |
nx_connectinstance() |
YES | |
nx_disconnect() |
YES | |
nx_eventhandler() |
YES | |
nx_eventnotify() |
This is not used in the current version of apps/examples/nx ,
was tested in a previous version) |
NO |
nx_openwindow() |
Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the
<NuttX-Directory>/.config file |
YES |
nx_closewindow() |
Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the
<NuttX-Directory>/.config file |
YES |
nx_requestbkgd() |
Verified by apps/examples/nxtext and apps/examples/nxhello .
|
YES |
nx_releasebkgd() |
Verified by apps/examples/nxtext and apps/examples/nxhello .
|
YES |
nx_getposition() |
NO | |
nx_setposition() |
Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the
<NuttX-Directory>/.config file |
YES |
nx_setsize() |
Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the
<NuttX-Directory>/.config file |
YES |
nx_raise() |
Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the
<NuttX-Directory>/.config file |
YES |
nx_lower() |
Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the
<NuttX-Directory>/.config file |
YES |
nx_modal() |
NO | |
nx_setvisibility() |
Exercized using Twm4Nx | YES, Informally |
nx_ishidden() |
Exercized using Twm4Nx | YES, Informally |
nx_fill() |
Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the
<NuttX-Directory>/.config file |
YES |
nx_getrectangle() |
YES | |
nx_filltrapezoid() |
Verified by apps/examples/nxlines .
|
YES |
nx_drawline() |
Verified by apps/examples/nxlines .
|
YES |
nx_drawcircle() |
Verified by apps/examples/nxlines .
|
YES |
nx_fillcircle() |
Verified by apps/examples/nxlines .
|
YES |
nx_setbgcolor() |
YES | |
nx_move() |
Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the
<NuttX-Directory>/.config file |
YES |
nx_bitmap() |
Change to CONFIG_EXAMPLES_NX_RAWWINDOWS=y in the
<NuttX-Directory>/.config file. |
YES |
nx_kbdin() |
YES | |
nx_mousein() |
YES |
Function | Special Setup/Notes | Verified |
---|---|---|
nxtk_openwindow() |
YES | |
nxtk_closewindow() |
YES | |
nxtk_getposition() |
NO | |
nxtk_setposition() |
YES | |
nxtk_setsize() |
YES | |
nxtk_raise() |
YES | |
nxtk_lower() |
YES | |
nxtk_modal() |
NO | |
nxtk_setvisibility() |
Exercized using Twm4Nx | YES, informally |
nxtk_ishidden() |
Exercized using Twm4Nx | YES, informally |
nxtk_fillwindow() |
YES | |
nxtk_getwindow() |
NO | |
nxtk_filltrapwindow() |
NO | |
nxtk_drawlinewindow() |
YES | |
nxtk_drawcirclewindow() |
YES | |
nxtk_fillcirclewindow() |
YES | |
nxtk_movewindow() |
NO | |
nxtk_bitmapwindow() |
YES | |
nxtk_opentoolbar() |
YES | |
nxtk_closetoolbar() |
YES | |
nxtk_filltoolbar() |
YES | |
nxtk_gettoolbar() |
NO | |
nxtk_filltraptoolbar() |
NO | |
nxtk_drawlinetoolbar() |
NO | |
nxtk_drawcircletoolbar() |
NO | |
nxtk_fillcircletoolbar() |
NO | |
nxtk_movetoolbar() |
NO | |
nxtk_bitmaptoolbar() |
NO |
Function | Special Setup/Notes | Verified |
---|---|---|
nxf_getfonthandle() |
YES | |
nxf_getfontset() |
YES | |
nxf_getbitmap() |
YES | |
nxf_convert_2bpp() |
NO | |
nxf_convert_4bpp() |
NO | |
nxf_convert_8bpp() |
Use defconfig when building. |
YES |
nxf_convert_16bpp() |
YES | |
nxf_convert_24bpp() |
NO | |
nxf_convert_32bpp() |
YES |