2020-07-21 00:18:26 +02:00
|
|
|
========
|
|
|
|
Appendix
|
|
|
|
========
|
|
|
|
|
|
|
|
``graphics/`` Directory Structure
|
|
|
|
=================================
|
|
|
|
|
|
|
|
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``.
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``libnx/nx``
|
2020-07-21 00:18:26 +02:00
|
|
|
Common callable interfaces that are, logically, part of both nxmu and
|
|
|
|
nxsu.
|
2020-10-18 18:48:44 +02:00
|
|
|
``graphics/nxglib`` and ``libnx/nxglib``
|
2020-07-21 00:18:26 +02:00
|
|
|
The NuttX tiny graphics library. The directory contains generic
|
|
|
|
utilities support operations on primitive graphics objects and logic
|
|
|
|
to rasterize directly into a framebuffer or through an LCD driver
|
|
|
|
interface. It has no concept of windows (other than the one,
|
|
|
|
framebuffer or LCD window).
|
2020-10-18 18:48:44 +02:00
|
|
|
``graphics/nxbe``
|
2020-07-21 00:18:26 +02:00
|
|
|
This is the *back-end* of a tiny windowing system. It can be used
|
|
|
|
with either of two front-ends to complete a windowing system (see
|
|
|
|
``nxmu`` and ``nxsu`` below). It contains most of the important
|
|
|
|
window management logic: clipping, window controls, window drawing,
|
|
|
|
etc.
|
2020-10-18 18:48:44 +02:00
|
|
|
``graphics/nxmu`` and ``libnx/nxmu``
|
2020-07-21 00:18:26 +02:00
|
|
|
This is the NX multi user *front end*. When combined with the generic
|
|
|
|
*back-end* (``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.
|
2020-10-18 18:48:44 +02:00
|
|
|
``libnx/nxfonts``
|
2020-07-21 00:18:26 +02:00
|
|
|
This is where the NXFONTS implementation resides. This is a
|
|
|
|
relatively low-level set of charset set/glyph management APIs. See
|
|
|
|
``include/nuttx/nx/nxfonts.h``.
|
2020-10-18 18:48:44 +02:00
|
|
|
``libnx/nxtk``
|
2020-07-21 00:18:26 +02:00
|
|
|
This is where the NXTOOLKIT implementation resides. This toolkit is
|
|
|
|
built on top of NX and works with the multi-user NX front-end. See
|
|
|
|
``include/nuttx/nx/nxtk.h``.
|
2020-10-18 18:48:44 +02:00
|
|
|
``apps/graphics/NxWidgets``
|
2020-10-20 10:40:45 +02:00
|
|
|
The :ref:`NxWidgets <nxwidgets>` code is provided as a separate
|
2020-07-21 00:18:26 +02:00
|
|
|
package provided in the ``apps/`` repository.
|
2020-10-18 18:48:44 +02:00
|
|
|
``graphics/nxterm``
|
2020-07-21 00:18:26 +02:00
|
|
|
The NxTerm driver is built on top of NX and works with the multi-user
|
|
|
|
NX front-end. See ``include/nuttx/nx/nxterm.h``.
|
|
|
|
|
|
|
|
NX Configuration Options
|
|
|
|
========================
|
|
|
|
|
|
|
|
General Configuration Settings
|
|
|
|
------------------------------
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX``
|
2020-07-21 00:18:26 +02:00
|
|
|
Enables overall support for graphics library and NX
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX_RAMBACKED``
|
2020-07-21 00:18:26 +02:00
|
|
|
Enables RAM backed window support. If this option is selected, then
|
|
|
|
windows may be optionally created with a RAM framebuffer backing up
|
|
|
|
the window content. Rending into the window will result in rending
|
|
|
|
into the backup framebuffer, then updating the physical display from
|
|
|
|
the framebuffer.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
NXGL Configuration Settings
|
|
|
|
---------------------------
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX_NPLANES``:
|
2020-07-21 00:18:26 +02:00
|
|
|
Some YUV color formats requires support for multiple planes, one for
|
|
|
|
each color component. Unless you have such special hardware, this
|
|
|
|
value should be undefined or set to 1.
|
2020-10-18 18:48:44 +02:00
|
|
|
``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``:
|
2020-07-21 00:18:26 +02:00
|
|
|
NX supports a variety of pixel depths. You can save some memory by
|
|
|
|
disabling support for unused color depths.
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX_PACKEDMSFIRST``:
|
2020-07-21 00:18:26 +02:00
|
|
|
If a pixel depth of less than 8-bits is used, then NX needs to know
|
|
|
|
if the pixels pack from the MS to LS or from LS to MS
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX_LCDDRIVER``:
|
2020-07-21 00:18:26 +02:00
|
|
|
By default, NX builds to use a framebuffer driver (see
|
|
|
|
``include/nuttx/video/fb.h``). If this option is defined, NX will
|
|
|
|
build to use an LCD driver (see ``include/nuttx/lcd/lcd.h``).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX_ANTIALIASING``:
|
2020-07-21 00:18:26 +02:00
|
|
|
Enable support for anti-aliasing when rendering lines as various
|
|
|
|
orientations. This option is only available for use with frame buffer
|
|
|
|
drivers and only with 16-, 24-, or 32-bit RGB color formats.
|
|
|
|
|
|
|
|
Configuration Settings
|
|
|
|
----------------------
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX_XYINPUT``:
|
2020-07-21 00:18:26 +02:00
|
|
|
Build in support for an X/Y input such as a mouse or a touscreen.
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX_KBD``:
|
2020-07-21 00:18:26 +02:00
|
|
|
Build in support of keypad/keyboard input.
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX_WRITEONLY``:
|
2020-07-21 00:18:26 +02:00
|
|
|
Define if the underlying graphics device does not support read
|
|
|
|
operations. Automatically defined if ``CONFIG_NX_LCDDRIVER`` and
|
|
|
|
``CONFIG_LCD_NOGETRUN`` are defined.
|
|
|
|
|
|
|
|
NX Server Configuration Settings
|
|
|
|
--------------------------------
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX_BLOCKING``
|
2020-07-21 00:18:26 +02:00
|
|
|
Open the client message queues in blocking mode. In this case,
|
|
|
|
``nx_eventhandler()`` will not return until a message is received and
|
|
|
|
processed.
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NX_MXSERVERMSGS`` and ``CONFIG_NX_MXCLIENTMSGS``
|
2020-07-21 00:18:26 +02:00
|
|
|
Specifies the maximum number of messages that can fit in the message
|
|
|
|
queues. No additional resources are allocated, but this can be set to
|
|
|
|
prevent flooding of the client or server with too many messages
|
|
|
|
(``CONFIG_PREALLOC_MQ_MSGS`` controls how many messages are
|
|
|
|
pre-allocated).
|
|
|
|
|
|
|
|
NXTK Configuration Settings
|
|
|
|
---------------------------
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTK_BORDERWIDTH``:
|
2020-07-21 00:18:26 +02:00
|
|
|
Specifies the width of the border (in pixels) used with framed
|
|
|
|
windows. The default is 4.
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTK_BORDERCOLOR1``, ``CONFIG_NXTK_BORDERCOLOR2``, and ``CONFIG_NXTK_BORDERCOLOR3``:
|
2020-07-21 00:18:26 +02:00
|
|
|
Specify the colors of the border used with framed windows.
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTK_BORDERCOLOR2``
|
2020-07-21 00:18:26 +02:00
|
|
|
The shadow side color and so is normally darker.
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTK_BORDERCOLOR3``
|
2020-07-21 00:18:26 +02:00
|
|
|
The shiny side color and so is normally brighter. The default is
|
|
|
|
medium, dark, and light grey, respectively
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTK_AUTORAISE``:
|
2020-07-21 00:18:26 +02:00
|
|
|
If set, a window will be raised to the top if the mouse position is
|
|
|
|
over a visible portion of the window. Default: A mouse button must be
|
|
|
|
clicked over a visible portion of the window.
|
|
|
|
|
|
|
|
NXFONTS Configuration Settings
|
|
|
|
------------------------------
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONTS_CHARBITS``:
|
2020-07-21 00:18:26 +02:00
|
|
|
The number of bits in the character set. Current options are only 7
|
|
|
|
and 8. The default is 7.
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS17X22``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a tiny, 17x22 san serif font (font
|
|
|
|
``ID FONTID_SANS17X22`` == 14).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS20X26``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a tiny, 20x26 san serif font (font
|
|
|
|
``ID FONTID_SANS20X26`` == 15).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS23X27``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a tiny, 23x27 san serif font (font
|
|
|
|
``ID FONTID_SANS23X27`` == 1).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS22X29``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a small, 22x29 san serif font (font
|
|
|
|
``ID FONTID_SANS22X29`` == 2).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS28X37``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a medium, 28x37 san serif font (font
|
|
|
|
``ID FONTID_SANS28X37`` == 3).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS39X48``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a large, 39x48 san serif font (font
|
|
|
|
``ID FONTID_SANS39X48`` == 4).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS17X23B``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a tiny, 17x23 san serif bold font
|
|
|
|
(font ``ID FONTID_SANS17X23B`` == 16).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS20X27B``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a tiny, 20x27 san serif bold font
|
|
|
|
(font ``ID FONTID_SANS20X27B`` == 17).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS22X29B``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a small, 22x29 san serif bold font
|
|
|
|
(font ID ``FONTID_SANS22X29B`` == 5).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS28X37B``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a medium, 28x37 san serif bold font
|
|
|
|
(font ID ``FONTID_SANS28X37B`` == 6).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SANS40X49B``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a large, 40x49 san serif bold font
|
|
|
|
(font ID ``FONTID_SANS40X49B`` == 7).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SERIF22X29``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a small, 22x29 font (with serifs)
|
|
|
|
(font ID ``FONTID_SERIF22X29`` == 8).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SERIF29X37``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a medium, 29x37 font (with serifs)
|
|
|
|
(font ID ``FONTID_SERIF29X37`` == 9).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SERIF38X48``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a large, 38x48 font (with serifs)
|
|
|
|
(font ID ``FONTID_SERIF38X48`` == 10).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SERIF22X28B``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a small, 27x38 bold font (with
|
|
|
|
serifs) (font ID ``FONTID_SERIF22X28B`` == 11).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SERIF27X38B``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a medium, 27x38 bold font (with
|
|
|
|
serifs) (font ID ``FONTID_SERIF27X38B`` == 12).
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXFONT_SERIF38X49B``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This option enables support for a large, 38x49 bold font (with
|
|
|
|
serifs) (font ID ``FONTID_SERIF38X49B`` == 13).
|
|
|
|
|
|
|
|
NxTerm Configuration Settings
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
General NxTerm settings.
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTERM``:
|
2020-07-21 00:18:26 +02:00
|
|
|
Enables building of the NxTerm driver.
|
|
|
|
|
|
|
|
NxTerm output text/graphics options:
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTERM_BPP``:
|
2020-07-21 00:18:26 +02:00
|
|
|
Currently, NxTerm supports only a single pixel depth. This
|
|
|
|
configuration setting must be provided to support that single pixel
|
|
|
|
depth. Default: The smallest enabled pixel depth. (see
|
|
|
|
``CONFIG_NX_DISABLE_*BPP``)
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTERM_CURSORCHAR``:
|
2020-07-21 00:18:26 +02:00
|
|
|
The bitmap code to use as the cursor. Default '_'
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTERM_MXCHARS``:
|
2020-07-21 00:18:26 +02:00
|
|
|
NxTerm needs to remember every character written to the console so
|
|
|
|
that it can redraw the window. This setting determines the size of
|
|
|
|
some internal memory allocations used to hold the character data.
|
|
|
|
Default: 128.
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTERM_CACHESIZE``:
|
2020-07-21 00:18:26 +02:00
|
|
|
NxTerm supports caching of rendered fonts. This font caching is
|
|
|
|
required for two reasons: (1) First, it improves text performance,
|
|
|
|
but more importantly (2) it preserves the font memory. Since the NX
|
|
|
|
server runs on a separate server thread, it requires that the
|
|
|
|
rendered font memory persist until the server has a chance to render
|
|
|
|
the font. Unfortunately, the font cache would be quite large if all
|
|
|
|
fonts were saved. The ``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 of ``CONFIG_NXTERM_CACHESIZE`` is something
|
|
|
|
that you should try. Alternatively, you can reduce the size of
|
|
|
|
``CONFIG_MQ_MAXMSGSIZE`` which will force NxTerm task to pace the
|
|
|
|
server task. ``CONFIG_NXTERM_CACHESIZE`` should be larger than
|
|
|
|
``CONFIG_MQ_MAXMSGSIZE`` in any event.
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTERM_LINESEPARATION``:
|
2020-07-21 00:18:26 +02:00
|
|
|
This the space (in rows) between each row of test. Default: 0
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTERM_NOWRAP``:
|
2020-07-21 00:18:26 +02:00
|
|
|
By default, lines will wrap when the test reaches the right hand side
|
|
|
|
of the window. This setting can be defining to change this behavior
|
|
|
|
so that the text is simply truncated until a new line is encountered.
|
|
|
|
|
|
|
|
NxTerm input options:
|
|
|
|
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTERM_NXKBDIN``:
|
2020-07-21 00:18:26 +02:00
|
|
|
Take input from the NX keyboard input callback. By default, keyboard
|
|
|
|
input is taken from stdin (``/dev/console``). If this option is set,
|
|
|
|
then the interface\ ``nxterm_kdbin()`` is enabled. That interface may
|
|
|
|
be driven by window callback functions so that keyboard input *only*
|
|
|
|
goes to the top window.
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTERM_KBDBUFSIZE``:
|
2020-07-21 00:18:26 +02:00
|
|
|
If ``CONFIG_NXTERM_NXKBDIN`` is enabled, then this value may be used
|
|
|
|
to define the size of the per-window keyboard input buffer. Default:
|
|
|
|
16
|
2020-10-18 18:48:44 +02:00
|
|
|
``CONFIG_NXTERM_NPOLLWAITERS``:
|
2020-07-21 00:18:26 +02:00
|
|
|
The number of threads that can be waiting for read data available.
|
|
|
|
Default: 4
|
|
|
|
|
|
|
|
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 <http://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html>`__, 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:
|
|
|
|
|
|
|
|
3. 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:
|
|
|
|
|
|
|
|
4. ``include/nuttx/nx/nxfonts.h``. Add you new font as a possible
|
|
|
|
system default font:
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
.. code-block:: c
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
#if defined(CONFIG_NXFONT_SANS23X27)
|
|
|
|
# define NXFONT_DEFAULT FONTID_SANS23X27
|
|
|
|
#elif defined(CONFIG_NXFONT_MYFONT)
|
|
|
|
# define NXFONT_DEFAULT FONTID_MYFONT
|
|
|
|
#endif
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
Then define the actual font ID. Make sure that the font ID value is
|
|
|
|
unique:
|
|
|
|
|
|
|
|
.. code-block:: c
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
#if defined(CONFIG_NXFONT_SANS23X27)
|
|
|
|
# define NXFONT_DEFAULT FONTID_SANS23X27
|
|
|
|
#elif defined(CONFIG_NXFONT_MYFONT)
|
|
|
|
# define NXFONT_DEFAULT FONTID_MYFONT
|
2020-10-18 18:48:44 +02:00
|
|
|
#endif
|
2020-07-21 00:18:26 +02:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
5. ``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.
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
.. code-block:: makefile
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
genfontsources:
|
|
|
|
ifeq ($(CONFIG_NXFONT_SANS23X27),y)
|
2020-09-14 18:53:37 +02:00
|
|
|
@$(MAKE) -C nxfonts -f Makefile.sources NXFONTS_FONTID=1 EXTRAFLAGS=$(EXTRAFLAGS)
|
2020-07-21 00:18:26 +02:00
|
|
|
endif
|
|
|
|
ifeq ($(CONFIG_NXFONT_MYFONT),y)
|
2020-09-14 18:53:37 +02:00
|
|
|
@$(MAKE) -C nxfonts -f Makefile.sources NXFONTS_FONTID=2 EXTRAFLAGS=$(EXTRAFLAGS)
|
2020-10-18 18:48:44 +02:00
|
|
|
endif
|
2020-07-21 00:18:26 +02:00
|
|
|
|
|
|
|
6. ``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``:
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
.. code-block:: makefile
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
ifeq ($(CONFIG_NXFONT_SANS23X27),y)
|
|
|
|
NXFSET_CSRCS += nxfonts_bitmaps_sans23x27.c
|
|
|
|
endif
|
|
|
|
ifeq ($(CONFIG_NXFONT_MYFONT),y)
|
|
|
|
NXFSET_CSRCS += nxfonts_bitmaps_myfont.c
|
2020-10-18 18:48:44 +02:00
|
|
|
endif
|
2020-07-21 00:18:26 +02:00
|
|
|
|
|
|
|
7. ``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``):
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
.. code-block:: makefile
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
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
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
8. ``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.
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
.. code-block:: c
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
#if NXFONTS_FONTID == 1
|
|
|
|
# include "nxfonts_sans23x27.h"
|
|
|
|
#elif NXFONTS_FONTID == 2
|
|
|
|
# include "nxfonts_myfont.h"
|
|
|
|
#else
|
|
|
|
# error "No font ID specified"
|
2020-10-18 18:48:44 +02:00
|
|
|
#endif
|
2020-07-21 00:18:26 +02:00
|
|
|
|
|
|
|
Where ``nxfonts_myfont.h`` is the NuttX font file that we generated
|
|
|
|
in step 2 using the *bdf-converter* tool.
|
|
|
|
|
|
|
|
9. ``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)`` <#nxfgetfonthandle>`__.
|
|
|
|
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:
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
.. code-block:: c
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
#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
|
|
|
|
};
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
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:
|
|
|
|
|
|
|
|
#. The configuration using the configuration file at
|
|
|
|
``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::
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
tools/configure.sh sim:nx
|
|
|
|
make
|
2020-10-18 18:48:44 +02:00
|
|
|
./nuttx
|
2020-07-21 00:18:26 +02:00
|
|
|
|
|
|
|
#. 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::
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
tools/configure sim:nx11
|
|
|
|
make
|
2020-10-18 18:48:44 +02:00
|
|
|
./nuttx
|
2020-07-21 00:18:26 +02:00
|
|
|
|
|
|
|
*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.
|
|
|
|
|
|
|
|
- Refer to the readme file in sim configuration
|
2022-11-22 19:59:48 +01:00
|
|
|
`README.txt <https://github.com/apache/nuttx/blob/master/boards/sim/sim/sim/README.txt>`__
|
2020-07-21 00:18:26 +02:00
|
|
|
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:
|
|
|
|
|
|
|
|
NXGLIB API Test Coverage
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
================================ ==================================== ========
|
|
|
|
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 YES
|
|
|
|
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
|
2020-10-18 18:48:44 +02:00
|
|
|
configurations.
|
2020-07-21 00:18:26 +02:00
|
|
|
``nxgl_circlepts`` Verified by apps/examples/nxlines. YES
|
|
|
|
``nxgl_circletraps`` Verified by apps/examples/nxlines. YES
|
|
|
|
================================ ==================================== ========
|
|
|
|
|
|
|
|
NX Server Callbacks Test Coverage
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
============== ==================== ========
|
|
|
|
Function Special Setup/Notes Verified
|
|
|
|
============== ==================== ========
|
|
|
|
``redraw()`` . YES
|
|
|
|
``position()`` . YES
|
|
|
|
``mousein()`` . YES
|
|
|
|
``kbdin()`` . YES
|
|
|
|
============== ==================== ========
|
|
|
|
|
|
|
|
NX API Test Coverage
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
========================= =============================================================== ========
|
|
|
|
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, NO
|
|
|
|
was tested in a previous version)
|
|
|
|
``nx_openwindow()`` Change to ``CONFIG_EXAMPLES_NX_RAWWINDOWS=y`` in the YES
|
|
|
|
``<NuttX-Directory>/.config file``
|
|
|
|
``nx_closewindow()`` Change to ``CONFIG_EXAMPLES_NX_RAWWINDOWS=y`` YES
|
2020-10-18 18:48:44 +02:00
|
|
|
in the ``<NuttX-Directory>/.config`` file
|
2020-07-21 00:18:26 +02:00
|
|
|
``nx_requestbkgd()`` Verified by ``apps/examples/nxtext`` and YES
|
2020-10-18 18:48:44 +02:00
|
|
|
``apps/examples/nxhello``.
|
2020-07-21 00:18:26 +02:00
|
|
|
``nx_releasebkgd()`` Verified by ``apps/examples/nxtext`` and YES
|
2020-10-18 18:48:44 +02:00
|
|
|
``apps/examples/nxhello``.
|
2020-07-21 00:18:26 +02:00
|
|
|
``nx_getposition()`` . NO
|
|
|
|
``nx_setposition()`` Change to ``CONFIG_EXAMPLES_NX_RAWWINDOWS=y`` in the YES
|
2020-10-18 18:48:44 +02:00
|
|
|
``<NuttX-Directory>/.config`` file
|
2020-07-21 00:18:26 +02:00
|
|
|
``nx_setsize()`` Change to ``CONFIG_EXAMPLES_NX_RAWWINDOWS=y`` in the YES
|
2020-10-18 18:48:44 +02:00
|
|
|
``<NuttX-Directory>/.config`` file
|
2020-07-21 00:18:26 +02:00
|
|
|
``nx_raise()`` Change to ``CONFIG_EXAMPLES_NX_RAWWINDOWS=y`` in the YES
|
2020-10-18 18:48:44 +02:00
|
|
|
``<NuttX-Directory>/.config`` file
|
2020-07-21 00:18:26 +02:00
|
|
|
``nx_lower()`` Change to ``CONFIG_EXAMPLES_NX_RAWWINDOWS=y`` in the YES
|
2020-10-18 18:48:44 +02:00
|
|
|
``<NuttX-Directory>/.config`` file
|
2020-07-21 00:18:26 +02:00
|
|
|
``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 YES
|
2020-10-18 18:48:44 +02:00
|
|
|
``<NuttX-Directory>/.config`` file
|
2020-07-21 00:18:26 +02:00
|
|
|
``nx_getrectangle()`` . YES
|
|
|
|
``nx_filltrapezoid()`` Verified by ``apps/examples/nxlines``. YES
|
|
|
|
``nx_drawline()`` 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 YES
|
2020-10-18 18:48:44 +02:00
|
|
|
``<NuttX-Directory>/.config`` file
|
2020-07-21 00:18:26 +02:00
|
|
|
``nx_bitmap()`` Change to ``CONFIG_EXAMPLES_NX_RAWWINDOWS=y`` in the YES
|
2020-10-18 18:48:44 +02:00
|
|
|
``<NuttX-Directory>/.config`` file.
|
2020-07-21 00:18:26 +02:00
|
|
|
``nx_kbdin()`` . YES
|
|
|
|
``nx_mousein()`` . YES
|
|
|
|
========================= =============================================================== ========
|
|
|
|
|
|
|
|
NXTK API Test Coverage
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
============================ ========================= ========
|
|
|
|
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
|
|
|
|
============================ ========================= ========
|
|
|
|
|
|
|
|
NXFONTS API Test Coverage
|
|
|
|
-------------------------
|
2020-10-18 18:48:44 +02:00
|
|
|
|
2020-07-21 00:18:26 +02:00
|
|
|
======================== ============================= ========
|
|
|
|
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
|
|
|
|
======================== ============================= ========
|
|
|
|
|