Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.99 KB)

1 168 up20180642
#ifndef GRAPH_H_INCLUDED
2
#define GRAPH_H_INCLUDED
3
4 331 up20180642
/**
5
 * @defgroup    graph   graph
6 351 up20180642
 * @ingroup libs
7 331 up20180642
 * @brief Graph module.
8
 *
9
 * Provides functions, classes and methods for graphic drawing.
10
 *
11
 * @{
12
 */
13
14 261 up20180642
// Graphics modes
15 336 up20180642
/// @brief Indexed graphic mode, 1024x768 px
16 261 up20180642
#define INDEXED_1024_768        0x105
17 336 up20180642
/// @brief Direct graphic mode, 640x480 px, RGB = 888 bits
18 261 up20180642
#define DIRECT_640_480_888      0x110
19 336 up20180642
/// @brief Direct graphic mode, 800x600 px, RGB = 888 bits
20 261 up20180642
#define DIRECT_800_600_888      0x115
21 336 up20180642
/// @brief Direct graphic mode, 1024x768 px, RGB = 888 bits
22 261 up20180642
#define DIRECT_1024_768_888     0x118
23 336 up20180642
/// @brief Direct graphic mode, 1280x1024 px, RGB = 565 bits
24 261 up20180642
#define DIRECT_1280_1024_565    0x11A
25 336 up20180642
/// @brief Direct graphic mode, 1280x1024 px, RGB = 888 bits
26 261 up20180642
#define DIRECT_1280_1024_888    0x11B
27
28 253 up20180642
// Colors in RBG (8 bit)
29 336 up20180642
/// @brief Black color
30 307 up20180642
#define GRAPH_BLACK             0x000000
31 336 up20180642
/// @brief White color
32 307 up20180642
#define GRAPH_WHITE             0xFFFFFF
33 336 up20180642
/// @brief Transparent
34 307 up20180642
#define GRAPH_TRANSPARENT       0x00
35 336 up20180642
/// @brief Red color
36 307 up20180642
#define GRAPH_RED               0xFF0000
37 253 up20180642
38 336 up20180642
/// @brief Alpha threshold, from which it is either considered transparent or opaque
39 253 up20180642
#define ALPHA_THRESHOLD     0x7F
40
41 332 up20180642
/**
42
 * @brief Initialize graphics.
43
 * @param   mode    Graphics mode to use
44
 * @return  SUCCESS if operation was successful, other value otherwise
45
 */
46
int (graph_init)(uint16_t mode);
47
48
/**
49
 * @brief Cleanup graphics.
50
 * @return  SUCCESS if operation was successful, other value otherwise
51
 */
52
int (graph_cleanup)(void);
53
54
/**
55
 * @brief Get screen X-resolution.
56
 * @return Screen X-resolution
57
 */
58 174 up20180642
uint16_t   (graph_get_XRes)         (void);
59 332 up20180642
/**
60
 * @brief Get screen Y-resolution.
61
 * @return Screen Y-resolution
62
 */
63 174 up20180642
uint16_t   (graph_get_YRes)         (void);
64 332 up20180642
/**
65
 * @brief Get number of bytes per pixel.
66
 *
67
 * That is, the number of bytes needed to encode the color of a pixel.
68
 * @return Number of bytes per pixel
69
 */
70 208 up20180642
uint16_t   (graph_get_bytes_pixel)  (void);
71 168 up20180642
72 332 up20180642
/**
73
 * @brief Draw pixel with color.
74
 * @param   x       X-position of pixel to draw
75
 * @param   y       Y-position of pixel to draw
76
 * @param   color   Color that will be used to draw the pixel
77
 * @return  SUCCESS if operation was successful, other value otherwise
78
 */
79
void (graph_set_pixel)             (uint16_t x, uint16_t y, uint32_t color);
80
/**
81
 * @brief Draw pixel with color using position.
82
 *
83
 * Position is calculated from y*WIDTH+x.
84
 * @param   pos     Position
85
 * @param   color   Color that will be used to draw the pixel
86
 */
87 208 up20180642
void (graph_set_pixel_pos)         (unsigned pos          , uint32_t color);
88 168 up20180642
89 333 up20180642
/**
90
 * @brief Clear screen, painting it black.
91
 * @return  SUCCESS if operation was successful, other value otherwise
92
 */
93 174 up20180642
int (graph_clear_screen)(void);
94 168 up20180642
95 333 up20180642
/**
96
 * @brief Draw everything on the buffer to the screen.
97
 * @return  SUCCESS if operation was successful, other value otherwise
98
 */
99 174 up20180642
int (graph_draw)(void);
100 168 up20180642
101 331 up20180642
/**
102
 * @}
103 285 up20180642
 */
104
105 168 up20180642
#endif /* end of include guard: GRAPH_H_INCLUDED */