Difference between revisions of "Linux"

From uGFX Wiki
Jump to: navigation, search
(Touchscreen / Mouse)
 
(27 intermediate revisions by the same user not shown)
Line 1: Line 1:
µGFX runs natively on any Linux system that runs the X server. Running µGFX on your computer can be used to simplify the process of developing your embedded GUI because you don't have to flash the firmware every time to try it. Also, this way µGFX can be used as the native GUI system on low power Linux devices such as the Raspberry-Pi and other single board computers.
+
µGFX runs natively on any Linux system. The SDL driver can be used to compile a native Linux desktop application. This is especially useful during the development process as the entire µGFX application can be developed and tested without flashing the target microcontroller every time. The Framebuffer driver is useful to use µGFX on embedded Linux systems that don't run X or a full Desktop environment.
 
+
'''''Note:''' The performance of the resulting program is very bad unless you use the Linux [[Linux#Framebuffer|Framebuffer]] driver. This is because the X driver just uses setPixel() and doesn't take any advantage of area blitting or double buffering. The application will run A LOT faster on the actual microcontroller.''
+
  
 
== SDL ==
 
== SDL ==
ToDo
+
Using the SDL driver is the '''recommended way''' of running µGFX inside a Linux system with a desktop environment. The SDL driver also supports mouse and keyboard input.
 +
 
 +
=== Dependencies ===
 +
[https://www.libsdl.org/ SDL2] is required to use the µGFX SDL driver. As we are compiling an SDL application ourselves, the development version of the SDL2 library used. On most common Linux distributions these can be installed by the <code>libsdl2-dev</code> package. However, note that µGFX applications get compiled as 32-bit applications. Therefore, you have to install the 32-bit variation of that package if you are running a 64-Bit Linux.
 +
 
 +
For example, the following packages need to be installed to compile µGFX on ''Ubuntu 16 64-Bit'':
 +
<source lang=c>
 +
apt install libsdl2-dev:i386 build-essential gcc-multilib
 +
</source>
 +
 
 +
=== Makefile ===
 +
A ready-to-use Makefile to compile a native µGFX Linux application can be found under ''/boards/base/Linux-SDL/example/''.
 +
 
 +
It is important to note that the following line has to be added to the <code>CFLAGS</code> in order for SDL to link properly:
 +
<syntaxhighlight lang=make>
 +
CFLAGS = `sdl2-config --libs --cflags`
 +
</syntaxhighlight>
  
 
== Framebuffer ==
 
== Framebuffer ==
The Linux driver does not only come with an X driver, but also with a framebuffer driver. To use the framebuffer driver, include the following line in your Makefile:
+
The framebuffer driver can be used to run µGFX on embedded Linux systems that don't run X or a desktop environment.
 
<syntaxhighlight lang=make>
 
<syntaxhighlight lang=make>
 
include $(GFXLIB)/boards/base/Linux-Framebuffer/board.mk
 
include $(GFXLIB)/boards/base/Linux-Framebuffer/board.mk
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== Dependencies ===
 +
There are no dependencies to use the Linux framebuffer driver. However, the Linux kernel must have been compiled with framebuffer support enabled.
  
 
=== Makefile ===
 
=== Makefile ===
A ready-to-use Makefile to compile a native uGFX Linux application can be found under ''/boards/base/Linux/example/''.
+
A ready-to-use Makefile to compile a native µGFX Linux application can be found under ''/boards/base/Linux-Framebuffer/example/''.
 +
 
 +
=== Framebuffer device ===
 +
By default, the framebuffer driver looks for the framebuffer device under <code>/dev/fb0</code> and <code>/dev/fb/0</code>. If your system links the framebuffer under a different path, please modify the <code>FBDEV_PATH1</code> macro in the <code>/boards/base/Linux-Framebuffer/board_framebuffer.h</code> file.
 +
 
 +
The pixel format can be set using <code>GDISP_LLD_PIXELFORMAT</code>. By default <code>GDISP_PIXELFORMAT_RGB888</code> is used. Note that the Linux framebuffer only supports RGB mode (no BGR modes).
 +
 
 +
=== Touchscreen / Mouse ===
 +
When the touchscreen/mouse device is already accessible through the Linux event input system ''(eg. <code>/dev/input/event0</code> or similar)'' the <code>Linux-Event</code> GINPUT driver can be used to interface the device.
 +
To simplify handling of systems that use the [[Linux#Framebuffer|framebuffer]] and a touchscreen or mouse via the event input system, the <code>Linux-Framebuffer-Touch</code> board files can be used.
 +
 
 +
The <code>GMOUSE_LINUX_EVENT_DEVICE</code> define in the board file can be used to specify the path to the input device. The default value is <code>/dev/input/event0</code>:
 +
<source lang="c">
 +
#define GMOUSE_LINUX_EVENT_DEVICE "/dev/input/event0"
 +
</source>
 +
 
 +
The <code>GMOUSE_LINUX_EVENT_SELF_CALIBRATE</code> define in the board file controls whether a calibration screen shows up prior to launching the actual application. The default value is <code>FALSE</code> which causes the calibration screen to show up:
 +
<source lang="c">
 +
#define GMOUSE_LINUX_EVENT_SELF_CALIBRATE FALSE
 +
</source>
 +
With touchscreen that support self calibration, this can be set to <code>TRUE</code> to use the built-in calibration. Alternatively, calibration data retrieved by passing the µGFX calibration screen can be stored and reloaded. See [[Touchscreen_Calibration|Touchscreen Calibration]] for more information.
 +
 
 +
=== Example ===
 +
Please have a look at the [[Raspberry_Pi|Raspberry Pi guide]] for an extensive step-by-step tutorial on how-to getting µGFX running on an embedded Linux system using the framebuffer.
  
 
== X ==
 
== X ==
ToDo
+
Using the X driver is '''not recommended'''. It's deprecated and an old relic that is kept in the µGFX library as a reference for examples and for systems that are incapable of running SDL. It is '''STRONGLY''' recommended to use the SDL driver instead (see above).
 +
The performance of the resulting program is very bad because the X driver just uses <code>setPixel()</code> and doesn't take any advantage of area blitting or double buffering.
 +
 
 +
=== Dependencies ===
 +
The X11 development libraries are required to run the µGFX X driver.
 +
 
 +
For example, the following packages need to be installed to compile µGFX on ''Ubuntu 16 64-Bit'':
 +
<source lang=c>
 +
apt install libx11-dev:i386 xorg-dev build-essential gcc-multilib
 +
</source>
 +
 
 +
=== Makefile ===
 +
A ready-to-use Makefile to compile a native µGFX Linux application can be found under ''/boards/base/Linux-X/example/''.

Latest revision as of 22:35, 23 August 2016

µGFX runs natively on any Linux system. The SDL driver can be used to compile a native Linux desktop application. This is especially useful during the development process as the entire µGFX application can be developed and tested without flashing the target microcontroller every time. The Framebuffer driver is useful to use µGFX on embedded Linux systems that don't run X or a full Desktop environment.

SDL

Using the SDL driver is the recommended way of running µGFX inside a Linux system with a desktop environment. The SDL driver also supports mouse and keyboard input.

Dependencies

SDL2 is required to use the µGFX SDL driver. As we are compiling an SDL application ourselves, the development version of the SDL2 library used. On most common Linux distributions these can be installed by the libsdl2-dev package. However, note that µGFX applications get compiled as 32-bit applications. Therefore, you have to install the 32-bit variation of that package if you are running a 64-Bit Linux.

For example, the following packages need to be installed to compile µGFX on Ubuntu 16 64-Bit:

apt install libsdl2-dev:i386 build-essential gcc-multilib

Makefile

A ready-to-use Makefile to compile a native µGFX Linux application can be found under /boards/base/Linux-SDL/example/.

It is important to note that the following line has to be added to the CFLAGS in order for SDL to link properly:

CFLAGS = `sdl2-config --libs --cflags`

Framebuffer

The framebuffer driver can be used to run µGFX on embedded Linux systems that don't run X or a desktop environment.

include $(GFXLIB)/boards/base/Linux-Framebuffer/board.mk

Dependencies

There are no dependencies to use the Linux framebuffer driver. However, the Linux kernel must have been compiled with framebuffer support enabled.

Makefile

A ready-to-use Makefile to compile a native µGFX Linux application can be found under /boards/base/Linux-Framebuffer/example/.

Framebuffer device

By default, the framebuffer driver looks for the framebuffer device under /dev/fb0 and /dev/fb/0. If your system links the framebuffer under a different path, please modify the FBDEV_PATH1 macro in the /boards/base/Linux-Framebuffer/board_framebuffer.h file.

The pixel format can be set using GDISP_LLD_PIXELFORMAT. By default GDISP_PIXELFORMAT_RGB888 is used. Note that the Linux framebuffer only supports RGB mode (no BGR modes).

Touchscreen / Mouse

When the touchscreen/mouse device is already accessible through the Linux event input system (eg. /dev/input/event0 or similar) the Linux-Event GINPUT driver can be used to interface the device. To simplify handling of systems that use the framebuffer and a touchscreen or mouse via the event input system, the Linux-Framebuffer-Touch board files can be used.

The GMOUSE_LINUX_EVENT_DEVICE define in the board file can be used to specify the path to the input device. The default value is /dev/input/event0:

#define GMOUSE_LINUX_EVENT_DEVICE "/dev/input/event0"

The GMOUSE_LINUX_EVENT_SELF_CALIBRATE define in the board file controls whether a calibration screen shows up prior to launching the actual application. The default value is FALSE which causes the calibration screen to show up:

#define GMOUSE_LINUX_EVENT_SELF_CALIBRATE FALSE

With touchscreen that support self calibration, this can be set to TRUE to use the built-in calibration. Alternatively, calibration data retrieved by passing the µGFX calibration screen can be stored and reloaded. See Touchscreen Calibration for more information.

Example

Please have a look at the Raspberry Pi guide for an extensive step-by-step tutorial on how-to getting µGFX running on an embedded Linux system using the framebuffer.

X

Using the X driver is not recommended. It's deprecated and an old relic that is kept in the µGFX library as a reference for examples and for systems that are incapable of running SDL. It is STRONGLY recommended to use the SDL driver instead (see above). The performance of the resulting program is very bad because the X driver just uses setPixel() and doesn't take any advantage of area blitting or double buffering.

Dependencies

The X11 development libraries are required to run the µGFX X driver.

For example, the following packages need to be installed to compile µGFX on Ubuntu 16 64-Bit:

apt install libx11-dev:i386 xorg-dev build-essential gcc-multilib

Makefile

A ready-to-use Makefile to compile a native µGFX Linux application can be found under /boards/base/Linux-X/example/.