ucglib_xmega_hal  4.0
Xmega Hardware Abstraction Layer for Ucglib
ucg_bmp.c File Reference

Bitmap facilities for ucglib from Oli Kraus. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "ucg.h"

Functions

void ucg_BitmapPrint (ucg_t *ucg, ucg_int_t xoffset, ucg_int_t yoffset, ucg_int_t width, ucg_int_t height, uint8_t nbytes, const __memx uint8_t *bitmap)
 Prints a bitmap to the display (obsolete) More...
 
void ucg_DrawBmpLine (ucg_t *ucg, ucg_int_t xoffset, ucg_int_t yoffset, ucg_int_t dir, ucg_int_t nbytes, uint8_t *bitLine)
 Draws a bitmap line to the display. More...
 
void ucg_DrawBmp (ucg_t *ucg, ucg_int_t xoffset, ucg_int_t yoffset, ucg_int_t delay, ucg_int_t width, ucg_int_t height, uint8_t nbytes, const __memx uint8_t *bitmap)
 Draws a bitmap to the display. More...
 
void ucg_DrawBmpRotate (ucg_t *ucg, ucg_int_t xoffset, ucg_int_t yoffset, ucg_int_t dir, ucg_int_t delay, ucg_int_t width, ucg_int_t height, uint8_t nbytes, const __memx uint8_t *bitmap)
 Draws a (rotated) bitmap to the display. More...
 

Variables

const ucg_pgm_uint8_t ucg_st7735_set_pos_dir0_seq []
 extern const from ucg_dev_ic_st7735.c for printing left->right
 
const ucg_pgm_uint8_t ucg_st7735_set_pos_dir1_seq []
 extern const from ucg_dev_ic_st7735.c for printing top->bottom
 
const ucg_pgm_uint8_t ucg_st7735_set_pos_dir2_seq []
 extern const from ucg_dev_ic_st7735.c for printing right->left
 
const ucg_pgm_uint8_t ucg_st7735_set_pos_dir3_seq []
 extern const from ucg_dev_ic_st7735.c for printing bottom->top
 

Detailed Description

Bitmap facilities for ucglib from Oli Kraus.

Author
Wim Dolman (w.e.dolman@hva.nl)
Date
30-09-2020
Version
4.0

This is an addition to the c-implementation of Oli Kraus.

The functions ucg_DrawBmpLine(), ucg_DrawBmp(), ucg_DrawBmpRotate() print a bitmap to the display. The bitmap is a const __memx uint8_t array in plain C. The maximum bitmap size is 32768 kB. To show large images the image must be split in smaller bitmaps. With __memx the 64K of the program memory can be exceeded.

Normally bitmap images are large. The Atmel couldn't address memory beyond 64K without special actions. There are two ways to read beyond 64K: using PROGMEM with far pointers or using __memx. The first option the user must decide which part of thecis used. As long as the application you within tthe 64K 16-bits pointers otherwise you need far-pointers The charme of the latest is that the compiler does the job. The drawback is that it uses 24-pointers which is a little bit slower. Kraus uses flash for commandstrings and fonts. The libraryfunctions uses 16-bits pointer (e.g. pgm_read_byte()). If you mix with large __memx array's the compiler mightnplace commandstrings and fonts beyond 64K. This reults in unaspected behavior. The solution is to place commandstrings in RAM and use __memx with the font functions, the commandsrings are relative small and the fonts can be large. A __memx based use_fonts.c must be used.

The function ucg_DrawBmpLine() and ucg_DrawBmp() use commandstrings that are dependent of the display type. In this case the four commandstrings for ST7735 are used, which are declared in ucg_dev_ic_st7735.c. It is better to use and problaby change display callback functions. So you can use this solution with every display.

Originally these functionality was added in the Xmega Hardware Abstraction Layer (version 2.0, 2.1 and 3.0). From vesion 4.0 this functionality is separated from the HAL.

Function Documentation

◆ ucg_BitmapPrint()

void ucg_BitmapPrint ( ucg_t *  ucg,
ucg_int_t  xoffset,
ucg_int_t  yoffset,
ucg_int_t  width,
ucg_int_t  height,
uint8_t  nbytes,
const __memx uint8_t *  bitmap 
)

Prints a bitmap to the display (obsolete)

Parameters
ucgpointer to struct for the display
xoffsetthe x-position of the upper left corner of the bitmap
yoffsetthe y-position of the upper left corner of the bitmap
widththe width of the bitmap in pixels
heightthe height of the bitmap in pixels
nbytesthe number of bytes of one pixel; must always be 3 (RGB)
bitmapthe pointer to a const unit8_t array with the bitmap.
             The bitmap must be smaller than 32K (largest AVR variable)
             Large bitmaps can be split in smaller parts
             The bitmaps can be located in the program memory or in the
             data memory:
             -# 'const uint8_t array[]' will be placed the data memory.
                    for atXmega256a3u devices the largest array ia 16K.
             -# 'const uint8_t __flash array[]' will be placed only in the program memory.
                    for atXmega256a3u devices the maximum space is 64K
             -# 'const uint8_t array[] PROGMEM' will be placed only in the program memory.
                    for atXmega256a3u devices the maximum space is 64K 
             -# 'const uint8_t __memx array[]' will be placed only in the program memory.
                    with __memx the complete program space can be used 
                    for atXmega256a3u devices the maximum space is 256K

            The drawback of using __memx is that it is slower than __flash. This is
            because _memx uses a 24-bits pointer and __flash uses a 16-bit pointer.

            This function is renamed.
            The original function calls the much faster function ucg_DrawBmp
