Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.77 KB)

1 168 up20180642
#ifndef GRAPH_H_INCLUDED
2
#define GRAPH_H_INCLUDED
3
4 331 up20180642
/**
5
 * @defgroup    graph   graph
6
 * @brief Graph module.
7
 *
8
 * Provides functions, classes and methods for graphic drawing.
9
 *
10
 * @{
11
 */
12
13 261 up20180642
// 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 253 up20180642
// Colors in RBG (8 bit)
23 307 up20180642
#define GRAPH_BLACK             0x000000
24
#define GRAPH_WHITE             0xFFFFFF
25
#define GRAPH_TRANSPARENT       0x00
26
#define GRAPH_RED               0xFF0000
27 253 up20180642
28
// Alpha
29
#define ALPHA_THRESHOLD     0x7F
30
31 331 up20180642
// MACROS
32 183 up20180642
#define GET_ALP(n)          (0xFF & ((n) >> 24))
33 168 up20180642
#define GET_RED(n)          (0xFF & ((n) >> 16))
34
#define GET_GRE(n)          (0xFF & ((n) >>  8))
35
#define GET_BLU(n)          (0xFF & (n      ))
36 183 up20180642
#define GET_COLOR(n)        (0xFFFFFF & (n))
37
#define SET_ALP(n)          (((n)&0xFF) << 24)
38 168 up20180642
#define SET_RED(n)          (((n)&0xFF) << 16)
39
#define SET_GRE(n)          (((n)&0xFF) <<  8)
40
#define SET_BLU(n)          (((n)&0xFF)      )
41 174 up20180642
#define SET_RGB(r,g,b)      (SET_RED(r) | SET_GRE(g) | SET_BLU(b))
42 168 up20180642
43 332 up20180642
/**
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 174 up20180642
uint16_t   (graph_get_XRes)         (void);
61 332 up20180642
/**
62
 * @brief Get screen Y-resolution.
63
 * @return Screen Y-resolution
64
 */
65 174 up20180642
uint16_t   (graph_get_YRes)         (void);
66 332 up20180642
/**
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 208 up20180642
uint16_t   (graph_get_bytes_pixel)  (void);
73 168 up20180642
74 332 up20180642
/**
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 208 up20180642
void (graph_set_pixel_pos)         (unsigned pos          , uint32_t color);
90 168 up20180642
91 331 up20180642
// SCREEN
92 174 up20180642
int (graph_clear_screen)(void);
93 168 up20180642
94 331 up20180642
// DRAW
95 174 up20180642
int (graph_draw)(void);
96 168 up20180642
97 331 up20180642
/**
98
 * @}
99 285 up20180642
 */
100
101 168 up20180642
#endif /* end of include guard: GRAPH_H_INCLUDED */