roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
st7735.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
8
9namespace roo_display {
10
11namespace st7735 {
12
13static const uint32_t kSpiFrequency = 20 * 1000 * 1000;
14
16
17enum Command {
18 INVCTR = 0xB4,
19
20 PWCTR1 = 0xC0,
21 PWCTR2 = 0xC1,
22 PWCTR3 = 0xC2,
23 PWCTR4 = 0xC3,
24 PWCTR5 = 0xC4,
25
26 VMCTR1 = 0xC5,
27
28 GMCTRP1 = 0xE0,
29 GMCTRN1 = 0xE1,
30};
31
32struct Init {
33 template <typename Target>
35 int16_t yend, bool inverted = false) const {
36 using namespace ::roo_display::st77xx;
37 t.writeCommand(SWRESET, {}, 120);
38 t.writeCommand(SLPOUT, {}, 120);
39 t.writeCommand(INVCTR, {0x07});
40 t.writeCommand(PWCTR1, {0xA2, 0x02, 0x84});
41 t.writeCommand(PWCTR2, {0xC5});
42 t.writeCommand(PWCTR3, {0x0A, 0x00});
43 t.writeCommand(PWCTR4, {0x8A, 0x2A});
44 t.writeCommand(PWCTR5, {0x8A, 0xEE});
45 t.writeCommand(VMCTR1, {0x0E});
46 t.writeCommand(MADCTL, {0xC8});
47 t.writeCommand(COLMOD, {0x05});
48 // Note: ST7735 has max. 132x162 resolution.
49 t.writeCommand(CASET, {0x00, (uint8_t)xstart, 0x00, (uint8_t)xend});
50 t.writeCommand(RASET, {0x00, (uint8_t)ystart, 0x00, (uint8_t)yend});
51 t.writeCommand(GMCTRP1, {0x02, 0x1C, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2D,
52 0x29, 0x25, 0x2B, 0x39, 0x00, 0x01, 0x03, 0x10});
53 t.writeCommand(GMCTRN1, {0x03, 0x1D, 0x07, 0x06, 0x2E, 0x2C, 0x29, 0x2D,
54 0x2E, 0x2E, 0x37, 0x3F, 0x00, 0x00, 0x02, 0x10});
55 t.writeCommand(inverted ? INVON : INVOFF);
56 t.writeCommand(NORON);
57 t.writeCommand(DISPON);
58 }
59};
60
61} // namespace st7735
62
63template <typename Transport, int16_t display_width, int16_t display_height,
64 int16_t lpad = 0, int16_t tpad = 0, int16_t rpad = lpad,
65 int16_t bpad = tpad, bool inverted = false>
68 lpad, tpad, rpad, bpad, inverted>>;
69
70template <int pinCS, int pinDC, int pinRST, int16_t display_width,
72 int16_t rpad = lpad, int16_t bpad = tpad, bool inverted = false,
73 typename Spi = DefaultSpi,
75 typename Gpio = DefaultGpio>
79 inverted>;
80
81template <int pinCS, int pinDC, int pinRST, typename Spi = DefaultSpi,
84 1, 2, 1, false, Spi, SpiSettings>;
85
86template <int pinCS, int pinDC, int pinRST, typename Spi = DefaultSpi,
89 St7735spi_Generic<pinCS, pinDC, pinRST, 80, 160, 26, 1, 26, 1, true, Spi,
91
92template <int pinCS, int pinDC, int pinRST, typename Spi = DefaultSpi,
95 1, 2, 3, false, Spi, SpiSettings>;
96
97} // namespace roo_display
SpiSettings< kSpiFrequency, kSpiMsbFirst, kSpiMode0 > DefaultSpiSettings
Definition st7735.h:15
static const uint32_t kSpiFrequency
Definition st7735.h:13
Defines 140 opaque HTML named colors.
void init(Target &t, int16_t xstart, int16_t xend, int16_t ystart, int16_t yend, bool inverted=false) const
Definition st7735.h:34