Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.46 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
21 253 up20180642
// Colors in RBG (8 bit)
22 307 up20180642
#define GRAPH_BLACK             0x000000
23
#define GRAPH_WHITE             0xFFFFFF
24
#define GRAPH_TRANSPARENT       0x00
25
#define GRAPH_RED               0xFF0000
26 253 up20180642
27
// Alpha
28
#define ALPHA_THRESHOLD     0x7F
29
30 332 up20180642
/**
31
 * @brief Initialize graphics.
32
 * @param   mode    Graphics mode to use
33
 * @return  SUCCESS if operation was successful, other value otherwise
34
 */
35
int (graph_init)(uint16_t mode);
36
37
/**
38
 * @brief Cleanup graphics.
39
 * @return  SUCCESS if operation was successful, other value otherwise
40
 */
41
int (graph_cleanup)(void);
42
43
/**
44
 * @brief Get screen X-resolution.
45
 * @return Screen X-resolution
46
 */
47 174 up20180642
uint16_t   (graph_get_XRes)         (void);
48 332 up20180642
/**
49
 * @brief Get screen Y-resolution.
50
 * @return Screen Y-resolution
51
 */
52 174 up20180642
uint16_t   (graph_get_YRes)         (void);
53 332 up20180642
/**
54
 * @brief Get number of bytes per pixel.
55
 *
56
 * That is, the number of bytes needed to encode the color of a pixel.
57
 * @return Number of bytes per pixel
58
 */
59 208 up20180642
uint16_t   (graph_get_bytes_pixel)  (void);
60 168 up20180642
61 332 up20180642
/**
62
 * @brief Draw pixel with color.
63
 * @param   x       X-position of pixel to draw
64
 * @param   y       Y-position of pixel to draw
65
 * @param   color   Color that will be used to draw the pixel
66
 * @return  SUCCESS if operation was successful, other value otherwise
67
 */
68
void (graph_set_pixel)             (uint16_t x, uint16_t y, uint32_t color);
69
/**
70
 * @brief Draw pixel with color using position.
71
 *
72
 * Position is calculated from y*WIDTH+x.
73
 * @param   pos     Position
74
 * @param   color   Color that will be used to draw the pixel
75
 */
76 208 up20180642
void (graph_set_pixel_pos)         (unsigned pos          , uint32_t color);
77 168 up20180642
78 333 up20180642
/**
79
 * @brief Clear screen, painting it black.
80
 * @return  SUCCESS if operation was successful, other value otherwise
81
 */
82 174 up20180642
int (graph_clear_screen)(void);
83 168 up20180642
84 333 up20180642
/**
85
 * @brief Draw everything on the buffer to the screen.
86
 * @return  SUCCESS if operation was successful, other value otherwise
87
 */
88 174 up20180642
int (graph_draw)(void);
89 168 up20180642
90 331 up20180642
/**
91
 * @}
92 285 up20180642
 */
93
94 168 up20180642
#endif /* end of include guard: GRAPH_H_INCLUDED */