2#include <initializer_list>
6#include "TinyGPU/Drivers/DisplayDriver.h"
7#include "TinyGPU/Emulation.h"
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34template <
typename RGB_T =
RGB565>
55 int8_t d4, int8_t d5, int8_t d6, int8_t d7,
56 int8_t wr, int8_t dc, int8_t cs = -1,
57 int8_t rd = -1, int8_t rst = -1, size_t xOffset = 0,
58 size_t yOffset = 0, size_t width = 240,
60 :
d_{d0, d1, d2, d3, d4, d5, d6, d7},
78 bool writeData(ISurface<RGB_T>& surface, size_t x, size_t y)
override {
79 static_assert(
sizeof(RGB_T) == 2,
80 "writeData assumes a 16bpp RGB_T (RGB565) stored in "
82 setAddressWindow(x, y, surface.width(), surface.height());
84 digitalWrite(dc_, HIGH);
85 const uint8_t* src = surface.data();
86 const size_t n = surface.size();
87 for (size_t i = 0; i < n; ++i) {
102 writeData16(x + xOffset_, x + xOffset_ + w - 1);
104 writeData16(y + yOffset_, y + yOffset_ + h - 1);
108 setColumnRowAddress(x, y, w, h);
114 for (int8_t pin :
d_) {
115 pinMode(pin, OUTPUT);
117 pinMode(wr_, OUTPUT);
118 digitalWrite(wr_, HIGH);
119 pinMode(dc_, OUTPUT);
121 pinMode(cs_, OUTPUT);
122 digitalWrite(cs_, HIGH);
125 pinMode(rd_, OUTPUT);
126 digitalWrite(rd_, HIGH);
129 pinMode(rst_, OUTPUT);
130 digitalWrite(rst_, LOW);
132 digitalWrite(rst_, HIGH);
139 digitalWrite(dc_, LOW);
146 digitalWrite(dc_, HIGH);
148 writeByte(d1 & 0xFF);
150 writeByte(d2 & 0xFF);
156 digitalWrite(dc_, HIGH);
165 for (uint8_t b : bytes) {
171 void beginTransaction() {
172 if (cs_ >= 0) digitalWrite(cs_, LOW);
175 void endTransaction() {
176 if (cs_ >= 0) digitalWrite(cs_, HIGH);
181 void writeByte(uint8_t data) {
182 for (uint8_t i = 0; i < 8; ++i) {
183 digitalWrite(
d_[i], (data >> i) & 0x01);
185 digitalWrite(wr_, LOW);
186 digitalWrite(wr_, HIGH);
191
192
193template <
typename RGB_T =
RGB565>
201 int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc,
202 int8_t cs = -1, int8_t rd = -1, int8_t rst = -1,
203 size_t width = 128, size_t height = 160)
204 :
DisplayDriverParallel8<
RGB_T>(
d0,
d1,
d2,
d3,
d4,
d5,
d6,
d7,
wr,
dc,
221
222
223template <
typename RGB_T =
RGB565>
231 int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc,
232 int8_t cs = -1, int8_t rd = -1, int8_t rst = -1,
233 size_t width = 240, size_t height = 320)
234 :
DisplayDriverParallel8<
RGB_T>(
d0,
d1,
d2,
d3,
d4,
d5,
d6,
d7,
wr,
dc,
251
252
253
254
255
256
257template <
typename RGB_T =
RGB565>
272 int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc,
273 int8_t cs = -1, int8_t rd = -1, int8_t rst = -1,
274 Rotation rotation = Rotation
::kNone,
275 size_t nativeWidth = 240, size_t nativeHeight = 320)
276 :
DisplayDriverParallel8<RGB_T>(d0, d1, d2, d3, d4, d5, d6, d7, wr, dc,
283 return isLandscapeFamily(rotation_) ? nativeHeight_ : nativeWidth_;
286 return isLandscapeFamily(rotation_) ? nativeWidth_ : nativeHeight_;
296 writeDataN({0x03, 0x80, 0x02});
299 writeDataN({0x00, 0xC1, 0x30});
302 writeDataN({0x64, 0x03, 0x12, 0x81});
305 writeDataN({0x85, 0x00, 0x78});
308 writeDataN({0x39, 0x2C, 0x00, 0x34, 0x02});
314 writeDataN({0x00, 0x00});
323 writeDataN({0x3E, 0x28});
335 writeDataN({0x00, 0x13});
338 writeDataN({0x08, 0x82, 0x27});
347 writeDataN({0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07,
348 0x10, 0x03, 0x0E, 0x09, 0x00});
351 writeDataN({0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08,
352 0x0F, 0x0C, 0x31, 0x36, 0x0F});
364 if (rotation == Rotation
::kNone)
return;
376 writeCommand(invert ? 0x21 : 0x20);
401
402
403template <
typename RGB_T =
RGB565>
411 int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc,
412 int8_t cs = -1, int8_t rd = -1, int8_t rst = -1,
413 size_t width = 320, size_t height = 480)
414 :
DisplayDriverParallel8<
RGB_T>(
d0,
d1,
d2,
d3,
d4,
d5,
d6,
d7,
wr,
dc,
431
432
433template <
typename RGB_T =
RGB565>
441 int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc,
442 int8_t cs = -1, int8_t rd = -1, int8_t rst = -1,
443 size_t width = 320, size_t height = 480)
444 :
DisplayDriverParallel8<
RGB_T>(
d0,
d1,
d2,
d3,
d4,
d5,
d6,
d7,
wr,
dc,
Common base class for 8-bit parallel ("Intel 8080"-style) TFT display drivers: 8 data lines (D0-D7),...
Definition: DisplayDriverParallel8.h:35
int8_t rd_
Definition: DisplayDriverParallel8.h:96
int8_t wr_
Definition: DisplayDriverParallel8.h:96
int8_t dc_
Definition: DisplayDriverParallel8.h:96
size_t xOffset_
Definition: DisplayDriverParallel8.h:97
size_t yOffset_
Definition: DisplayDriverParallel8.h:97
size_t width_
Definition: DisplayDriverParallel8.h:98
void writeDataN(std::initializer_list< uint8_t > bytes)
Definition: DisplayDriverParallel8.h:164
size_t height_
Definition: DisplayDriverParallel8.h:98
int8_t d_[8]
Definition: DisplayDriverParallel8.h:95
size_t height() const override
Definition: DisplayDriverParallel8.h:72
void setColumnRowAddress(size_t x, size_t y, size_t w, size_t h)
Definition: DisplayDriverParallel8.h:100
int8_t cs_
Definition: DisplayDriverParallel8.h:96
int8_t rst_
Definition: DisplayDriverParallel8.h:96
void setupPinsAndReset()
Definition: DisplayDriverParallel8.h:113
void writeCommand(uint8_t cmd)
Definition: DisplayDriverParallel8.h:137
bool writeData(ISurface< RGB_T > &surface, size_t x, size_t y) override
Definition: DisplayDriverParallel8.h:78
size_t width() const override
Definition: DisplayDriverParallel8.h:71
bool setAddressWindow(size_t x, size_t y, size_t w, size_t h) override
Definition: DisplayDriverParallel8.h:107
void writeData8(uint8_t data)
Definition: DisplayDriverParallel8.h:154
DisplayDriverParallel8(int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t d4, int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc, int8_t cs=-1, int8_t rd=-1, int8_t rst=-1, size_t xOffset=0, size_t yOffset=0, size_t width=240, size_t height=320)
Definition: DisplayDriverParallel8.h:54
bool writeData(ISurface< RGB_T > &surface) override
Definition: DisplayDriverParallel8.h:74
void writeData16(uint16_t d1, uint16_t d2)
Definition: DisplayDriverParallel8.h:144
Definition: DisplayDriver.h:49
Driver for HX8357 8-bit parallel display controller.
Definition: DisplayDriverParallel8.h:404
HX8357Driver8080(int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t d4, int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc, int8_t cs=-1, int8_t rd=-1, int8_t rst=-1, size_t width=320, size_t height=480)
Definition: DisplayDriverParallel8.h:410
bool begin() override
Definition: DisplayDriverParallel8.h:417
Driver for ILI9341 8-bit parallel display controller.
Definition: DisplayDriverParallel8.h:258
static uint8_t madctlForRotation(Rotation rotation)
Definition: DisplayDriverParallel8.h:384
size_t nativeHeight_
Definition: DisplayDriverParallel8.h:381
size_t nativeWidth_
Definition: DisplayDriverParallel8.h:381
void setInvertColor(bool invert)
Definition: DisplayDriverParallel8.h:374
size_t height() const override
Definition: DisplayDriverParallel8.h:285
size_t width() const override
Definition: DisplayDriverParallel8.h:282
Rotation rotation() const
Definition: DisplayDriverParallel8.h:370
bool invertColor_
Definition: DisplayDriverParallel8.h:382
bool begin() override
Definition: DisplayDriverParallel8.h:289
ILI9341Driver8080(int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t d4, int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc, int8_t cs=-1, int8_t rd=-1, int8_t rst=-1, Rotation rotation=Rotation::kNone, size_t nativeWidth=240, size_t nativeHeight=320)
Definition: DisplayDriverParallel8.h:271
void setRotation(Rotation rotation) override
Definition: DisplayDriverParallel8.h:363
Rotation rotation_
Definition: DisplayDriverParallel8.h:380
RGB color stored in 16-bit RGB565 format, byte-swapped from the conventional bit layout.
Definition: RGB565.h:24
Driver for ST7735 8-bit parallel display controller.
Definition: DisplayDriverParallel8.h:194
ST7735Driver8080(int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t d4, int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc, int8_t cs=-1, int8_t rd=-1, int8_t rst=-1, size_t width=128, size_t height=160)
Definition: DisplayDriverParallel8.h:200
bool begin() override
Definition: DisplayDriverParallel8.h:207
Driver for ST7789 8-bit parallel display controller.
Definition: DisplayDriverParallel8.h:224
ST7789Driver8080(int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t d4, int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc, int8_t cs=-1, int8_t rd=-1, int8_t rst=-1, size_t width=240, size_t height=320)
Definition: DisplayDriverParallel8.h:230
bool begin() override
Definition: DisplayDriverParallel8.h:237
Driver for ST7796 8-bit parallel display controller.
Definition: DisplayDriverParallel8.h:434
ST7796Driver8080(int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t d4, int8_t d5, int8_t d6, int8_t d7, int8_t wr, int8_t dc, int8_t cs=-1, int8_t rd=-1, int8_t rst=-1, size_t width=320, size_t height=480)
Definition: DisplayDriverParallel8.h:440
bool begin() override
Definition: DisplayDriverParallel8.h:447
Definition: DSIBusESP32.h:19
void delay(unsigned long ms)
Definition: EmulationDesktop.h:52
DisplayRotation
Abstract base class for display drivers.
Definition: DisplayDriver.h:28