1.. _qnx:
2
3===
4QNX
5===
6
7What is QNX?
8************
9
10QNX is a commercial operating system first released in 1980. The operating
11system is based on a micro-kernel design, with the file system(s), network
12stack, and various other drivers each running in its own process with a separate
13address space.
14
15See www.qnx.com for more details.
16
17Highlight of QNX
18----------------
19
20- 64-bit only, runs on x86_64 and ARMv8
21- Requires an MMU as the design mandates separation among processes
22- Support for thousands of processes and millions of threads
23- Up to 64 cores, up to 16TB of RAM
24- Virtualization support (as host and guest)
25- Full POSIX compatibility
26- Safety certification to various automotive, industrial and medical standards
27
28How to run LVGL on QNX?
29***********************
30
31There are two ways to use LVGL in your QNX project. The first is similar to how
32LVGL is used on other systems. The second is to build LVGL as either a shared or
33a static library.
34
35Include LVGL in Your Project
36----------------------------
37
38Follow the generic instructions for getting started with LVGL. After copying
39`lv_conf_template.h` to  `lv_conf.h` make the following changes to the latter:
40
411. Enable QNX support:
42
43.. code-block:: c
44
45    #define LV_USE_QNX 1
46
472. Set colour depth to 32:
48
49.. code-block:: c
50
51    #define LV_COLOR_DEPTH 32
52
533. (Optional) Enable double-buffering:
54
55.. code-block:: c
56
57    #define LV_QNX_BUF_COUNT 2
58
59Build LVGL as a Library
60-----------------------
61
62**Note that this method is an alternative to including LVGL in your project. If
63you choose to build a library then you do not need to follow the instructions in
64the previous section.**
65
66The top-level `qnx` directory includes a recursive make file for building LVGL,
67both as a shared library and as a static library for the supported
68architectures. To build all libraries, simply invoke `make` in this directory:
69
70.. code-block:: shell
71
72    # cd $(LVGL_ROOT)/env_support/qnx
73    # make
74
75If you prefer to build for a specific architecture and variant, go to the
76appropriate directory and run `make` there. For example, to build a shared
77library for ARMv8:
78
79.. code-block:: shell
80
81    # cd $(LVGL_ROOT)/env_support/qnx/aarch64/so.le
82    # make
83
84As a general rule, if you only want to have one LVGL application in your system
85then it is better to use a static library. If you have more than one, and
86especially if they run concurrently, it is better to use the shared library.
87
88Before building the library, you may wish to edit
89`$(LVGL_ROOT)/env_support/qnx/lv_conf.h`, e.g. to add fonts or disable
90double-buffering.
91
92Writing a LVGL Application
93--------------------------
94
95To create a LVGL application for QNX, follow these steps in your code:
96
971. Initialize the library.
982. Create a window.
993. Add the input devices.
1004. Create the UI.
1015. Run the event loop.
102
103Steps 2, 3 and 5 use QNX-specific calls, but the rest of the code should be
104identical to that of a LVGL application written for any other platform.
105
106The following code shows how to create a "Hello World" application:
107
108.. code-block:: c
109
110    #include <lvgl.h>
111
112    int
113    main(int argc, char **argv)
114    {
115        /* Initialize the library. */
116        lv_init();
117
118        /* Create a 800x480 window. */
119        lv_display_t *disp = lv_qnx_window_create(800, 480);
120        lv_qnx_window_set_title(disp, "LVGL Example");
121
122        /* Add keyboard and mouse devices. */
123        lv_qnx_add_keyboard_device(disp);
124        lv_qnx_add_pointer_device(disp);
125
126        /* Generate the UI. */
127        lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x003a57), LV_PART_MAIN);
128
129        lv_obj_t * label = lv_label_create(lv_screen_active());
130        lv_label_set_text(label, "Hello world");
131        lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0xffffff), LV_PART_MAIN);
132        lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
133
134        /* Run the event loop until it exits. */
135        return lv_qnx_event_loop(disp);
136    }
137
138Build the Application
139---------------------
140
141Building the application consists of compiling the source with the LVGL headers,
142and then linking against the library. This can be done in many ways, using
143different build systems. The following is a simple make file for the example
144above, which builds for ARMv8 with the shared library:
145
146.. code-block:: makefile
147
148    CC=qcc -Vgcc_ntoaarch64le
149
150    LVGL_ROOT=$(HOME)/src/lvgl
151    CCFLAGS=-I$(LVGL_ROOT)/env_support/qnx -I$(LVGL_ROOT)
152    LDFLAGS=-lscreen -llvgl -L$(LVGL_ROOT)/env_support/qnx/aarch64/so.le
153
154    lvgl_example: lvgl_example.c
155    	$(CC) $(CCFLAGS) -Wall -o $@ $< $(LDFLAGS)
156
157    clean:
158    	rm -f *.o *~ lvgl_example
159