Skip to content

Commit 8b7144b

Browse files
add NV3007 display support
1 parent 38e8569 commit 8b7144b

File tree

4 files changed

+303
-0
lines changed

4 files changed

+303
-0
lines changed

examples/PDQgraphicstest/Arduino_GFX_display.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, TFT_RST, 0 /* rotation */, false /*
9191
// NT39125 LCD 240x376
9292
// Arduino_GFX *gfx = new Arduino_NT39125(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 240, 376, 0, 0, 0, 56);
9393

94+
// NV3007 LCD 142x428
95+
// Arduino_GFX *gfx = new Arduino_NV3007(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 142 /* width */, 428 /* height */, 12 /* col offset 1 */, 0 /* row offset 1 */, 14 /* col offset 2 */, 0 /* row offset 2 */);
96+
9497
// NV3041A IPS LCD
9598
// Arduino_GFX *gfx = new Arduino_NV3041A(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
9699

src/Arduino_GFX_Library.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#include "display/Arduino_NT35310.h"
7777
#include "display/Arduino_NT35510.h"
7878
#include "display/Arduino_NT39125.h"
79+
#include "display/Arduino_NV3007.h"
7980
#include "display/Arduino_NV3023.h"
8081
#include "display/Arduino_NV3041A.h"
8182
#include "display/Arduino_OTM8009A.h"

