-
Notifications
You must be signed in to change notification settings - Fork 0
/
St7735s.h
70 lines (57 loc) · 1.36 KB
/
St7735s.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
#ifndef _ST7735S_H_
#define _ST7735S_H_
#include <cstdint>
#include <mbed.h>
/**
* ST7735S LCD controller driver module
*/
class St7735s {
public:
St7735s(SPI& spi, DigitalOut& cs, DigitalOut& rs, DigitalOut& reset);
void init(uint8_t width, uint8_t height, uint8_t start_x, uint8_t start_y);
protected:
inline void cmd(uint8_t command, size_t data_len, uint8_t* data) {
cs_ = 0;
rs_ = 0; // 0 for command data, 1 for display data
spi_.write(command);
rs_ = 1;
spi_.write((char*)data, data_len, NULL, 0);
cs_ = 1;
}
void set_window(uint8_t width, uint8_t height, uint8_t start_x, uint8_t start_y);
SPI &spi_;
DigitalOut &cs_, &rs_, &reset_;
enum Cmd {
SLPIN = 0x10,
SLPOUT = 0x11,
PTLON = 0x12,
NORON = 0x13,
INVOFF = 0x20,
INVON = 0x21,
GAMSET = 0x26,
DISPOFF = 0x28,
DISPON = 0x29,
CASET = 0x2A,
RASET = 0x2B,
RAMWR = 0x2C,
RGBSET = 0x2D,
RAMRD = 0x2E,
MADCTL = 0x36,
COLMOD = 0x3A, // pixel mode
};
enum PixelFormat {
IFPF_12B = 3,
IFPF_16B = 5,
IFPF_18B = 6,
IFPF_UNUSED = 7,
};
enum MemoryAccess {
MADCTL_MX = 1 << 6, // mirror X
MADCTL_MY = 1 << 7, // mirror Y
MADCTL_MV = 1 << 5, // transpose
MADCTL_ML = 1 << 4, // transpose
MADCTL_BGR = 1 << 3, // transpose
MADCTL_MH = 1 << 2, // transpose
};
};
#endif