mid-level display functions More...
#include <avr/pgmspace.h>
#include "../../font/font.h"
Go to the source code of this file.
Data Structures | |
struct | rectangle_s |
rectangle on display More... | |
Defines | |
#define | HL_LCD_SAVE_SIZE(X0, Y0, X1, Y1) ((((X1+7)/8)-(X0/8))*(Y1-Y0)) |
same as hl_lcd_restore(), but as macro | |
Typedefs | |
typedef struct rectangle_s | rectangle_t |
rectangle on display | |
Enumerations | |
enum | hl_blt_1op { op_clear = 0b00, op_invert = 0b01, op_keep = 0b10, op_set = 0b11 } |
ROPs for one pixel: More... | |
enum | hl_blt_2op { op2_clearall = 0b0000, op2_notand = 0b0001, op2_0010 = 0b0010, op2_notsrc = 0b0011, op2_clearnot = 0b0100, op2_invert = 0b0101, op2_xor = 0b0110, op2_notor = 0b0111, op2_and = 0b1000, op2_1001 = 0b1001, op2_keep = 0b1010, op2_1011 = 0b1011, op2_copysrc = 0b1100, op2_1101 = 0b1101, op2_or = 0b1110, op2_setall = 0b1111 } |
Functions | |
void | hl_lcd_op_pixel (uint8_t x, uint8_t y, hl_blt_1op op) |
operate on a single pixel | |
void | hl_lcd_setall (uint8_t fill) |
fill all display bytes with given pattern | |
void | hl_lcd_set_font (const font_t *f) |
select font to use for text operations | |
void | hl_lcd_get_current_font (font_t *f) |
get data of current font | |
void | hl_lcd_set_current_font (const font_t *f) |
restore font saved with hl_lcd_get_current_font() | |
void | hl_lcd_drawchar (uint8_t x, uint8_t y, char c) |
draw a character at pixel position (x,y) using font set by hl_lcd_set_font() | |
void | hl_lcd_drawchar_font (uint8_t x, uint8_t y, char c, const font_t *f) |
draw a character at pixel position (x,y) using specified font | |
uint8_t | hl_lcd_get_charwidth (void) __attribute__((pure)) |
get width (in pixels) of currently selected font | |
uint8_t | hl_lcd_get_charheight (void) __attribute__((pure)) |
get height (in pixels) of currently selected font | |
void | hl_lcd_drawstr (uint8_t x, uint8_t y, const char *s) |
draw a character string beginning at pixel position (x,y) | |
void | hl_lcd_drawstr_P (uint8_t x, uint8_t y, PGM_P s) |
like hl_lcd_drawstr(), but for strings stored in Flash memory | |
void | hl_lcd_drawstrn (uint8_t x, uint8_t y, const char *s, size_t len) |
like hl_lcd_drawstr(), but draws at most LEN characters | |
void | hl_lcd_drawstrn_P (uint8_t x, uint8_t y, PGM_P s, size_t len) |
like hl_lcd_drawstrn(), but for strings stored in Flash memory | |
void | hl_lcd_clear (void) |
clear complete LCD display | |
void | hl_lcd_scroll_up (rectangle_t win, uint8_t lines) |
scroll display up | |
void | hl_lcd_set_rectangle (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, hl_blt_1op op) |
fill/clear/invert/keep all pixels inside a rectangle | |
void | hl_lcd_set_line_horiz (uint8_t x0, uint8_t y, uint8_t x1, hl_blt_1op op) |
fill/clear/invert/keep a single horizontal display line | |
void | hl_lcd_set_line_vert (uint8_t x, uint8_t y0, uint8_t y1, hl_blt_1op op) |
fill/clear/invert/keep a single horizontal display column | |
size_t | hl_lcd_save (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t *save, size_t size) |
save display area for later re-display at same position | |
size_t | hl_lcd_restore (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, const uint8_t *save, size_t size) |
restore display area stored by hl_lcd_save() at same position | |
size_t | hl_lcd_save_size (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) __attribute__((const )) |
calculate necessary size of buffer for hl_lcd_save() |
mid-level display functions
This file declares functions for display access: simple graphics and text display.
More complex graphics functions like arbitrary lines, circles or ellipses will be implemented when we deem them necessary.
enum hl_blt_1op |
void hl_lcd_drawchar | ( | uint8_t | x, | |
uint8_t | y, | |||
char | c | |||
) |
draw a character at pixel position (x,y) using font set by hl_lcd_set_font()
hl_lcd_drawchar() draws a character at an arbitrary position
x | X coordinate of upper left character box corner | |
y | Y coordinate of upper left character box corner | |
c | character to draw (pattern and size is defined by previous call to hl_lcd_set_font()) |
{ hl_lcd_drawchar_priv (x, y, c, ¤t_font); }
void hl_lcd_drawchar_font | ( | uint8_t | x, | |
uint8_t | y, | |||
char | c, | |||
const font_t * | f | |||
) |
draw a character at pixel position (x,y) using specified font
hl_lcd_drawchar_font() draws a character at an arbitrary position
x | X coordinate of upper left character box corner | |
y | Y coordinate of upper left character box corner | |
c | character to draw (pattern and size is defined by the next parameter) | |
f | font to use for that character |
{ font_priv_t p; hl_lcd_set_font_priv (&p, f); hl_lcd_drawchar_priv (x, y, c, &p); }
void hl_lcd_drawstr | ( | uint8_t | x, | |
uint8_t | y, | |||
const char * | s | |||
) |
draw a character string beginning at pixel position (x,y)
hl_lcd_drawstr() may be implemented in a more efficient way than calling hl_lcd_drawchar multiple times, especially for char_width != 8 pixel or x8 != 0
{ hl_lcd_drawstr_internal (x, y, s, -1, DRAWSTR_MEM_RAM | DRAWSTR_STOP0_STOP); }
void hl_lcd_op_pixel | ( | uint8_t | x, | |
uint8_t | y, | |||
hl_blt_1op | op | |||
) |
operate on a single pixel
hl_lcd_op_pixel() operates on a single pixel given by its coordinates
x | X coordinate of pixel | |
y | Y coordinate of pixel | |
op | what to do to given pixel |
size_t hl_lcd_save | ( | uint8_t | x0, | |
uint8_t | y0, | |||
uint8_t | x1, | |||
uint8_t | y1, | |||
uint8_t * | save, | |||
size_t | size | |||
) |
save display area for later re-display at same position
DO NOT RELY ON THE FORMAT OF THE STORED DATA! This may change depending on implementation and even depending on the position paramaters. You may copy the data around or discard it. Restore is only guaranteed to work to the exact same position and size the data was saved from.
void hl_lcd_scroll_up | ( | rectangle_t | win, | |
uint8_t | lines | |||
) |
scroll display up
hl_lcd_scroll_up() scrolls up the display for the specified number of lines
win | window to use for scrolling | |
lines | lines to scroll up (in pixels) |
void hl_lcd_set_current_font | ( | const font_t * | f | ) |
restore font saved with hl_lcd_get_current_font()
The difference to hl_lcd_set_font() is that here we expect *f to be in RAM instead of in FLASH.
{ current_font.font = *f; hl_lcd_set_font_calc (¤t_font); }
void hl_lcd_set_line_horiz | ( | uint8_t | x0, | |
uint8_t | y, | |||
uint8_t | x1, | |||
hl_blt_1op | op | |||
) | [inline] |
fill/clear/invert/keep a single horizontal display line
This is a special case of hl_lcd_set_rectangle().
{ hl_lcd_set_rectangle (x0,y, x1,y+1, op); }
void hl_lcd_set_line_vert | ( | uint8_t | x, | |
uint8_t | y0, | |||
uint8_t | y1, | |||
hl_blt_1op | op | |||
) | [inline] |
fill/clear/invert/keep a single horizontal display column
This is a special case of hl_lcd_set_rectangle().
{ hl_lcd_set_rectangle (x,y0, x+1,y1, op); }
void hl_lcd_set_rectangle | ( | uint8_t | x0, | |
uint8_t | y0, | |||
uint8_t | x1, | |||
uint8_t | y1, | |||
hl_blt_1op | op | |||
) |
fill/clear/invert/keep all pixels inside a rectangle
(x0,y0) is inclusive, (x1,y1) is exclusive
void hl_lcd_setall | ( | uint8_t | fill | ) |
fill all display bytes with given pattern
fill | 8-bit byte pattern to write to display |
{ uint8_t x, y; /* increment X and after each X wrap-around, Y */ HL_LCD_WriteCmd (HL_LCD_INC_CTRL /*| HL_LCD_INC_CTRL_AIM */ | HL_LCD_INC_CTRL_AYI | HL_LCD_INC_CTRL_AXI); HL_LCD_SetX (0); HL_LCD_SetY (0); for (y = 0; y < HL_LCD_HEIGHT; y++) { for (x = 0; x < HL_LCD_WIDTH_BYTES+2; x++) { HL_LCD_WriteData (fill); } } HL_LCD_WriteCmd (HL_LCD_INC_CTRL); /* disable auto-increment */ }