src/display/Arduino_NV3007.cpp

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#include "Arduino_NV3007.h"
2+
#include "SPI.h"
3+
4+
Arduino_NV3007::Arduino_NV3007(
5+
Arduino_DataBus *bus, int8_t rst, uint8_t r,
6+
bool ips, int16_t w, int16_t h,
7+
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
8+
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
9+
{
10+
}
11+
12+
bool Arduino_NV3007::begin(int32_t speed)
13+
{
14+
_override_datamode = SPI_MODE0; // always use SPI_MODE0
15+
16+
return Arduino_TFT::begin(speed);
17+
}
18+
19+
void Arduino_NV3007::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
20+
{
21+
if ((x != _currentX) || (w != _currentW) || (y != _currentY) || (h != _currentH))
22+
{
23+
_bus->writeC8D16D16(NV3007_CASET, x + _xStart, x + w - 1 + _xStart);
24+
_bus->writeC8D16D16(NV3007_RASET, y + _yStart, y + h - 1 + _yStart);
25+
26+
_currentX = x;
27+
_currentY = y;
28+
_currentW = w;
29+
_currentH = h;
30+
}
31+
32+
_bus->writeCommand(NV3007_RAMWR); // write to RAM
33+
}
34+
35+
/**************************************************************************/
36+
/*!
37+
@brief Set origin of (0,0) and orientation of TFT display
38+
@param m The index for rotation, from 0-3 inclusive
39+
*/
40+
/**************************************************************************/
41+
void Arduino_NV3007::setRotation(uint8_t r)
42+
{
43+
Arduino_TFT::setRotation(r);
44+
switch (_rotation)
45+
{
46+
case 1:
47+
r = 0x70;
48+
break;
49+
case 2:
50+
r = 0xC0;
51+
break;
52+
case 3:
53+
r = 0xA0;
54+
break;
55+
default: // case 0:
56+
r = 0x00;
57+
break;
58+
}
59+
_bus->beginWrite();
60+
_bus->writeC8D8(NV3007_MADCTL, r);
61+
_bus->endWrite();
62+
}
63+
64+
void Arduino_NV3007::invertDisplay(bool i)
65+
{
66+
_bus->sendCommand(_ips ? (i ? NV3007_INVOFF : NV3007_INVON) : (i ? NV3007_INVON : NV3007_INVOFF));
67+
}
68+
69+
void Arduino_NV3007::displayOn(void)
70+
{
71+
_bus->sendCommand(NV3007_SLPOUT);
72+
delay(NV3007_SLPOUT_DELAY);
73+
}
74+
75+
void Arduino_NV3007::displayOff(void)
76+
{
77+
_bus->sendCommand(NV3007_SLPIN);
78+
delay(NV3007_SLPIN_DELAY);
79+
}
80+
81+
void Arduino_NV3007::tftInit()
82+
{
83+
if (_rst != GFX_NOT_DEFINED)
84+
{
85+
pinMode(_rst, OUTPUT);
86+
digitalWrite(_rst, HIGH);
87+
delay(100);
88+
digitalWrite(_rst, LOW);
89+
delay(NV3007_RST_DELAY);
90+
digitalWrite(_rst, HIGH);
91+
delay(NV3007_RST_DELAY);
92+
}
93+
else
94+
{
95+
// Software Rest
96+
}
97+
98+
_bus->batchOperation(NV3007_init_operations, sizeof(NV3007_init_operations));
99+
100+
invertDisplay(false);
101+
}

src/display/Arduino_NV3007.h

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
#ifndef _ARDUINO_NV3007_H_
2+
#define _ARDUINO_NV3007_H_
3+
4+
#include <Arduino.h>
5+
#include <Print.h>
6+
#include "./Arduino_GFX.h"
7+
#include "../Arduino_TFT.h"
8+
9+
#define NV3007_TFTWIDTH 168
10+
#define NV3007_TFTHEIGHT 428
11+
12+
#define NV3007_RST_DELAY 120 ///< delay ms wait for reset finish
13+
#define NV3007_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
14+
#define NV3007_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
15+
16+
#define NV3007_SLPIN 0x10
17+
#define NV3007_SLPOUT 0x11
18+
19+
#define NV3007_INVOFF 0x20
20+
#define NV3007_INVON 0x21
21+
#define NV3007_DISPOFF 0x28
22+
#define NV3007_DISPON 0x29
23+
24+
#define NV3007_CASET 0x2A
25+
#define NV3007_RASET 0x2B
26+
#define NV3007_RAMWR 0x2C
27+
#define NV3007_RAMRD 0x2E
28+
29+
#define NV3007_MADCTL 0x36
30+
31+
static const uint8_t NV3007_init_operations[] = {
32+
BEGIN_WRITE,
33+
34+
WRITE_C8_D8, 0xFF, 0xA5,
35+
36+
WRITE_COMMAND_8, 0x11,
37+
DELAY, 120, // 120ms
38+
39+
WRITE_C8_D8, 0xff, 0xa5,
40+
WRITE_C8_D8, 0x9a, 0x08,
41+
WRITE_C8_D8, 0x9b, 0x08,
42+
WRITE_C8_D8, 0x9c, 0xb0,
43+
WRITE_C8_D8, 0x9d, 0x17,
44+
WRITE_C8_D8, 0x9e, 0xc2,
45+
WRITE_C8_D16, 0x8f, 0x22, 0x04,
46+
WRITE_C8_D8, 0x84, 0x90,
47+
WRITE_C8_D8, 0x83, 0x7B,
48+
WRITE_C8_D8, 0x85, 0x4F,
49+
////GAMMA---------------------------------/////////////
50+
// V0[3:0]
51+
WRITE_C8_D8, 0x6e, 0x0f,
52+
WRITE_C8_D8, 0x7e, 0x0f,
53+
54+
// V63[3:0]
55+
WRITE_C8_D8, 0x60, 0x00,
56+
WRITE_C8_D8, 0x70, 0x00,
57+
// V1[5:0]
58+
WRITE_C8_D8, 0x6d, 0x39,
59+
WRITE_C8_D8, 0x7d, 0x31,
60+
// V62[5:0]
61+
WRITE_C8_D8, 0x61, 0x0A,
62+
WRITE_C8_D8, 0x71, 0x0A,
63+
// V2[5:0]
64+
WRITE_C8_D8, 0x6c, 0x35,
65+
WRITE_C8_D8, 0x7c, 0x29,
66+
// V61[5:0]
67+
WRITE_C8_D8, 0x62, 0x0F,
68+
WRITE_C8_D8, 0x72, 0x0F,
69+
// V20[6:0]
70+
WRITE_C8_D8, 0x68, 0x4f,
71+
WRITE_C8_D8, 0x78, 0x45,
72+
// V43[6:0]
73+
WRITE_C8_D8, 0x66, 0x33,
74+
WRITE_C8_D8, 0x76, 0x33,
75+
// V4[4:0]
76+
WRITE_C8_D8, 0x6b, 0x14,
77+
WRITE_C8_D8, 0x7b, 0x14,
78+
// V59[4:0]
79+
WRITE_C8_D8, 0x63, 0x09,
80+
WRITE_C8_D8, 0x73, 0x09,
81+
// V6[4:0]
82+
WRITE_C8_D8, 0x6a, 0x13,
83+
WRITE_C8_D8, 0x7a, 0x16,
84+
// V57[4:0]
85+
WRITE_C8_D8, 0x64, 0x08,
86+
WRITE_C8_D8, 0x74, 0x08,
87+
WRITE_C8_D8, 0x69, 0x07,
88+
WRITE_C8_D8, 0x79, 0x0d,
89+
WRITE_C8_D8, 0x65, 0x05,
90+
WRITE_C8_D8, 0x75, 0x05,
91+
WRITE_C8_D8, 0x67, 0x33,
92+
WRITE_C8_D8, 0x77, 0x33,
93+
WRITE_C8_D8, 0x6f, 0x00,
94+
WRITE_C8_D8, 0x7f, 0x00,
95+
WRITE_C8_D8, 0x50, 0x00,
96+
WRITE_C8_D8, 0x52, 0xd6,
97+
WRITE_C8_D8, 0x53, 0x04,
98+
WRITE_C8_D8, 0x54, 0x04,
99+
WRITE_C8_D8, 0x55, 0x1b,
100+
WRITE_C8_D8, 0x56, 0x1b,
101+
WRITE_COMMAND_8, 0xa0,
102+
WRITE_BYTES, 3, 0x2a, 0x24, 0x00,
103+
WRITE_C8_D8, 0xa1, 0x84,
104+
WRITE_C8_D8, 0xa2, 0x85,
105+
WRITE_C8_D8, 0xa8, 0x34,
106+
WRITE_C8_D8, 0xa9, 0x80,
107+
WRITE_C8_D8, 0xaa, 0x73,
108+
WRITE_C8_D16, 0xAB, 0x03, 0x61,
109+
WRITE_C8_D16, 0xAC, 0x03, 0x65,
110+
WRITE_C8_D16, 0xAD, 0x03, 0x60,
111+
WRITE_C8_D16, 0xAE, 0x03, 0x64,
112+
WRITE_C8_D8, 0xB9, 0x82,
113+
WRITE_C8_D8, 0xBA, 0x83,
114+
WRITE_C8_D8, 0xBB, 0x80,
115+
WRITE_C8_D8, 0xBC, 0x81,
116+
WRITE_C8_D8, 0xBD, 0x02,
117+
WRITE_C8_D8, 0xBE, 0x01,
118+
WRITE_C8_D8, 0xBF, 0x04,
119+
WRITE_C8_D8, 0xC0, 0x03,
120+
WRITE_C8_D8, 0xc4, 0x33,
121+
WRITE_C8_D8, 0xc5, 0x80,
122+
WRITE_C8_D8, 0xc6, 0x73,
123+
WRITE_C8_D8, 0xc7, 0x00,
124+
WRITE_C8_D16, 0xC8, 0x33, 0x33,
125+
WRITE_C8_D8, 0xC9, 0x5b,
126+
WRITE_C8_D8, 0xCA, 0x5a,
127+
WRITE_C8_D8, 0xCB, 0x5d,
128+
WRITE_C8_D8, 0xCC, 0x5c,
129+
WRITE_C8_D16, 0xCD, 0x33, 0x33,
130+
WRITE_C8_D8, 0xCE, 0x5f,
131+
WRITE_C8_D8, 0xCF, 0x5e,
132+
WRITE_C8_D8, 0xD0, 0x61,
133+
WRITE_C8_D8, 0xD1, 0x60,
134+
WRITE_COMMAND_8, 0xB0,
135+
WRITE_BYTES, 4, 0x3a, 0x3a, 0x00, 0x00,
136+
WRITE_C8_D8, 0xB6, 0x32,
137+
WRITE_C8_D8, 0xB7, 0x80,
138+
WRITE_C8_D8, 0xB8, 0x73,
139+
WRITE_C8_D8, 0xe0, 0x00,
140+
WRITE_C8_D16, 0xe1, 0x03, 0x0f,
141+
WRITE_C8_D8, 0xe2, 0x04,
142+
WRITE_C8_D8, 0xe3, 0x01,
143+
WRITE_C8_D8, 0xe4, 0x0e,
144+
WRITE_C8_D8, 0xe5, 0x01,
145+
WRITE_C8_D8, 0xe6, 0x19,
146+
WRITE_C8_D8, 0xe7, 0x10,
147+
WRITE_C8_D8, 0xe8, 0x10,
148+
WRITE_C8_D8, 0xe9, 0x21,
149+
WRITE_C8_D8, 0xea, 0x12,
150+
WRITE_C8_D8, 0xeb, 0xd0,
151+
WRITE_C8_D8, 0xec, 0x04,
152+
WRITE_C8_D8, 0xed, 0x07,
153+
WRITE_C8_D8, 0xee, 0x07,
154+
WRITE_C8_D8, 0xef, 0x09,
155+
WRITE_C8_D8, 0xF0, 0xD0,
156+
WRITE_C8_D8, 0xF1, 0x0E,
157+
WRITE_C8_D8, 0xF9, 0x56,
158+
WRITE_COMMAND_8, 0xf2,
159+
WRITE_BYTES, 4, 0x26, 0x1b, 0x0b, 0x20,
160+
WRITE_C8_D8, 0xec, 0x04,
161+
WRITE_C8_D8, 0x35, 0x00,
162+
WRITE_C8_D16, 0x44, 0x00, 0x10,
163+
WRITE_C8_D8, 0x46, 0x10,
164+
WRITE_C8_D8, 0xff, 0x00,
165+
WRITE_C8_D8, 0x3a, 0x05,
166+
WRITE_COMMAND_8, NV3007_SLPOUT,
167+
END_WRITE,
168+
169+
DELAY, 200,
170+
171+
BEGIN_WRITE,
172+
WRITE_COMMAND_8, NV3007_DISPON,
173+
END_WRITE,
174+
175+
DELAY, 150};
176+
177+
class Arduino_NV3007 : public Arduino_TFT
178+
{
179+
public:
180+
Arduino_NV3007(
181+
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
182+
bool ips = false, int16_t w = NV3007_TFTWIDTH, int16_t h = NV3007_TFTHEIGHT,
183+
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
184+
185+
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
186+
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
187+
void setRotation(uint8_t r) override;
188+
void invertDisplay(bool) override;
189+
void displayOn() override;
190+
void displayOff() override;
191+
192+
protected:
193+
void tftInit() override;
194+
195+
private:
196+
};
197+
198+
#endif

0 commit comments

Comments
 (0)