![]() |
ucglib_xmega_hal
2.1
Xmega Hardware Abstraction Layer for Ucglib
|
This is the Xmega Hardware Abstraction Layer for the C implementation of the ucglib library from Oli Kraus
The C implementation of the ucglib library can be found at https://github.com/olikraus/ucglib/tree/master/csrc
This HAL contains four c- and h-files:
ucglib_xmega_hal.c | Functions for the HAL |
ucglib_xmega_hal.h | Prototypes and definitions of the HAL |
ucg.h | An adjusted ucg.h with a extra hook for printing facilities |
main.c | An example for a 1.8 inch TFT LCD Module |
The struct ucg_t
in the adjusted ucg.h
has an extra field at the end on the struct:
* #ifdef __AVR_XMEGA__ * void *xmega_hook; // added pointer for print hook * #endif
The examples uses the 32 MHz clock. So you need clock.c and clock.h from http://dolman-wim.nl/xmega/libraries/index.php
These are the steps foor using ucglib with a Xmega
* Display Xmega * VCC 3V3 * GND GND * CS D4 (SS) * RESET D3 * A0 (DC or CD) D2 * SDA D5 (MOSI) * SCK D7 (SCK) * LED (BLK) D1 * D6 (MISO) not connected
The test uses this 1.8 inch TFT LCD Module:
![]() |
The default configuration is using SPI:
* #define UCG_XMEGA_USE UCG_XMEGA_USING_SPI * #define UCG_XMEGA_BLK UCG_XMEGA_BLK_CONNECT * * #define UCG_XMEGA_INTERFACE SPID * #define UCG_XMEGA_SPI_PORT PORTD * * #define UCG_XMEGA_SPI_SCK_bp PIN7_bp * #define UCG_XMEGA_SPI_MISO_bp PIN6_bp * #define UCG_XMEGA_SPI_MOSI_bp PIN5_bp * #define UCG_XMEGA_SPI_SS_bp PIN4_bp * #define UCG_XMEGA_SPI_RESET_bp PIN3_bp * #define UCG_XMEGA_SPI_CD_bp PIN2_bp * #define UCG_XMEGA_SPI_BLK_bp PIN1_bp
This HAL uses for the serial communication SPI or bit banging. With SPI the display must connected to one of the SPI's of the Xmega. With bit banging all connections are available The define UCG_XMEGA_USE in ucglib_xmega_hal.h must be UCG_XMEGA_USING_SPI for SPI and the define UCG_XMEGA_USING_BB for bit banging. The default value is UCG_XMEGA_USING_SPI.
The BLK connection of the display can be connected directly to the Xmega or external to 3V3. The define UCG_XMEGA_BLK in ucglib_xmega_hal.h can have three values: UCG_XMEGA_BLK_CONNECT, UCG_XMEGA_BLK_EXTERN or UCG_XMEGA_BLK_DISABLED. The default value is UCG_XMEGA_BLK_CONNECT.
The option UCG_XMEGA_BLK_DISABLED makes it possible to connect the display direct a side the HvA-Xmegaboard with the BLK (LED) externally connected
![]() |
The connections are listed here:
* Display Xmega/power * VCC 3V3 * GND GND * CS D0 * RESET D1 * A0 (DC or CD) D2 * SDA D3 * SCK D4 * LED (BLK) D5 (Disabled), connect LED direct to 3V3 or 5V
The default configuration is using BB with the TFT-display and the HvA-Xmegaboard is:
* #define UCG_XMEGA_USE UCG_XMEGA_USING_BB * #define UCG_XMEGA_BLK UCG_XMEGA_BLK_DISABLED * * #define UCG_XMEGA_SPI_PORT PORTD * * #define UCG_XMEGA_BB_SCK_bp PIN4_bp * #define UCG_XMEGA_BB_SDA_bp PIN3_bp * #define UCG_XMEGA_BB_CS_bp PIN0_bp * #define UCG_XMEGA_BB_RESET_bp PIN1_bp * #define UCG_XMEGA_BB_CD_bp PIN2_bp * #define UCG_XMEGA_BB_BLK_bp PIN5_bp // pin position is necessary to disable pin
A function ucg_BitmapPrint() is added. This function prints a bitmap to the display. The bitmap is an array with rgb-pixels. The size of the array may not exceed the 32K limit. Pictures larger than 32K must be split in smaller blocks.
Two examples can be found in the folder examples.
A non-AVR program to split a PNG file in multiple arrays can be found in thye folder gcc.
This library is free software. You can redistribute it and/or modify it. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.