1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 00:09:46 +01:00
RIOT/pkg/ucglib
2022-03-17 14:33:07 +01:00
..
contrib Merge pull request #17309 from aabadie/pr/pkg/ztimer 2021-12-07 09:13:39 +01:00
doc.txt doc/pkg: include some Readme.md within doc.txt 2022-01-25 17:41:40 +01:00
Kconfig treewide: make all modules use Kconfig ZTIMER_USEC indirection 2022-03-17 14:33:07 +01:00
Makefile pkg: silent make commands with RIOT_CI_BUILD=1 2021-03-12 16:05:18 +01:00
Makefile.dep pkg/ucglib: migrate to ztimer 2021-12-01 17:54:55 +01:00
Makefile.include pkg/ucglib: refactor the Ucglib package 2020-06-17 00:47:54 +02:00
Makefile.ucglib pkg/ucglib: clean build system integration 2020-06-12 17:55:29 +02:00
Makefile.ucglib_csrc pkg/ucglib: clean build system integration 2020-06-12 17:55:29 +02:00
Makefile.ucglib_sdl pkg/ucglib: clean build system integration 2020-06-12 17:55:29 +02:00
README.md pkg/ucglib: refactor the Ucglib package 2020-06-17 00:47:54 +02:00

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);