Porting and Simulation of the Open Source GUI Library uC/GUI

uC/GUI is a lightweight graphical user interface (GUI) library specifically designed for embedded systems. Developed by Segger, it aims to provide a simple and efficient graphical interface solution for embedded applications. Here are some of the main features and functionalities of uC/GUI:

Main Features

  1. Lightweight:

  • The design goal of uC/GUI is to be as compact as possible, suitable for resource-constrained embedded systems. Its memory footprint and processor requirements are relatively low.
  • Efficiency:

    • The library is optimized to quickly render graphics and text on various hardware platforms, ensuring a smooth user experience.
  • Multi-Platform Support:

    • uC/GUI supports various microcontroller architectures, including ARM, AVR, 8051, etc., allowing it to run on different hardware.
  • Rich Graphics Elements:

    • It provides a variety of graphical elements (such as buttons, text boxes, sliders, icons, etc.) that make it easy to create various user interfaces.
  • Customizability:

    • Developers can customize the appearance and behavior of graphical elements as needed, supporting flexible configuration of themes and styles.
  • Touchscreen Support:

    • It supports touchscreen input, capable of handling touch events to provide users with an intuitive interaction method.
  • Multi-Language Support:

    • It supports multi-language display, facilitating the development of international applications.
  • Simple and Easy-to-Use API:

    • It provides a simple and easy-to-use API, allowing developers to quickly get started and implement complex interfaces.

    Application Scenarios

    • Consumer Electronics: Such as smart home devices, portable electronics, etc.
    • Industrial Control: User interfaces for manufacturing equipment, monitoring systems, etc.
    • Medical Devices: Providing intuitive operation interfaces in medical instruments.
    • Automotive Electronics: Used in in-vehicle infotainment systems and dashboard displays.

    Porting and SimulationDownload uCGUI version 3.98https://gitee.com/git-lib/ucgui398In the root directory of the project where the ILI9431 driver has been ported, create a new GUI folder, and copy all files from the directory ucguiuC-GUI-V3-98uC-GUI-V3-98MicriumSoftwareuC-GUIStartGUI to the GUI directory. Copy uC-GUI-V3-98MicriumSoftwareuC-GUISampleGUI_XGUI_X_uCOS.c to the GUILCDDriver folder, and copy the Config from uC-GUI-V3-98MicriumSoftwareuC-GUIStart to the newly created GUI folder.Porting and Simulation of the Open Source GUI Library uC/GUIClick Manage Project items, create UGUI_ConvertColor, UGUI_ConvertMono, UGUI_Core, UGUI_Font, UGUI_LCDDriver, UGUI_Widget, UGUI_WM, GUI_Config, and add the corresponding files to the directories.Porting and Simulation of the Open Source GUI Library uC/GUINote that only add LCDWin.c and GUI_X_uCOS.c files to the UGUI_LCDDriver directory.Porting and Simulation of the Open Source GUI Library uC/GUIOpen LCDWin.c and replace all instances of LCDSIM_SetPixelIndex(x, y, LCD_NUM_COLORS-1-Index, LCD_DISPLAY_INDEX) with ILI9341_DrawPixel(x, y, c), making corresponding changes based on each call, and include the ILI9341 header file in LCDWin.c.Porting and Simulation of the Open Source GUI Library uC/GUIThis example does not perform pixel reading; write an empty function for reading pixels in ili9431.c to prevent compilation errors.int GetPixel(int x, int y, int LayerIndex){

    return 0;

    }

    Modify the corresponding configuration in GUIConf.h.

    Porting and Simulation of the Open Source GUI Library uC/GUI

    Write test code and compile.

    void ShowColorBar(void)

    {

    int x0 = 60, y0 = 40, yStep = 15, i;

    int NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS);

    int xsize = LCD_GetDevCap(LCD_DEVCAP_XSIZE) – x0;

    GUI_SetFont(&GUI_Font13HB_1);

    GUI_DispStringHCenterAt(“μC/GUI-sample:Show color bars”, 160, 0);

    GUI_SetFont(&GUI_Font8x8);

    GUI_SetColor(GUI_WHITE);

    GUI_SetBkColor(GUI_BLACK);

    #if(LCD_FIXEDPALETTE)

    GUI_DispString(“Fixed palette: “);

    GUI_DispDecMin(LCD_FIXEDPALETTE);

    #endif

    GUI_DispStringAt(“Red”, 0, y0 + yStep);

    GUI_DispStringAt(“Green”, 0, y0 + 3 * yStep);

    GUI_DispStringAt(“Blue”, 0, y0 + 5 * yStep);

    GUI_DispStringAt(“Grey”, 0, y0 + 6 * yStep);

    GUI_DispStringAt(“Yellow”, 0, y0 + 8 * yStep);

    GUI_DispStringAt(“Cyan”, 0, y0 + 10 * yStep);

    GUI_DispStringAt(“Magenta”, 0, y0 + 12 * yStep);

    for(i=0; i < xsize; i++)

    {

    U16 cs =(255 *(U32)i) / xsize;

    U16 x = x0 + i;

    /* Red */

    GUI_SetColor(cs);

    GUI_DrawVLine(x, y0, y0 +yStep – 1);

    GUI_SetColor(0xff +(255 – cs) * 0x10100L);

    GUI_DrawVLine(x, y0 +yStep, y0 + 2 * yStep – 1);

    /* Green */

    GUI_SetColor(cs<<8);

    GUI_DrawVLine(x, y0 + 2 * yStep, y0 + 3 * yStep – 1);

    GUI_SetColor(0xff00 +(255 – cs) * 0x10001L);

    GUI_DrawVLine(x, y0 + 3 * yStep, y0 + 4 * yStep – 1);

    /* Blue */

    GUI_SetColor(cs * 0x10000L);

    GUI_DrawVLine(x, y0 + 4 * yStep, y0 + 5 * yStep – 1);

    GUI_SetColor(0xff0000 +(255 – cs) * 0x101L);

    GUI_DrawVLine(x, y0 + 5 * yStep, y0 + 6 * yStep – 1);

    /* Grey */

    GUI_SetColor((U32)cs * 0x10101L);

    GUI_DrawVLine(x, y0 + 6 * yStep, y0 + 7 * yStep – 1);

    /* Yellow */

    GUI_SetColor(cs * 0x101);

    GUI_DrawVLine(x, y0 + 7 * yStep, y0 + 8 * yStep – 1);

    GUI_SetColor(0xffff +(255 – cs) * 0x10000L);

    GUI_DrawVLine(x, y0 + 8 * yStep, y0 + 9 * yStep – 1);

    /* Cyan */

    GUI_SetColor(cs * 0x10100L);

    GUI_DrawVLine(x, y0 + 9 * yStep, y0 + 10 * yStep – 1);

    GUI_SetColor(0xffff00 +(255 – cs) * 0x1L);

    GUI_DrawVLine(x, y0 + 10 * yStep, y0 + 11 * yStep – 1);

    /* Magenta */

    GUI_SetColor(cs * 0x10001);

    GUI_DrawVLine(x, y0 + 11 * yStep, y0 + 12 * yStep – 1);

    GUI_SetColor(0xff00ff +(255 – cs) * 0x100L);

    GUI_DrawVLine(x, y0 + 12 * yStep, y0 + 13 * yStep – 1);

    }

    }

    /* USER CODE END 0 */

    /**

    * @brief The application entry point.

    * @retval int

    */

    int main(void)

    {

    /* USER CODE BEGIN 1 */

    BUTTON_Handle hButton;//Button handle

    /* USER CODE END 1 */

    /* MCU Configuration——————————————————–*/

    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

    HAL_Init();

    /* Configure the system clock */

    SystemClock_Config();

    /* Initialize all configured peripherals */

    MX_GPIO_Init();

    MX_SPI1_Init();

    /* USER CODE BEGIN 2 */

    Display_init();

    //ILI9341_FillScreen(ILI9341_CYAN);

    GUI_Init();//GUI initialization

    GUI_SetBkColor(GUI_CYAN); // Background color

    GUI_SetColor(GUI_RED); // Pen color

    GUI_Clear(); // Clear screen

    ShowColorBar();

    /* USER CODE END 2 */

    /* Infinite loop */

    /* USER CODE BEGIN WHILE */

    while (1)

    {

    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */

    }

    /* USER CODE END 3 */

    }

    Draw the schematic

    Porting and Simulation of the Open Source GUI Library uC/GUI

    Add the generated .hex file to the chip model and click run.

    Porting and Simulation of the Open Source GUI Library uC/GUI

    The running result is shown in the figure below.

    Porting and Simulation of the Open Source GUI Library uC/GUI

    Conclusion

    uC/GUI is a powerful and flexible graphical user interface library suitable for various embedded applications. Its lightweight and efficient nature makes it an ideal choice for developing embedded graphical interfaces. If you are developing embedded systems and need to implement a graphical user interface, uC/GUI is a solution worth considering.

    Follow our public account, reply in the background

    UCG01

    You will automatically receive the link to this project’s Keil project

    Leave a Comment