Project

General

Profile

Statistics
| Revision:

root / proj / libs / graph / include / graph.h @ 332

History | View | Annotate | Download (2.77 KB)

1
#ifndef GRAPH_H_INCLUDED
2
#define GRAPH_H_INCLUDED
3

    
4
/**
5
 * @defgroup    graph   graph
6
 * @brief Graph module.
7
 *
8
 * Provides functions, classes and methods for graphic drawing.
9
 *
10
 * @{
11
 */
12

    
13
// Graphics modes
14
#define INDEXED_1024_768        0x105
15
#define DIRECT_640_480_888      0x110
16
#define DIRECT_800_600_888      0x115
17
#define DIRECT_1024_768_888     0x118
18
#define DIRECT_1280_1024_565    0x11A
19
#define DIRECT_1280_1024_888    0x11B
20
#define LINEAR_FRAME_BUFFER_MD  BIT(14)
21

    
22
// Colors in RBG (8 bit)
23
#define GRAPH_BLACK             0x000000
24
#define GRAPH_WHITE             0xFFFFFF
25
#define GRAPH_TRANSPARENT       0x00
26
#define GRAPH_RED               0xFF0000
27

    
28
// Alpha
29
#define ALPHA_THRESHOLD     0x7F
30

    
31
// MACROS
32
#define GET_ALP(n)          (0xFF & ((n) >> 24))
33
#define GET_RED(n)          (0xFF & ((n) >> 16))
34
#define GET_GRE(n)          (0xFF & ((n) >>  8))
35
#define GET_BLU(n)          (0xFF & (n      ))
36
#define GET_COLOR(n)        (0xFFFFFF & (n))
37
#define SET_ALP(n)          (((n)&0xFF) << 24)
38
#define SET_RED(n)          (((n)&0xFF) << 16)
39
#define SET_GRE(n)          (((n)&0xFF) <<  8)
40
#define SET_BLU(n)          (((n)&0xFF)      )
41
#define SET_RGB(r,g,b)      (SET_RED(r) | SET_GRE(g) | SET_BLU(b))
42

    
43
/**
44
 * @brief Initialize graphics.
45
 * @param   mode    Graphics mode to use
46
 * @return  SUCCESS if operation was successful, other value otherwise
47
 */
48
int (graph_init)(uint16_t mode);
49

    
50
/**
51
 * @brief Cleanup graphics.
52
 * @return  SUCCESS if operation was successful, other value otherwise
53
 */
54
int (graph_cleanup)(void);
55

    
56
/**
57
 * @brief Get screen X-resolution.
58
 * @return Screen X-resolution
59
 */
60
uint16_t   (graph_get_XRes)         (void);
61
/**
62
 * @brief Get screen Y-resolution.
63
 * @return Screen Y-resolution
64
 */
65
uint16_t   (graph_get_YRes)         (void);
66
/**
67
 * @brief Get number of bytes per pixel.
68
 *
69
 * That is, the number of bytes needed to encode the color of a pixel.
70
 * @return Number of bytes per pixel
71
 */
72
uint16_t   (graph_get_bytes_pixel)  (void);
73

    
74
/**
75
 * @brief Draw pixel with color.
76
 * @param   x       X-position of pixel to draw
77
 * @param   y       Y-position of pixel to draw
78
 * @param   color   Color that will be used to draw the pixel
79
 * @return  SUCCESS if operation was successful, other value otherwise
80
 */
81
void (graph_set_pixel)             (uint16_t x, uint16_t y, uint32_t color);
82
/**
83
 * @brief Draw pixel with color using position.
84
 *
85
 * Position is calculated from y*WIDTH+x.
86
 * @param   pos     Position
87
 * @param   color   Color that will be used to draw the pixel
88
 */
89
void (graph_set_pixel_pos)         (unsigned pos          , uint32_t color);
90

    
91
// SCREEN
92
int (graph_clear_screen)(void);
93

    
94
// DRAW
95
int (graph_draw)(void);
96

    
97
/**
98
 * @}
99
 */
100

    
101
#endif /* end of include guard: GRAPH_H_INCLUDED */