2.8 SPI TFT подключение
- Войдите на сайт для отправки комментариев
Вс, 10/01/2016 - 22:44
Добрый вечер, приобрел пару дисплеев 2.8 SPI TFT http://ru.aliexpress.com/item/A96-Free-Shipping-2-8-240x320-SPI-TFT-LCD-...
в описании указано что питание и логика 3.3В или 5В типа работать должно так и так, перепробовал кучу библиотек не фига не работает, горит белый экран и все тут.
Может кто подключал и подскажет как? или там все таки нужна логика 3.3В??
что значит "перепробовал кучу библиотек" ? Поди не так подключили. Там ещё бывает reset надо подключать к reset на ардуино, чтоб и дисплей сбрасывался при подаче напряжения питания.
библиотеки две : одна от UTFT , другая от Adafruit.
забейте здесь в поиск - SPI TFT . много тем здесь открыто с аналогичными подключениями SPI на 1.8" 2.2" .
дак вот 3 либы и пробовал
две которые вы перечислили и вот эта https://github.com/gmtii/ili9341-arduino не на одной либе он не запустил едиственное что на той что по ссылке он реагирует на резет, на остальных просто горит экран.
Мне интересно может нужно на логические пины 3.3В и не мучатся а китает просто наеб в описании что логика работает от 5В?
вот статейка ещё красивая http://arduino-kit.ru/catalog/id/displey-sensornyiy-24-tft-lcd-240x320 , пока не читал.
если будете использовать совместно с картой памяти, то для их поочередного включения есть у дисплея и карты включающие их сигналы CS , только их их завести на разные пины ардуины и включать поочередно.
Естественно уровни должны быть не выше 3,3 ( я б даже сказал не выше 3.0в , потому как на этом шилде стоит микросхема 65Z5 , она 3,0в )
Если пошукать поиском SPI LCD TFT на ебай и али, можно у продавцов увидеть ссылки на либы и документацию
к примеру http://www.ebay.com/itm/240x320-2-8-SPI-TFT-LCD-Touch-Panel-Serial-Port-Module-with-PCB-ILI9341-5V-3-3V/371278122006
там в документации http://www.winddeal.net/image/tools/37444.rar об уровнях и питании сказано .
Именно на этой плате судя по фото
1. нет транзистора включения подсветки, значит
вывод LED - это анод светодиодов подсветки, катодами они сидят на минусе. поэтому правильно подключить к +5в через резистор около 30 ом (-60ом) . Или к +3,3в через низкоомник , на крайняк на прямую.
2. нет преобразователей уровней, значит
- для скетчей софтового SPI понадобиться либо сделать делители на резисторах как в статье http://arduino-project.net/chasy-na-arduino-tft01-22sp/ . Или для ограничения тока лог. уровней просто последовательно резисторы (проверял 30ком, 10ком - работает, а 100ком, 1ком - не работает) , для этого случая желательно на кондёр около стабилизатора 65Z5 повешать стабилитрон на 3,0-3,3в , потому как эти уровни пересиливают напряжение на стабилизаторе до4-4,5в , от этого дисплей может выйти из строя. //нахрапом , на UTFT у меня тож не завёлся, заработало на https://github.com/adafruit/Adafruit_ILI9341 , ( по сообщению http://forum.arduino.cc/index.php?topic=181679.msg1758347#msg1758347 , можете и всю страницу, тему глянуть)
подключал так
1
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
2
Adafruit_ILI9341 tft = Adafruit_ILI9341( 5, 6, 11, 13, 4, 12);
в скетче закоментил аппаратный SPI , раскоментил програмный
001
/***************************************************
002
This is our GFX example for the Adafruit ILI9341 Breakout and Shield
003
----> <a href="http://www.adafruit.com/products/1651" rel="nofollow">http://www.adafruit.com/products/1651</a>
004
005
Check out the links above for our tutorials and wiring diagrams
006
These displays use SPI to communicate, 4 or 5 pins are required to
007
interface (RST is optional)
008
Adafruit invests time and resources providing this open source code,
009
please support Adafruit and open-source hardware by purchasing
010
products from Adafruit!
011
012
Written by Limor Fried/Ladyada for Adafruit Industries.
013
MIT license, all text above must be included in any redistribution
014
****************************************************/
015
016
017
#include "SPI.h"
018
#include "Adafruit_GFX.h"
019
#include "Adafruit_ILI9341.h"
020
021
// For the Adafruit shield, these are the default.
022
#define TFT_DC 9
023
#define TFT_CS 10
024
025
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
026
// Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
027
// If using the breakout, change pins as desired
028
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
029
Adafruit_ILI9341 tft = Adafruit_ILI9341(5, 6, 11, 13, 4, 12);
030
031
void
setup
() {
032
Serial
.begin(9600);
033
Serial
.println(
"ILI9341 Test!"
);
034
035
tft.begin();
036
037
// read diagnostics (optional but can help debug problems)
038
uint8_t x = tft.readcommand8(ILI9341_RDMODE);
039
Serial
.print(
"Display Power Mode: 0x"
);
Serial
.println(x, HEX);
040
x = tft.readcommand8(ILI9341_RDMADCTL);
041
Serial
.print(
"MADCTL Mode: 0x"
);
Serial
.println(x, HEX);
042
x = tft.readcommand8(ILI9341_RDPIXFMT);
043
Serial
.print(
"Pixel Format: 0x"
);
Serial
.println(x, HEX);
044
x = tft.readcommand8(ILI9341_RDIMGFMT);
045
Serial
.print(
"Image Format: 0x"
);
Serial
.println(x, HEX);
046
x = tft.readcommand8(ILI9341_RDSELFDIAG);
047
Serial
.print(
"Self Diagnostic: 0x"
);
Serial
.println(x, HEX);
048
049
Serial
.println(F(
"Benchmark Time (microseconds)"
));
050
051
Serial
.print(F(
"Screen fill "
));
052
Serial
.println(testFillScreen());
053
delay(500);
054
055
Serial
.print(F(
"Text "
));
056
Serial
.println(testText());
057
delay(3000);
058
059
Serial
.print(F(
"Lines "
));
060
Serial
.println(testLines(ILI9341_CYAN));
061
delay(500);
062
063
Serial
.print(F(
"Horiz/Vert Lines "
));
064
Serial
.println(testFastLines(ILI9341_RED, ILI9341_BLUE));
065
delay(500);
066
067
Serial
.print(F(
"Rectangles (outline) "
));
068
Serial
.println(testRects(ILI9341_GREEN));
069
delay(500);
070
071
Serial
.print(F(
"Rectangles (filled) "
));
072
Serial
.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA));
073
delay(500);
074
075
Serial
.print(F(
"Circles (filled) "
));
076
Serial
.println(testFilledCircles(10, ILI9341_MAGENTA));
077
078
Serial
.print(F(
"Circles (outline) "
));
079
Serial
.println(testCircles(10, ILI9341_WHITE));
080
delay(500);
081
082
Serial
.print(F(
"Triangles (outline) "
));
083
Serial
.println(testTriangles());
084
delay(500);
085
086
Serial
.print(F(
"Triangles (filled) "
));
087
Serial
.println(testFilledTriangles());
088
delay(500);
089
090
Serial
.print(F(
"Rounded rects (outline) "
));
091
Serial
.println(testRoundRects());
092
delay(500);
093
094
Serial
.print(F(
"Rounded rects (filled) "
));
095
Serial
.println(testFilledRoundRects());
096
delay(500);
097
098
Serial
.println(F(
"Done!"
));
099
100
}
101
102
103
void
loop
(
void
) {
104
for
(uint8_t rotation=0; rotation<4; rotation++) {
105
tft.setRotation(rotation);
106
testText();
107
delay(1000);
108
}
109
}
110
111
unsigned
long
testFillScreen() {
112
unsigned
long
start = micros();
113
tft.fillScreen(ILI9341_BLACK);
114
tft.fillScreen(ILI9341_RED);
115
tft.fillScreen(ILI9341_GREEN);
116
tft.fillScreen(ILI9341_BLUE);
117
tft.fillScreen(ILI9341_BLACK);
118
return
micros() - start;
119
}
120
121
unsigned
long
testText() {
122
tft.fillScreen(ILI9341_BLACK);
123
unsigned
long
start = micros();
124
tft.setCursor(0, 0);
125
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1);
126
tft.println(
"Hello World!"
);
127
tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2);
128
tft.println(1234.56);
129
tft.setTextColor(ILI9341_RED); tft.setTextSize(3);
130
tft.println(0xDEADBEEF, HEX);
131
tft.println();
132
tft.setTextColor(ILI9341_GREEN);
133
tft.setTextSize(5);
134
tft.println(
"Groop"
);
135
tft.setTextSize(2);
136
tft.println(
"I implore thee,"
);
137
tft.setTextSize(1);
138
tft.println(
"my foonting turlingdromes."
);
139
tft.println(
"And hooptiously drangle me"
);
140
tft.println(
"with crinkly bindlewurdles,"
);
141
tft.println(
"Or I will rend thee"
);
142
tft.println(
"in the gobberwarts"
);
143
tft.println(
"with my blurglecruncheon,"
);
144
tft.println(
"see if I don't!"
);
145
return
micros() - start;
146
}
147
148
unsigned
long
testLines(uint16_t color) {
149
unsigned
long
start, t;
150
int
x1, y1, x2, y2,
151
w = tft.width(),
152
h = tft.height();
153
154
tft.fillScreen(ILI9341_BLACK);
155
156
x1 = y1 = 0;
157
y2 = h - 1;
158
start = micros();
159
for
(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
160
x2 = w - 1;
161
for
(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
162
t = micros() - start;
// fillScreen doesn't count against timing
163
164
tft.fillScreen(ILI9341_BLACK);
165
166
x1 = w - 1;
167
y1 = 0;
168
y2 = h - 1;
169
start = micros();
170
for
(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
171
x2 = 0;
172
for
(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
173
t += micros() - start;
174
175
tft.fillScreen(ILI9341_BLACK);
176
177
x1 = 0;
178
y1 = h - 1;
179
y2 = 0;
180
start = micros();
181
for
(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
182
x2 = w - 1;
183
for
(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
184
t += micros() - start;
185
186
tft.fillScreen(ILI9341_BLACK);
187
188
x1 = w - 1;
189
y1 = h - 1;
190
y2 = 0;
191
start = micros();
192
for
(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
193
x2 = 0;
194
for
(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
195
196
return
micros() - start;
197
}
198
199
unsigned
long
testFastLines(uint16_t color1, uint16_t color2) {
200
unsigned
long
start;
201
int
x, y, w = tft.width(), h = tft.height();
202
203
tft.fillScreen(ILI9341_BLACK);
204
start = micros();
205
for
(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
206
for
(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);
207
208
return
micros() - start;
209
}
210
211
unsigned
long
testRects(uint16_t color) {
212
unsigned
long
start;
213
int
n, i, i2,
214
cx = tft.width() / 2,
215
cy = tft.height() / 2;
216
217
tft.fillScreen(ILI9341_BLACK);
218
n = min(tft.width(), tft.height());
219
start = micros();
220
for
(i=2; i<n; i+=6) {
221
i2 = i / 2;
222
tft.drawRect(cx-i2, cy-i2, i, i, color);
223
}
224
225
return
micros() - start;
226
}
227
228
unsigned
long
testFilledRects(uint16_t color1, uint16_t color2) {
229
unsigned
long
start, t = 0;
230
int
n, i, i2,
231
cx = tft.width() / 2 - 1,
232
cy = tft.height() / 2 - 1;
233
234
tft.fillScreen(ILI9341_BLACK);
235
n = min(tft.width(), tft.height());
236
for
(i=n; i>0; i-=6) {
237
i2 = i / 2;
238
start = micros();
239
tft.fillRect(cx-i2, cy-i2, i, i, color1);
240
t += micros() - start;
241
// Outlines are not included in timing results
242
tft.drawRect(cx-i2, cy-i2, i, i, color2);
243
}
244
245
return
t;
246
}
247
248
unsigned
long
testFilledCircles(uint8_t radius, uint16_t color) {
249
unsigned
long
start;
250
int
x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
251
252
tft.fillScreen(ILI9341_BLACK);
253
start = micros();
254
for
(x=radius; x<w; x+=r2) {
255
for
(y=radius; y<h; y+=r2) {
256
tft.fillCircle(x, y, radius, color);
257
}
258
}
259
260
return
micros() - start;
261
}
262
263
unsigned
long
testCircles(uint8_t radius, uint16_t color) {
264
unsigned
long
start;
265
int
x, y, r2 = radius * 2,
266
w = tft.width() + radius,
267
h = tft.height() + radius;
268
269
// Screen is not cleared for this one -- this is
270
// intentional and does not affect the reported time.
271
start = micros();
272
for
(x=0; x<w; x+=r2) {
273
for
(y=0; y<h; y+=r2) {
274
tft.drawCircle(x, y, radius, color);
275
}
276
}
277
278
return
micros() - start;
279
}
280
281
unsigned
long
testTriangles() {
282
unsigned
long
start;
283
int
n, i, cx = tft.width() / 2 - 1,
284
cy = tft.height() / 2 - 1;
285
286
tft.fillScreen(ILI9341_BLACK);
287
n = min(cx, cy);
288
start = micros();
289
for
(i=0; i<n; i+=5) {
290
tft.drawTriangle(
291
cx , cy - i,
// peak
292
cx - i, cy + i,
// bottom left
293
cx + i, cy + i,
// bottom right
294
tft.color565(0, 0, i));
295
}
296
297
return
micros() - start;
298
}
299
300
unsigned
long
testFilledTriangles() {
301
unsigned
long
start, t = 0;
302
int
i, cx = tft.width() / 2 - 1,
303
cy = tft.height() / 2 - 1;
304
305
tft.fillScreen(ILI9341_BLACK);
306
start = micros();
307
for
(i=min(cx,cy); i>10; i-=5) {
308
start = micros();
309
tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
310
tft.color565(0, i, i));
311
t += micros() - start;
312
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
313
tft.color565(i, i, 0));
314
}
315
316
return
t;
317
}
318
319
unsigned
long
testRoundRects() {
320
unsigned
long
start;
321
int
w, i, i2,
322
cx = tft.width() / 2 - 1,
323
cy = tft.height() / 2 - 1;
324
325
tft.fillScreen(ILI9341_BLACK);
326
w = min(tft.width(), tft.height());
327
start = micros();
328
for
(i=0; i<w; i+=6) {
329
i2 = i / 2;
330
tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
331
}
332
333
return
micros() - start;
334
}
335
336
unsigned
long
testFilledRoundRects() {
337
unsigned
long
start;
338
int
i, i2,
339
cx = tft.width() / 2 - 1,
340
cy = tft.height() / 2 - 1;
341
342
tft.fillScreen(ILI9341_BLACK);
343
start = micros();
344
for
(i=min(tft.width(), tft.height()); i>20; i-=6) {
345
i2 = i / 2;
346
tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
347
}
348
349
return
micros() - start;
350
}
Если вы подключали его напрямую к 5ти вольтовой ардуине, и у ней было хорошее питание, то вероятно ему уже каюк.
- для скетчей аппаратного SPI (дает большую скорость), всё же желательно использовать микросхемы преобразователей уровней, чтоб не заваливались фронты управляющих сигналов. У меня заработало на резистивных делителях 1ком+20ком(просто что было легче поменять верхние 10ком) . раскоментил аппаратный , закоментил софтовый. Заработало. На делителях 1ком+2ком нет.
01
...............................
02
#include "SPI.h"
03
#include "Adafruit_GFX.h"
04
#include "Adafruit_ILI9341.h"
05
06
// For the Adafruit shield, these are the default.
07
#define TFT_DC 9
08
#define TFT_CS 10
09
10
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
11
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
12
// If using the breakout, change pins as desired
13
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
14
//Adafruit_ILI9341 tft = Adafruit_ILI9341(10, 9, 11, 13, 8, 12);
15
...............................
Да скорость стала такая же быстрая как и 8ми битных дисплеях. подключение SPI #13, #12, #11 осталось тоже, DC на 9, CS на 10, RESET соеденил с RES на ардуино, чтоб дисплей сбрасывался совместно с ардуиной (при подаче питания).
// потом следом и UTFT заработал , как в статье про часы на нём, на делителях 10к+20к. Очень странно - а раньше нивкакую не запускался. наверно забыл что в memorysaver.h надо выбрать тип контроллера, ( оставить закоментированными только
//#define DISABLE_ILI9341_S4P 1 // MI0283QT9 и
//#define DISABLE_ILI9341_S5P 1 // TFT01_22SP / TFT01_24SP / TFT22SHLD / DMTFT28105
)
Спасибо, развернутый ответ.. Подключил пока через резисторы 10ком по такой схеме http://1.bp.blogspot.com/-0Zmb2xr-uEI/U8ZCaSnNQEI/AAAAAAAAMEE/eeV1dRPckLs/s1600/schema_conectare_ILI9341_Arduino_ver1m0.png и с либой Ucglib заработало с программным isp на апаратном висит nrf24, в месте на хотят работать, позже попробую вашу предложенную Adafruit_ILI9341 может она по резвее будет, а то эта тормозит жутко. А так заказал такие http://ru.aliexpress.com/item/1PCS-IIC-I2C-Logic-Level-Converter-Bi-Directional-Module-5V-to-3-3V/32417113805.html