Skip to content

Commit 97c62b2

Browse files
add SPD2010 display class
1 parent 7df3ce2 commit 97c62b2

File tree

3 files changed

+557
-0
lines changed

3 files changed

+557
-0
lines changed

src/Arduino_GFX_Library.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include "display/Arduino_RGB_Display.h"
8787
#include "display/Arduino_SEPS525.h"
8888
#include "display/Arduino_SH1106.h"
89+
#include "display/Arduino_SPD2010.h"
8990
#include "display/Arduino_SSD1283A.h"
9091
#include "display/Arduino_SSD1306.h"
9192
#include "display/Arduino_SSD1331.h"

src/display/Arduino_SPD2010.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#include "Arduino_SPD2010.h"
2+
#include "SPI.h"
3+
4+
Arduino_SPD2010::Arduino_SPD2010(Arduino_DataBus *bus, int8_t rst)
5+
: Arduino_TFT(bus, rst, 0, false, SPD2010_TFTWIDTH, SPD2010_TFTHEIGHT, 0, 0, 0, 0)
6+
{
7+
}
8+
9+
bool Arduino_SPD2010::begin(int32_t speed)
10+
{
11+
_override_datamode = SPI_MODE3; // always use SPI_MODE3
12+
13+
return Arduino_TFT::begin(speed);
14+
}
15+
16+
/**************************************************************************/
17+
/*!
18+
@brief Set origin of (0,0) and orientation of TFT display
19+
@param m The index for rotation, from 0-3 inclusive
20+
*/
21+
/**************************************************************************/
22+
void Arduino_SPD2010::setRotation(uint8_t r)
23+
{
24+
Arduino_TFT::setRotation(r);
25+
// not implemented
26+
}
27+
28+
void Arduino_SPD2010::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
29+
{
30+
if ((x != _currentX) || (w != _currentW))
31+
{
32+
_currentX = x;
33+
_currentW = w;
34+
x += _xStart;
35+
_bus->writeC8D16D16(SPD2010_CASET, x, x + w - 1);
36+
}
37+
38+
if ((y != _currentY) || (h != _currentH))
39+
{
40+
_currentY = y;
41+
_currentH = h;
42+
y += _yStart;
43+
_bus->writeC8D16D16(SPD2010_PASET, y, y + h - 1);
44+
}
45+
46+
_bus->writeCommand(SPD2010_RAMWR); // write to RAM
47+
}
48+
49+
void Arduino_SPD2010::invertDisplay(bool i)
50+
{
51+
_bus->sendCommand(i ? SPD2010_INVON : SPD2010_INVOFF);
52+
}
53+
54+
void Arduino_SPD2010::displayOn(void)
55+
{
56+
_bus->sendCommand(SPD2010_SLPOUT);
57+
delay(SPD2010_SLPOUT_DELAY);
58+
}
59+
60+
void Arduino_SPD2010::displayOff(void)
61+
{
62+
_bus->sendCommand(SPD2010_SLPIN);
63+
delay(SPD2010_SLPIN_DELAY);
64+
}
65+
66+
// Companion code to the above tables. Reads and issues
67+
// a series of LCD commands stored in PROGMEM byte array.
68+
void Arduino_SPD2010::tftInit()
69+
{
70+
if (_rst != GFX_NOT_DEFINED)
71+
{
72+
pinMode(_rst, OUTPUT);
73+
digitalWrite(_rst, HIGH);
74+
delay(100);
75+
digitalWrite(_rst, LOW);
76+
delay(SPD2010_RST_DELAY);
77+
digitalWrite(_rst, HIGH);
78+
delay(SPD2010_RST_DELAY);
79+
}
80+
else
81+
{
82+
// Software Rest
83+
_bus->sendCommand(SPD2010_SWRESET);
84+
delay(SPD2010_RST_DELAY);
85+
}
86+
87+
_bus->batchOperation(spd2010_init_operations, sizeof(spd2010_init_operations));
88+
89+
invertDisplay(false);
90+
}

0 commit comments

Comments
 (0)