1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/pkg/ucglib/README.md
Bas Stottelaar 7d73e8acaf pkg/ucglib: refactor the Ucglib package
- Passing RIOT-OS specific data as user_ptr
- Added necessary macros to Makefile.dep
- Added missing explicit dependency to xtimer module
- Added ucg_riotos.h with the RIOT-OS specific functionality
- Removed the now-obsolete patch of Ucglib
- Other minor fixes
2020-06-17 00:47:54 +02:00

1.9 KiB

Ucglib

Introduction

Ucglib is a color graphics library for LCDs and OLEDs. It contains both drivers and high-level drawing routines.

The library is originally written for Arduino boards, but it runs just fine on other platforms, as long as the right drivers are available.

Usage

Just put USEPKG += ucglib in your Makefile and #include "ucg.h" to your code. Refer to the Ucglib wiki for more information on the API.

RIOT-OS interface

This package patches the original source to add an interface for RIOT-OS.

Only the callback for SPI peripherals is supported:

  • ucg_com_hw_spi_riotos

These methods require a structure containing peripheral information (ucg_riotos_t), that is set using the ucg_SetUserPtr function. This structure contains the peripheral and pin mapping.

If the above interface is not sufficient, it is still possible to write a dedicated interface by (re-)implementing the methods above. Refer to the Ucglib wiki for more information.

Example

ucg_t ucg;

ucg_riotos_t user_data =
{
    .device_index = SPI_DEV(0),
    .pin_cs = GPIO_PIN(PA, 0),
    .pin_cd = GPIO_PIN(PA, 1),
    .pin_reset = GPIO_PIN(PA, 2)
};

ucg_SetUserPtr(&ucg, &user_data);

ucg_Init(&ucg, ucg_dev_ssd1331_18x96x64_univision, ucg_ext_ssd1331_18, ucg_com_hw_spi_riotos);

Virtual displays

For targets without SPI, a virtual display is available. Support for a virtual display is not compiled by default.

  • By adding USEMODULE += ucglib_sdl, a SDL virtual display will be used. This is only available on native targets that have SDL2 installed. It uses sdl2-config to find the headers and libraries. Note that RIOT-OS builds 32-bit binaries and requires 32-bit SDL2 libraries.

Example

ucg_t ucg;

ucg_Init(&ucg, ucg_sdl_dev_cb, ucg_ext_none, NULL);