Difference between revisions of "Linux"

From uGFX Wiki
Jump to: navigation, search
(Framebuffer)
Line 10: Line 10:
  
 
== Makefile ==
 
== Makefile ==
The following Makefile can be used to compile an µGFX application on a Linux system. Modify the highlighted line(s).
+
A ready-to-use Makefile to compile a native uGFX Linux application can be found under ''/boards/base/Linux/example/''.
<syntaxhighlight lang=make line start="1" highlight="15">
+
# The name of the project / binary
+
PROJECT = ugfx
+
 
+
# List C source files here
+
SRC    = $(GFXSRC) \
+
          main.c
+
 
+
# List all user directories here
+
UINCDIR = $(GFXINC) \
+
 
+
# List all libraries
+
LIBS    = -lX11 -pthread
+
 
+
# Include uGFX
+
GFXLIB  = /home/tectu/projects/resources/ugfx
+
include $(GFXLIB)/gfx.mk
+
include $(GFXLIB)/boards/base/Linux/board.mk                    # The X driver
+
#include $(GFXLIB)/boards/base/Linux-Framebuffer/board.mk      # The framebuffer driver
+
 
+
 
+
###############################################################################
+
# Do not change anything below this line unless you know what you're doing    #
+
###############################################################################
+
 
+
# Your toolchain
+
CC      = gcc
+
INCDIR  = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
+
LIBDIR  = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
+
OBJS    = $(SRC:.c=.o)
+
CCFLAGS = -O2 -Wall -DGFX_USE_OS_LINUX=TRUE
+
LDFLAGS =
+
 
+
 
+
###############################################################################
+
# Actual Makefile rules                                                      #
+
###############################################################################
+
 
+
all: $(OBJS) $(PROJECT)
+
 
+
%.o : %.c
+
$(CC) -c $(CCFLAGS) -I . $(INCDIR) $< -o $@
+
 
+
$(PROJECT): $(OBJS)
+
$(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
+
 
+
clean:                                     
+
-rm -f $(OBJS)
+
-rm -f $(PROJECT)
+
</syntaxhighlight>
+

Revision as of 20:46, 29 September 2014

µ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.

Note: The performance of the resulting program is very bad. 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.

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:

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

Makefile

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