README.txt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. README
  2. ^^^^^^
  3. This directory contains tiny graphics support for NuttX. The contents of this directory
  4. are only build if CONFIG_NX is defined in the NuttX configuration file.
  5. Contents
  6. ^^^^^^^^
  7. Roadmap
  8. Related Header Files
  9. Directories
  10. Installing New Fonts
  11. Configuration Settings
  12. Roadmap
  13. ^^^^^^^
  14. This directory holds NuttX graphic packages. Not all of these packages are implemented
  15. at the present, but here is the longer term roadmap:
  16. NxWidgets - NxWidgets is a higher level, C++, object-oriented library for object-
  17. oriented access to graphics "widgets." NxWidgets is provided as a separate
  18. package. NxWidgets is built on top of the core NuttX graphics subsystem,
  19. but is not a part of the core graphics subystems.
  20. NXTOOLKIT - A set of C graphics tools that provide higher-level window drawing
  21. operations. The toolkit can be used for window-oriented graphics
  22. without NxWidgets and is built on top of NX.
  23. NXFONTS - A set of C graphics tools for present (bitmap) font images.
  24. NX - The tiny NuttX windowing system. This includes both a small-footprint,
  25. single user implementaton (NXSU as described below) and a somewhat
  26. larger multi-user implentation (NXMU as described below). Both
  27. conform to the same APIs as defined in include/nuttx/nx/nx.h and, hence,
  28. are more-or-less interchangable. NX can be used without NxWidgets
  29. and without NXTOOLKIT for raw access to window memory.
  30. NXGLIB - Low level graphics utilities and direct framebuffer rendering logic.
  31. NX is built on top of NXGLIB.
  32. NxConsole - NxConsole is a write-only character device that is built on top of
  33. an NX window. This character device can be used to provide stdout
  34. and stderr and, hence, can provide the output side of NuttX console.
  35. NxConsole is only available when the multi-user NX implementation is
  36. selected (CONFIG_NX_MULTIUSERs).
  37. Related Header Files
  38. ^^^^^^^^^^^^^^^^^^^^
  39. include/nuttx/nx/nxglib.h -- Describes the NXGLIB C interfaces
  40. include/nuttx/nx/nx.h -- Describes the NX C interfaces
  41. include/nuttx/nx/nxtk.h -- Describe the NXTOOLKIT C interfaces
  42. include/nuttx/nx/nxfont.h -- Describe sthe NXFONT C interfaces
  43. Directories
  44. ^^^^^^^^^^^
  45. graphics/nxglib
  46. The NuttX tiny graphics library. The directory contains generic utilities
  47. support operations on primitive graphics objects and logic to rasterize directly
  48. into a framebuffer. It has no concept of windows (other than the one, framebuffer
  49. window).
  50. graphics/nxbe
  51. This is the "back-end" of a tiny windowing system. It can be used with either of
  52. two front-ends to complete a windowing system (see nxmu and nxsu below). It
  53. contains most of the important window management logic: clipping, window controls,
  54. window drawing, etc.
  55. graphics/nxsu
  56. This is the NX single user "front end". When combined with the generic "back-end"
  57. (nxbe), it implements a single thread, single user windowing system. The files
  58. in this directory present the window APIs described in include/nuttx/nx/nx.h. The
  59. single user front-end is selected when CONFIG_NX_MULTIUSER is not defined in the
  60. NuttX configuration file.
  61. graphics/nxmu
  62. This is the NX multi user "front end". When combined with the generic "back-end"
  63. (nxbe), it implements a multi-threaded, multi-user windowing system. The files
  64. in this directory present the window APIs described in include/nuttx/nx/nx.h. The
  65. multi-user front end includes a graphics server that executes on its own thread;
  66. multiple graphics clients then communicate with the server via a POSIX message
  67. queue to serialize window operations from many threads. The multi-user front-end
  68. is selected when CONFIG_NX_MULTIUSER is defined in the NuttX configuration file.
  69. graphics/nxfonts
  70. This is where the NXFONTS implementation resides. This is a relatively low-
  71. level set of charset set/glyph management APIs. See include/nuttx/nx/nxfonts.h
  72. graphics/nxtk
  73. This is where the NXTOOLKIT implementation resides. This toolkit is built on
  74. top of NX and works with either the single-user or multi-user NX version. See
  75. include/nuttx/nx/nxtk.h
  76. nuttx/../NxWidgets
  77. The NxWidgets code is provided as a separate package located outside of the
  78. NuttX source tree (probably at this location).
  79. Installing New Fonts
  80. ^^^^^^^^^^^^^^^^^^^^
  81. There is a tool called bdf-converter in the directory tools/. The bdf-converter
  82. program be used to convert fonts in Bitmap Distribution Format (BDF)
  83. into fonts that can be used in the NX graphics system.
  84. Below are general instructions for creating and installing a new font
  85. in the NX graphic system:
  86. 1. Locate a font in BDF format,
  87. 2. Use the bdf-converter program to convert the BDF font to the NuttX
  88. font format. This will result in a C header file containing
  89. defintions. That header file should be installed at, for example,
  90. graphics/nxfonts/nxfonts_myfont.h.
  91. Create a new NuttX configuration variable. For example, suppose
  92. you define the following variable: CONFIG_NXFONT_MYFONT. Then
  93. you would need to:
  94. 3. Define CONFIG_NXFONT_MYFONT=y in your NuttX configuration file.
  95. A font ID number has to be assigned for each new font. The font ID
  96. is defined in the file include/nuttx/nx/nxfonts.h. Those definitions
  97. have to be extended to support your new font. Look at how the font ID
  98. enabled by CONFIG_NXFONT_SANS23X27 is defined and add an ID for your
  99. new font in a similar fashion:
  100. 4. include/nuttx/nx/nxfonts.h. Add you new font as a possible system
  101. default font:
  102. #if defined(CONFIG_NXFONT_SANS23X27)
  103. # define NXFONT_DEFAULT FONTID_SANS23X27
  104. #elif defined(CONFIG_NXFONT_MYFONT)
  105. # define NXFONT_DEFAULT FONTID_MYFONT
  106. #endif
  107. Then define the actual font ID. Make sure that the font ID value
  108. is unique:
  109. enum nx_fontid_e
  110. {
  111. FONTID_DEFAULT = 0 /* The default font */
  112. #ifdef CONFIG_NXFONT_SANS23X27
  113. , FONTID_SANS23X27 = 1 /* The 23x27 sans serif font */
  114. #endif
  115. #ifdef CONFIG_NXFONT_MYFONT
  116. , FONTID_MYFONT = 2 /* My shiny, new font */
  117. #endif
  118. ...
  119. New Add the font to the NX build system. There are several files that
  120. you have to modify to to this. Look how the build system uses the
  121. font CONFIG_NXFONT_SANS23X27 for examaples:
  122. 5. nuttx/graphics/Makefile. This file needs logic to auto-generate
  123. a C source file from the header file that you generated with the
  124. the bdf-converter program. Notice NXFONTS_FONTID=2; this must be
  125. set to the same font ID value that you defined in the
  126. include/nuttx/nx/nxfonts.h file.
  127. genfontsources:
  128. ifeq ($(CONFIG_NXFONT_SANS23X27),y)
  129. @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=1 EXTRADEFINES=$(EXTRADEFINES)
  130. endif
  131. ifeq ($(CONFIG_NXFONT_MYFONT),y)
  132. @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=2 EXTRADEFINES=$(EXTRADEFINES)
  133. endif
  134. 6. nuttx/graphics/nxfonts/Make.defs. Set the make variable NXFSET_CSRCS.
  135. NXFSET_CSRCS determines the name of the font C file to build when
  136. NXFONTS_FONTID=2:
  137. ifeq ($(CONFIG_NXFONT_SANS23X27),y)
  138. NXFSET_CSRCS += nxfonts_bitmaps_sans23x27.c
  139. endif
  140. ifeq ($(CONFIG_NXFONT_MYFONT),y)
  141. NXFSET_CSRCS += nxfonts_bitmaps_myfont.c
  142. endif
  143. 7. nuttx/graphics/nxfonts/Makefile.sources. This is the Makefile used
  144. in step 5 that will actually generate the font C file. So, given
  145. your NXFONTS_FONTID=2, it needs to determine a prefix to use for
  146. auto-generated variable and function names and (again) the name of
  147. the autogenerated file to create (this must be the same name that
  148. was used in nuttx/graphics/nxfonts/Make.defs):
  149. ifeq ($(NXFONTS_FONTID),1)
  150. NXFONTS_PREFIX := g_sans23x27_
  151. GEN_CSRC = nxfonts_bitmaps_sans23x27.c
  152. endif
  153. ifeq ($(NXFONTS_FONTID),2)
  154. NXFONTS_PREFIX := g_myfont_
  155. GEN_CSRC = nxfonts_bitmaps_myfont.c
  156. endif
  157. 8. graphics/nxfonts/nxfonts_bitmaps.c. This is the file that contains
  158. the generic font structures. It is used as a "template" file by
  159. nuttx/graphics/nxfonts/Makefile.sources to create your customized
  160. font data set.
  161. #if NXFONTS_FONTID == 1
  162. # include "nxfonts_sans23x27.h"
  163. #elif NXFONTS_FONTID == 2
  164. # include "nxfonts_myfont.h"
  165. #else
  166. # error "No font ID specified"
  167. #endif
  168. Where nxfonts_myfont.h is the NuttX font file that we generated in
  169. step 2 using the bdf-converter tool.
  170. 9. graphics/nxfonts/nxfonts_getfont.c. Finally, we need to extend the
  171. logic that does the run-time font lookups so that can find our new
  172. font. The lookup function is NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid).
  173. The new font information needs to be added to data structures used by
  174. that function:
  175. #ifdef CONFIG_NXFONT_SANS23X27
  176. extern const struct nx_fontpackage_s g_sans23x27_package;
  177. #endif
  178. #ifdef CONFIG_NXFONT_MYFONT
  179. extern const struct nx_fontpackage_s g_myfont_package;
  180. #endif
  181. static FAR const struct nx_fontpackage_s *g_fontpackages[] =
  182. {
  183. #ifdef CONFIG_NXFONT_SANS23X27
  184. &g_sans23x27_package,
  185. #endif
  186. #ifdef CONFIG_NXFONT_MYFONT
  187. &g_myfont_package,
  188. #endif
  189. NULL
  190. };
  191. Configuration Settings
  192. ^^^^^^^^^^^^^^^^^^^^^^
  193. General NX Settings
  194. -------------------
  195. CONFIG_NX
  196. Enables overall support for graphics library and NX
  197. CONFIG_NX_MULTIUSER
  198. Configures NX in multi-user mode
  199. CONFIG_NX_NPLANES
  200. Some YUV color formats requires support for multiple planes, one for each
  201. color component. Unless you have such special hardware, this value should be
  202. undefined or set to 1.
  203. CONFIG_NX_WRITEONLY
  204. Define if the underlying graphics device does not support read operations.
  205. Automatically defined if CONFIG_NX_LCDDRIVER and CONFIG_LCD_NOGETRUN are
  206. defined.
  207. CONFIG_NX_DISABLE_1BPP, CONFIG_NX_DISABLE_2BPP,
  208. CONFIG_NX_DISABLE_4BPP, CONFIG_NX_DISABLE_8BPP,
  209. CONFIG_NX_DISABLE_16BPP, CONFIG_NX_DISABLE_24BPP, and
  210. CONFIG_NX_DISABLE_32BPP
  211. NX supports a variety of pixel depths. You can save some memory by disabling
  212. support for unused color depths.
  213. CONFIG_NX_PACKEDMSFIRST
  214. If a pixel depth of less than 8-bits is used, then NX needs to know if the
  215. pixels pack from the MS to LS or from LS to MS
  216. CONFIG_NX_MOUSE
  217. Build in support for mouse input.
  218. CONFIG_NX_KBD
  219. Build in support of keypad/keyboard input.
  220. CONFIG_NXTK_BORDERWIDTH
  221. Specifies with with of the border (in pixels) used with framed windows.
  222. The default is 4.
  223. CONFIG_NXTK_BORDERCOLOR1, CONFIG_NXTK_BORDERCOLOR2, CONFIG_NXTK_BORDERCOLOR3
  224. Specify the colors of the border used with framed windows.
  225. CONFIG_NXTK_BORDERCOLOR2 is the shadow side color and so is normally darker.
  226. CONFIG_NXTK_BORDERCOLOR3 is the shiny side color and so is normally brighter.
  227. The default is mediumdark grey, and light grey, respectively
  228. CONFIG_NXTK_AUTORAISE
  229. If set, a window will be raised to the top if the mouse position is over a
  230. visible portion of the window. Default: A mouse button must be clicked over
  231. a visible portion of the window.
  232. CONFIG_NXFONTS_CHARBITS
  233. The number of bits in the character set. Current options are only 7 and 8.
  234. The default is 7.
  235. Font Selections
  236. ---------------
  237. CONFIG_NXFONT_SANS17X22
  238. This option enables support for a tiny, 17x22 san serif font
  239. (font ID FONTID_SANS17X22 == 14).
  240. CONFIG_NXFONT_SANS20X26
  241. This option enables support for a tiny, 20x26 san serif font
  242. (font ID FONTID_SANS20X26 == 15).
  243. CONFIG_NXFONT_SANS23X27
  244. This option enables support for a tiny, 23x27 san serif font
  245. (font ID FONTID_SANS23X27 == 1).
  246. CONFIG_NXFONT_SANS22X29
  247. This option enables support for a small, 22x29 san serif font
  248. (font ID FONTID_SANS22X29 == 2).
  249. CONFIG_NXFONT_SANS28X37
  250. This option enables support for a medium, 28x37 san serif font
  251. (font ID FONTID_SANS28X37 == 3).
  252. CONFIG_NXFONT_SANS39X48
  253. This option enables support for a large, 39x48 san serif font
  254. (font ID FONTID_SANS39X48 == 4).
  255. CONFIG_NXFONT_SANS17X23B
  256. This option enables support for a tiny, 17x23 san serif bold font
  257. (font ID FONTID_SANS17X23B == 16).
  258. CONFIG_NXFONT_SANS20X27B
  259. This option enables support for a tiny, 20x27 san serif bold font
  260. (font ID FONTID_SANS20X27B == 17).
  261. CONFIG_NXFONT_SANS22X29B
  262. This option enables support for a small, 22x29 san serif bold font
  263. (font ID FONTID_SANS22X29B == 5).
  264. CONFIG_NXFONT_SANS28X37B
  265. This option enables support for a medium, 28x37 san serif bold font
  266. (font ID FONTID_SANS28X37B == 6).
  267. CONFIG_NXFONT_SANS40X49B
  268. This option enables support for a large, 40x49 san serif bold font
  269. (font ID FONTID_SANS40X49B == 7).
  270. CONFIG_NXFONT_SERIF22X29
  271. This option enables support for a small, 22x29 font (with serifs)
  272. (font ID FONTID_SERIF22X29 == 8).
  273. CONFIG_NXFONT_SERIF29X37
  274. This option enables support for a medium, 29x37 font (with serifs)
  275. (font ID FONTID_SERIF29X37 == 9).
  276. CONFIG_NXFONT_SERIF38X48
  277. This option enables support for a large, 38x48 font (with serifs)
  278. (font ID FONTID_SERIF38X48 == 10).
  279. CONFIG_NXFONT_SERIF22X28B
  280. This option enables support for a small, 27x38 bold font (with serifs)
  281. (font ID FONTID_SERIF22X28B == 11).
  282. CONFIG_NXFONT_SERIF27X38B
  283. This option enables support for a medium, 27x38 bold font (with serifs)
  284. (font ID FONTID_SERIF27X38B == 12).
  285. CONFIG_NXFONT_SERIF38X49B
  286. This option enables support for a large, 38x49 bold font (with serifs)
  287. (font ID FONTID_SERIF38X49B == 13).
  288. NxConsole Configuration Settings
  289. --------------------------------
  290. CONFIG_NXCONSOLE
  291. Enables building of the NxConsole driver.
  292. NxConsole output text/graphics options:
  293. CONFIG_NXCONSOLE_BPP
  294. Currently, NxConsole supports only a single pixel depth. This
  295. configuration setting must be provided to support that single pixel depth.
  296. Default: The smallest enabled pixel depth. (see CONFIG_NX_DISABLE_*BPP)
  297. CONFIG_NXCONSOLE_CURSORCHAR
  298. The bitmap code to use as the cursor. Default '_'
  299. CONFIG_NXCONSOLE_MXCHARS
  300. NxConsole needs to remember every character written to the console so
  301. that it can redraw the window. This setting determines the size of some
  302. internal memory allocations used to hold the character data. Default: 128.
  303. CONFIG_NXCONSOLE_CACHESIZE
  304. NxConsole supports caching of rendered fonts. This font caching is required
  305. for two reasons: (1) First, it improves text performance, but more
  306. importantly (2) it preserves the font memory. Since the NX server runs on
  307. a separate server thread, it requires that the rendered font memory persist
  308. until the server has a chance to render the font. Unfortunately, the font
  309. cache would be quite large if all fonts were saved. The CONFIG_NXCONSOLE_CACHESIZE
  310. setting will control the size of the font cache (in number of glyphs). Only that
  311. number of the most recently used glyphs will be retained. Default: 16.
  312. NOTE: There can still be a race condition between the NxConsole driver and the
  313. NX task. If you every see character corruption (especially when printing
  314. a lot of data or scrolling), then increasing the value of CONFIG_NXCONSOLE_CACHESIZE
  315. is something that you should try. Alternatively, you can reduce the size of
  316. CONFIG_MQ_MAXMSGSIZE which will force NxConsole task to pace the server task.
  317. CONFIG_NXCONSOLE_CACHESIZE should be larger than CONFIG_MQ_MAXMSGSIZE in any event.
  318. CONFIG_NXCONSOLE_LINESEPARATION
  319. This the space (in rows) between each row of test. Default: 0
  320. CONFIG_NXCONSOLE_NOWRAP
  321. By default, lines will wrap when the test reaches the right hand side
  322. of the window. This setting can be defining to change this behavior so
  323. that the text is simply truncated until a new line is encountered.
  324. NxConsole Input options
  325. CONFIG_NXCONSOLE_NXKBDIN
  326. Take input from the NX keyboard input callback. By default, keyboard
  327. input is taken from stdin (/dev/console). If this option is set, then
  328. the interface nxcon_kdbin() is enabled. That interface may be driven
  329. by window callback functions so that keyboard input *only* goes to the
  330. top window.
  331. CONFIG__NXCONSOLE_KBDBUFSIZE
  332. If CONFIG_NXCONSOLE_NXKBDIN is enabled, then this value may be used to
  333. define the size of the per-window keyboard input buffer. Default: 16
  334. CONFIG_NXCONSOLE_NPOLLWAITERS
  335. The number of threads that can be waiting for read data available.
  336. Default: 4
  337. NX Multi-user only options
  338. --------------------------
  339. CONFIG_NX_BLOCKING
  340. Open the client message queues in blocking mode. In this case,
  341. nx_eventhandler() will not return until a message is received and processed.
  342. CONFIG_NX_MXSERVERMSGS and CONFIG_NX_MXCLIENTMSGS
  343. Specifies the maximum number of messages that can fit in the message queues.
  344. No additional resources are allocated, but this can be set to prevent
  345. flooding of the client or server with too many messages (CONFIG_PREALLOC_MQ_MSGS
  346. controls how many messages are pre-allocated).