Returns
void

◆ ucg_DrawBmp()

void ucg_DrawBmp ( ucg_t *  ucg,
ucg_int_t  xoffset,
ucg_int_t  yoffset,
ucg_int_t  delay,
ucg_int_t  width,
ucg_int_t  height,
uint8_t  nbytes,
const __memx uint8_t *  bitmap 
)

Draws a bitmap to the display.

Parameters
ucgpointer to struct for the display
xoffsetthe x-position of the upper left corner of the bitmap
yoffsetthe y-position of the upper left corner of the bitmap
delaya delay after each line drawn to get a wipe style
widththe width of the bitmap in pixels
heightthe height of the bitmap in pixels
nbytesthe number of bytes of one pixel; must always be 3 (RGB)
bitmapthe pointer to a const unit8_t array with the bitmap.
             The bitmap must be smaller than 32K (largest AVR variable)
             Large bitmaps can be split in smaller parts
             The bitmaps can be located in the program memory or in the
             data memory:
             -# 'const uint8_t array[]' will be placed the data memory.
                    for atXmega256a3u devices the largest array ia 16K.
             -# 'const uint8_t __flash array[]' will be placed only in the program memory.
                    for atXmega256a3u devices the maximum space is 64K
             -# 'const uint8_t array[] PROGMEM' will be placed only in the program memory.
                    for atXmega256a3u devices the maximum space is 64K 
             -# 'const uint8_t __memx array[]' will be placed only in the program memory.
                    with __memx the complete program space can be used 
                    for atXmega256a3u devices the maximum space is 256K

            The drawback of using __memx is that it is a little bit slower (< 2%) than 
            __flash. This is because _memx uses a 24-bits pointer and __flash 
            uses a 16-bit pointer.

            This function replaces the earlier function ucg_BitmapPrint
Returns
void

◆ ucg_DrawBmpLine()

void ucg_DrawBmpLine ( ucg_t *  ucg,
ucg_int_t  xoffset,
ucg_int_t  yoffset,
ucg_int_t  dir,
ucg_int_t  nbytes,
uint8_t *  bitLine 
)

Draws a bitmap line to the display.

Parameters
ucgpointer to struct for the display
xoffsetthe x-position of the upper left corner of the bitmap line
yoffsetthe y-position of the upper left corner of the bitmap line
dirthe direction of the bitmap 0 (normal), 1 (+90*), 2 (180*) or 3 (270*)
nbytesthe number of bytes to be sent
bitLinethe pointer to a const unit8_t array with the bitmap line.
Returns
void

◆ ucg_DrawBmpRotate()

void ucg_DrawBmpRotate ( ucg_t *  ucg,
ucg_int_t  xoffset,
ucg_int_t  yoffset,
ucg_int_t  dir,
ucg_int_t  delay,
ucg_int_t  width,
ucg_int_t  height,
uint8_t  nbytes,
const __memx uint8_t *  bitmap 
)

Draws a (rotated) bitmap to the display.

Parameters
ucgpointer to struct for the display
xoffsetthe x-position of the upper left corner of the bitmap
yoffsetthe y-position of the upper left corner of the bitmap
dirthe direction of the bitmap 0 (normal), 1 (+90*), 2 (180*) or 3 (270*)
delaya delay (in us) after each line drawn to get a wipe style
widththe width of the bitmap in pixels
heightthe height of the bitmap in pixels
nbytesthe number of bytes of one pixel; must always be 3 (RGB)
bitmapthe pointer to a const unit8_t array with the bitmap.
             The bitmap must be smaller than 32K (largest AVR variable)
             Large bitmaps can be split in smaller parts
             The bitmaps can be located in the program memory or in the
             data memory:
             -# 'const uint8_t array[]' will be placed the data memory.
                    for atXmega256a3u devices the largest array ia 16K.
             -# 'const uint8_t __flash array[]' will be placed only in the program memory.
                    for atXmega256a3u devices the maximum space is 64K
             -# 'const uint8_t array[] PROGMEM' will be placed only in the program memory.
                    for atXmega256a3u devices the maximum space is 64K 
             -# 'const uint8_t __memx array[]' will be placed only in the program memory.
                    with __memx the complete program space can be used 
                    for atXmega256a3u devices the maximum space is 256K

            The drawback of using __memx is that it is a little bit slower than 
            __flash. This is because _memx uses a 24-bits pointer and __flash 
            uses a 16-bit pointer.

            This function is a little slower (< 10%) than ucg_DrawBmp
Returns
void