Project

General

Profile

Statistics
| Revision:

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

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