Linux

From uGFX Wiki
Revision as of 09:42, 4 July 2014 by Tectu (Talk | contribs) (Framebuffer)

Jump to: navigation, search

µ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

The following Makefile can be used to compile an µGFX application on a Linux system. Modify the highlighted line(s).

  1. # The name of the project / binary
  2. PROJECT = ugfx
  3.  
  4. # List C source files here
  5. SRC     = $(GFXSRC) \
  6.           main.c
  7.  
  8. # List all user directories here
  9. UINCDIR = $(GFXINC) \
  10.  
  11. # List all libraries
  12. LIBS    = -lX11 -pthread
  13.  
  14. # Include uGFX
  15. GFXLIB  = /home/tectu/projects/resources/ugfx
  16. include $(GFXLIB)/gfx.mk
  17. include $(GFXLIB)/boards/base/Linux/board.mk                    # The X driver
  18. #include $(GFXLIB)/boards/base/Linux-Framebuffer/board.mk       # The framebuffer driver
  19.  
  20.  
  21. ###############################################################################
  22. # Do not change anything below this line unless you know what you're doing    #
  23. ###############################################################################
  24.  
  25. # Your toolchain
  26. CC      = gcc
  27. INCDIR  = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
  28. LIBDIR  = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
  29. OBJS    = $(SRC:.c=.o)
  30. CCFLAGS = -O2 -Wall -DGFX_USE_OS_LINUX=TRUE
  31. LDFLAGS = 
  32.  
  33.  
  34. ###############################################################################
  35. # Actual Makefile rules                                                       #
  36. ###############################################################################
  37.  
  38. all: $(OBJS) $(PROJECT)
  39.  
  40. %.o : %.c
  41. 	$(CC) -c $(CCFLAGS) -I . $(INCDIR) $< -o $@
  42.  
  43. $(PROJECT): $(OBJS)
  44. 	$(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
  45.  
  46. clean:                                      
  47. 	-rm -f $(OBJS)
  48. 	-rm -f $(PROJECT)