Return to Robotics Tutorials

Embedded C GUI for Raspberry PI & Arduino

In developing my custom telemetry robot controller with a touchscreen TFT LCD display, I needed to design a GUI library in C to support menus, buttons, text and images. GUIslice is a lightweight C library intended to work with the Raspberry Pi and Arduino.

GUIslice Touchscreen GUI in C
Custom Telemetry Menu Screen

GUIslice C Library Features

GUIslice provides an open source (free), lightweight platform-independent library that enables embedded GUI menus and displays in C.

  • Processor Hardware Support: This library was intended for use on the Raspberry Pi and Arduino, but also runs on ARM Cortex M0 (Adafruit Feather M0). It can easily be compiled for other targets as well.
  • Display Hardware Support: GUIslice can drive a wide range of displays from 2" TFT LCD displays using a SPI interface (such as PiTFT), parallel, OLED to HDMI. It also supports direct LINUX framebuffer graphics (via SDL1.2). See latest testing for compatibility.
  • Touchscreen Support: To facilitate embedded touchscreen GUI designs, optional support is provided for resistive and capacitive touch devices.
  • Lightweight GUI library:
    • Dependencies for LINUX: SDL 1.2 (optional TTF_Font) or SDL2 -- no need for Python or XWindows / X11!
    • Dependencies for Arduino: Adafruit-GFX, graphics lib (eg. ILI9341) and optional touch lib (eg. STMPE610).
    • Enhancements to support GUI elements in Flash memory for RAM-constained devices such as Arduino (ATmega328)
    • Written in pure C with no dynamic memory allocation within GUIslice
  • Graphic elements: Buttons, Checkboxes, Radio buttons, Text areas, Progress bars, Bitmap images, basic drawing primitives, etc. Both text and image-based buttons are supported. Event mechanism with callbacks. Extensions for custom widget creation.
  • Window paging: Support for multiple display pages and switching between them.
  • Font support: For LINUX: Wide variety of TrueType fonts supported via TTF_Font.
  • Permissive License: GUIslice has been released as open source with the very permissive MIT License. It is free to use for personal or commercial use.

Download GUIslice

The source code is now available in the following GitHub repository:

I gladly welcome any code contributions (pull requests), feedback or suggestions for new features / hardware support!

Screenshots of Embedded GUI applications

Raspberry Pi touchscreen GUI  Touchscreen GUI for Arduino

Examples of GUIslice on Arduino

Please see the GUIslice for Arduino page for more details

Installation of GUIslice on Raspberry Pi

Please see the Installation guide for Raspberry Pi

How to use GUIslice

The GUIslice library includes a number of example programs demonstrating basic functionality as well as more complex drawing callbacks and compound elements. For more details, please refer to the GUIslice wiki.

Example touchscreen C GUI code with Button and Event Loop

The following program displays an image-based button and tracks any touch-presses, highlighting the button while hovering on it. Releasing the button ends the program through a callback.

#include "GUIslice.h"
#include "GUIslice_drv.h"

// Instantiate the GUI
#define MAX_PAGE            1
#define MAX_ELEM_PG_MAIN    5
gslc_tsGui                  m_gui;
gslc_tsDriver               m_drv;
gslc_tsPage                 m_asPage[MAX_PAGE];
gslc_tsElem                 m_asPageElem[MAX_ELEM_PG_MAIN];

bool m_bQuit = false;

// Button callback
bool CbBtnQuit(void* pvGui,void *pvElem,gslc_teTouch eTouch,int16_t nX,int16_t nY)
  if (eTouch == GSLC_TOUCH_UP_IN) {
    m_bQuit = true;
  return true;

int main( int argc, char* args[] )
  gslc_tsElem*  pElem = NULL;

  // Initialize
  // Build the main page
  // Background flat color

  // Create background box
  pElem = gslc_ElemCreateBox(&m_gui,E_ELEM_BOX,E_PG_MAIN,(gslc_tsRect){10,50,300,150});

  // Create Quit button with image label and callback
  pElem = gslc_ElemCreateBtnImg(&m_gui,E_ELEM_BTN_QUIT,E_PG_MAIN,(gslc_tsRect){258,70,32,32},

  // Start up display on main page

  // Main event loop
  m_bQuit = false;
  while (!m_bQuit) {
    // Update GUI

  // Close down display
  return 0;

Example Code

Example code is provided in the GUIslice repository in the following subdirectories:

  • LINUX: /tests/
  • Arduino sketches: /arduino/

Supported Devices

The following CPUs, boards and hardware devices have been tested to work with GUIslice:

  • Processors
    • Raspberry Pi
    • Arduino (see GUIslice for Arduino)
      • Arduino Pro Mini
      • ATmega328P / Arduino UNO R3
      • ATmega2560
    • ARM Cortex
    • Tested soon:
      • STM32 (STM32F103C8T6)
      • BeagleBone Black
      • ESP8266 (ESP-12)
  • Displays
  • Graphic driver chips
    • ILI9341 / ILI9340
    • XPT2046 (via SDL)
    • Tested soon:
      • SSD1306
      • ST7735R
  • Touch driver chips
    • STMPE610
    • FT6X06 (via SDL)
    • Tested soon:
      • FT6206
      • ADS7843


Reader's Comments:

Please leave your comments or suggestions below!
 I have tried to install SDL on Beaglebone Black. Have you experimented with BBB? I would appreciate your comments on using GUIslice on BBB. Many thanks for your excellent article.
 Hi Kevin! Thanks for your interest in GUIslice. I have sent a private email to see if we can get it working for you.
 Hi, i am interesting your microSDL library.
please send me the link!
Thank you!
 Email sent!
 The library looks awesome! I'm interested in testing it out. Do you mind if I ask for read access?
 Glad to hear it! Email sent
2016-12-10hal pitts
 please send me the link to the microSDL library

thank you
 Email sent!
 Very promising and interesting project according to this article.

I'd really like to taste the implementation of microSDL.

May I look closer?

 Definitely! Private message sent
 I would also like to try this c library to test. I have been playing with Kivy but am a C programmer and all the Pi code I have is in C and would like to have my Gui that I am now trying to incorporate to be in C also.

 Sure! Private email message sent to you with link to repository.
2016-10-22Dick Wilder
 Calvin -
I'd like to beta-test the current version. Please contact me via email.

I'm looking forward to the first release, any estimate of when you will post to github?
 Thanks for the interest! The library is currently available on GitHub for testing. Private message sent with link.

I am interested in your microSDL library. Have you put the source code in the public domain?

D A Uhen
 Hi David! I will be releasing the microSDL library into the public domain shortly -- most likely onto github. I will send you an email update once I have tightened up the code and uploaded it. Thanks for the interest!


Leave a comment or suggestion for this page:

(Never Shown - Optional)