-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusec_dev.h
125 lines (104 loc) · 4.17 KB
/
usec_dev.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef __USEC_DEV_H_
#define __USEC_DEV_H_
#include <stdint.h>
#include <stddef.h>
/******************************************************************************/
#define USEC_DEV_OK (0)
#define USEC_DEV_ERR (1)
/* enable/disable logs */
#define USEC_DEV_DEBUG_LOG (0)
/* do not modify */
#define USEC_DEV_FAST_WRITE (1)
#define USEC_DEV_SENSE_LEN (256)
#define USEC_DEV_BLOCK_LEN (32)
#define USEC_DEV_TIMEOUT (50000)
#define USEC_DEV_SPT_LEN (60*1024)
/******************************************************************************/
/*
* Update modes:
* (source: https://github.com/m5stack/M5EPD/blob/main/src/M5EPD_Driver.h)
*
* UPDATE_MODE_INIT - is used to completely erase the display and leave it in
* the white state. It is useful for situations where the display information in
* memory is not a faithful representation of the optical state of the display,
* for example, after the device receives power after it has been fully powered
* down.
*
* UPDATE_MODE_DU - is a very fast, non-flashy update. This mode supports
* transitions from any graytone to black or white only. It cannot be used to
* update to any graytone other than black or white.
*
* UPDATE_MODE_GC16 - is used to update the full display and provide a high
* image quality. When GC16 is used with Full Display Update the entire display
* will update as the new image is written. If a Partial Update command is used
* the only pixels with changing graytone values will update. The GC16 mode has
* 16 unique gray levels.
*
* UPDATE_MODE_GL16 - is primarily used to update sparse content on a white
* background, such as a page of anti-aliased text, with reduced flash. The GL16
* waveform has 16 unique gray levels.
*
* UPDATE_MODE_A2 - is a fast, non-flash update mode designed for fast paging
* turning or simple black/white animation. This mode supports transitions from
* and to black or white only. It cannot be used to update to any graytone other
* than black or white.
*
* UPDATE_MODE_DU4 - is a fast update time (similar to UPDATE_MODE_DU),
* non-flashy waveform. This mode supports gray-gray transitions.
*/
enum
{
UPDATE_MODE_INIT,
UPDATE_MODE_DU,
UPDATE_MODE_GC16,
UPDATE_MODE_GL16,
UPDATE_MODE_A2,
UPDATE_MODE_DU4
};
/******************************************************************************/
enum
{
IMG_1BPP,
IMG_2BPP,
IMG_4BPP,
IMG_8BPP
};
/******************************************************************************/
typedef struct
{
int dev_fd[1]; /* device file descriptor */
uint32_t dev_width[1]; /* screen width [px] */
uint32_t dev_height[1]; /* screen height [px] */
uint32_t dev_addr[1]; /* only for internal usage */
uint8_t *dev_sense_buf; /* only for internal usage */
} usec_ctx;
/******************************************************************************/
usec_ctx *
usec_init (const uint8_t *dev_path);
void
usec_deinit (usec_ctx *ctx);
uint8_t
usec_get_temp (usec_ctx *ctx,
uint8_t *temp_val);
uint8_t
usec_get_vcom (usec_ctx *ctx,
uint16_t *vcom_val);
uint8_t
usec_img_upload (usec_ctx *ctx,
uint8_t *img_data,
size_t img_size,
uint8_t img_bpp,
uint32_t img_pos_x,
uint32_t img_pos_y,
uint32_t img_width,
uint32_t img_height);
uint8_t
usec_img_update (usec_ctx *ctx,
uint32_t area_pos_x,
uint32_t area_pos_y,
uint32_t area_width,
uint32_t area_height,
uint8_t update_mode,
uint8_t update_wait);
/******************************************************************************/
#endif /* __USEC_DEV_H_ */