Жк-экран и его подключение к ардуино
- Войдите на сайт для отправки комментариев
Пнд, 17/10/2016 - 15:31
Добрый день!
Купил на Али-рессе жк-экранчик, маленький - https://ru.aliexpress.com/item/Brand-LCD-Module-TFT-2-4-inch-TFT-touch-LCD-screen-for-Arduino-UNO-R3-Board/32598873860.html?spm=2114.13010608.0.0.sa1jpd&detailNewVersion=&categoryId=400401
установил библиотеку SPFD 5408. Начинаю загружать примеры - куча ошибок.
Экран белый и никак не реагирует...
Если можно подсказать, буду очень признателен.
Заранее спасибо
А сообщения о ошибках Вам Клапауций 322 запретил выложить?
А сообщения о ошибках Вам Клапауций 322 запретил выложить?
я запрещаю упоминать имя мое в суе.
Как изволите Ваше пр-во, только не нервничайте, а то санитарам прийдется бежать к Вам прервав ужин, и они долго злые будут ;)
Если добавляю такой тестовый код :
001
// BMP-loading example specifically for the TFTLCD breakout board.
002
// If using the Arduino shield, use the tftbmp_shield.pde sketch instead!
003
// If using an Arduino Mega, make sure the SD library is configured for
004
// 'soft' SPI in the file Sd2Card.h.
005
006
/////// ***** Not Tested yet on SPFD5408 - next version I do it
007
008
#include <Adafruit_GFX.h> // Core graphics library
009
#include <Adafruit_TFTLCD.h> // Hardware-specific library
010
#include <SD.h>
011
012
// The control pins for the LCD can be assigned to any digital or
013
// analog pins...but we'll use the analog pins as this allows us to
014
// double up the pins with the touch screen (see the TFT paint example).
015
#define LCD_CS A3 // Chip Select goes to Analog 3
016
#define LCD_CD A2 // Command/Data goes to Analog 2
017
#define LCD_WR A1 // LCD Write goes to Analog 1
018
#define LCD_RD A0 // LCD Read goes to Analog 0
019
020
// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
021
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
022
// D0 connects to digital pin 8 (Notice these are
023
// D1 connects to digital pin 9 NOT in order!)
024
// D2 connects to digital pin 2
025
// D3 connects to digital pin 3
026
// D4 connects to digital pin 4
027
// D5 connects to digital pin 5
028
// D6 connects to digital pin 6
029
// D7 connects to digital pin 7
030
// For the Arduino Mega, use digital pins 22 through 29
031
// (on the 2-row header at the end of the board).
032
033
// For Arduino Uno/Duemilanove, etc
034
// connect the SD card with DI going to pin 11, DO going to pin 12 and SCK going to pin 13 (standard)
035
// Then pin 10 goes to CS (or whatever you have set up)
036
#define SD_CS 10 // Set the chip select line to whatever you use (10 doesnt conflict with the library)
037
038
// In the SD card, place 24 bit color BMP files (be sure they are 24-bit!)
039
// There are examples in the sketch folder
040
041
// our TFT wiring
042
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, A4);
043
044
void
setup
()
045
{
046
Serial
.begin(9600);
047
digitalWrite(35, HIGH);
//I use this on mega for LCD Backlight
048
tft.reset();
049
050
uint16_t identifier = tft.readID();
051
052
if
(identifier == 0x9325) {
053
progmemPrintln(PSTR(
"Found ILI9325 LCD driver"
));
054
}
else
if
(identifier == 0x9328) {
055
progmemPrintln(PSTR(
"Found ILI9328 LCD driver"
));
056
}
else
if
(identifier == 0x7575) {
057
progmemPrintln(PSTR(
"Found HX8347G LCD driver"
));
058
}
else
{
059
progmemPrint(PSTR(
"Unknown LCD driver chip: "
));
060
Serial
.println(identifier, HEX);
061
progmemPrintln(PSTR(
"If using the Adafruit 2.8\" TFT Arduino shield, the line:"
));
062
progmemPrintln(PSTR(
" #define USE_ADAFRUIT_SHIELD_PINOUT"
));
063
progmemPrintln(PSTR(
"should appear in the library header (Adafruit_TFT.h)."
));
064
progmemPrintln(PSTR(
"If using the breakout board, it should NOT be #defined!"
));
065
progmemPrintln(PSTR(
"Also if using the breakout, double-check that all wiring"
));
066
progmemPrintln(PSTR(
"matches the tutorial."
));
067
return
;
068
}
069
070
tft.begin(identifier);
071
072
progmemPrint(PSTR(
"Initializing SD card..."
));
073
if
(!SD.begin(SD_CS)) {
074
progmemPrintln(PSTR(
"failed!"
));
075
return
;
076
}
077
progmemPrintln(PSTR(
"OK!"
));
078
079
bmpDraw(
"woof.bmp"
, 0, 0);
080
delay(1000);
081
}
082
083
void
loop
()
084
{
085
for
(
int
i = 0; i<4; i++) {
086
tft.setRotation(i);
087
tft.fillScreen(0);
088
for
(
int
j=0; j <= 200; j += 50) {
089
bmpDraw(
"miniwoof.bmp"
, j, j);
090
}
091
delay(1000);
092
}
093
}
094
095
// This function opens a Windows Bitmap (BMP) file and
096
// displays it at the given coordinates. It's sped up
097
// by reading many pixels worth of data at a time
098
// (rather than pixel by pixel). Increasing the buffer
099
// size takes more of the Arduino's precious RAM but
100
// makes loading a little faster. 20 pixels seems a
101
// good balance.
102
103
#define BUFFPIXEL 20
104
105
void
bmpDraw(
char
*filename,
int
x,
int
y) {
106
107
File bmpFile;
108
int
bmpWidth, bmpHeight;
// W+H in pixels
109
uint8_t bmpDepth;
// Bit depth (currently must be 24)
110
uint32_t bmpImageoffset;
// Start of image data in file
111
uint32_t rowSize;
// Not always = bmpWidth; may have padding
112
uint8_t sdbuffer[3*BUFFPIXEL];
// pixel in buffer (R+G+B per pixel)
113
uint16_t lcdbuffer[BUFFPIXEL];
// pixel out buffer (16-bit per pixel)
114
uint8_t buffidx =
sizeof
(sdbuffer);
// Current position in sdbuffer
115
boolean goodBmp =
false
;
// Set to true on valid header parse
116
boolean flip =
true
;
// BMP is stored bottom-to-top
117
int
w, h, row, col;
118
uint8_t r, g, b;
119
uint32_t pos = 0, startTime = millis();
120
uint8_t lcdidx = 0;
121
boolean first =
true
;
122
123
if
((x >= tft.width()) || (y >= tft.height()))
return
;
124
125
Serial
.println();
126
progmemPrint(PSTR(
"Loading image '"
));
127
Serial
.print(filename);
128
Serial
.println(
'\''
);
129
// Open requested file on SD card
130
if
((bmpFile = SD.open(filename)) == NULL) {
131
progmemPrintln(PSTR(
"File not found"
));
132
return
;
133
}
134
135
// Parse BMP header
136
if
(read16(bmpFile) == 0x4D42) {
// BMP signature
137
progmemPrint(PSTR(
"File size: "
));
Serial
.println(read32(bmpFile));
138
(
void
)read32(bmpFile);
// Read & ignore creator bytes
139
bmpImageoffset = read32(bmpFile);
// Start of image data
140
progmemPrint(PSTR(
"Image Offset: "
));
Serial
.println(bmpImageoffset, DEC);
141
// Read DIB header
142
progmemPrint(PSTR(
"Header size: "
));
Serial
.println(read32(bmpFile));
143
bmpWidth = read32(bmpFile);
144
bmpHeight = read32(bmpFile);
145
if
(read16(bmpFile) == 1) {
// # planes -- must be '1'
146
bmpDepth = read16(bmpFile);
// bits per pixel
147
progmemPrint(PSTR(
"Bit Depth: "
));
Serial
.println(bmpDepth);
148
if
((bmpDepth == 24) && (read32(bmpFile) == 0)) {
// 0 = uncompressed
149
150
goodBmp =
true
;
// Supported BMP format -- proceed!
151
progmemPrint(PSTR(
"Image size: "
));
152
Serial
.print(bmpWidth);
153
Serial
.print(
'x'
);
154
Serial
.println(bmpHeight);
155
156
// BMP rows are padded (if needed) to 4-byte boundary
157
rowSize = (bmpWidth * 3 + 3) & ~3;
158
159
// If bmpHeight is negative, image is in top-down order.
160
// This is not canon but has been observed in the wild.
161
if
(bmpHeight < 0) {
162
bmpHeight = -bmpHeight;
163
flip =
false
;
164
}
165
166
// Crop area to be loaded
167
w = bmpWidth;
168
h = bmpHeight;
169
if
((x+w-1) >= tft.width()) w = tft.width() - x;
170
if
((y+h-1) >= tft.height()) h = tft.height() - y;
171
172
// Set TFT address window to clipped image bounds
173
tft.setAddrWindow(x, y, x+w-1, y+h-1);
174
175
for
(row=0; row<h; row++) {
// For each scanline...
176
// Seek to start of scan line. It might seem labor-
177
// intensive to be doing this on every line, but this
178
// method covers a lot of gritty details like cropping
179
// and scanline padding. Also, the seek only takes
180
// place if the file position actually needs to change
181
// (avoids a lot of cluster math in SD library).
182
if
(flip)
// Bitmap is stored bottom-to-top order (normal BMP)
183
pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
184
else
// Bitmap is stored top-to-bottom
185
pos = bmpImageoffset + row * rowSize;
186
if
(bmpFile.position() != pos) {
// Need seek?
187
bmpFile.seek(pos);
188
buffidx =
sizeof
(sdbuffer);
// Force buffer reload
189
}
190
191
for
(col=0; col<w; col++) {
// For each column...
192
// Time to read more pixel data?
193
if
(buffidx >=
sizeof
(sdbuffer)) {
// Indeed
194
// Push LCD buffer to the display first
195
if
(lcdidx > 0) {
196
tft.pushColors(lcdbuffer, lcdidx, first);
197
lcdidx = 0;
198
first =
false
;
199
}
200
bmpFile.read(sdbuffer,
sizeof
(sdbuffer));
201
buffidx = 0;
// Set index to beginning
202
}
203
204
// Convert pixel from BMP to TFT format
205
b = sdbuffer[buffidx++];
206
g = sdbuffer[buffidx++];
207
r = sdbuffer[buffidx++];
208
lcdbuffer[lcdidx++] = tft.color565(r,g,b);
209
}
// end pixel
210
}
// end scanline
211
// Write any remaining data to LCD
212
if
(lcdidx > 0) {
213
tft.pushColors(lcdbuffer, lcdidx, first);
214
}
215
progmemPrint(PSTR(
"Loaded in "
));
216
Serial
.print(millis() - startTime);
217
Serial
.println(
" ms"
);
218
}
// end goodBmp
219
}
220
}
221
222
bmpFile.close();
223
if
(!goodBmp) progmemPrintln(PSTR(
"BMP format not recognized."
));
224
}
225
226
// These read 16- and 32-bit types from the SD card file.
227
// BMP data is stored little-endian, Arduino is little-endian too.
228
// May need to reverse subscript order if porting elsewhere.
229
230
uint16_t read16(File f) {
231
uint16_t result;
232
((uint8_t *)&result)[0] = f.read();
// LSB
233
((uint8_t *)&result)[1] = f.read();
// MSB
234
return
result;
235
}
236
237
uint32_t read32(File f) {
238
uint32_t result;
239
((uint8_t *)&result)[0] = f.read();
// LSB
240
((uint8_t *)&result)[1] = f.read();
241
((uint8_t *)&result)[2] = f.read();
242
((uint8_t *)&result)[3] = f.read();
// MSB
243
return
result;
244
}
245
246
// Copy string from flash to serial port
247
// Source string MUST be inside a PSTR() declaration!
248
void
progmemPrint(
const
char
*str) {
249
char
c;
250
while
(c = pgm_read_byte(str++))
Serial
.print(c);
251
}
252
253
// Same as above, with trailing newline
254
void
progmemPrintln(
const
char
*str) {
255
progmemPrint(str);
256
Serial
.println();
257
}
То выходит такая ошибка:
Ошибка компиляции для платы Arduino/Genuino Uno.
Если такой:
001
// IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY
002
// CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.
003
// SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP.
004
005
// Modified for SPFD5408 Library by Joao Lopes
006
// Version 0.9.2 - Rotation for Mega and screen initial
007
008
// *** SPFD5408 change -- Begin
009
#include <SPFD5408_Adafruit_GFX.h> // Core graphics library
010
#include <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library
011
#include <SPFD5408_TouchScreen.h>
012
// *** SPFD5408 change -- End
013
014
// The control pins for the LCD can be assigned to any digital or
015
// analog pins...but we'll use the analog pins as this allows us to
016
// double up the pins with the touch screen (see the TFT paint example).
017
#define LCD_CS A3 // Chip Select goes to Analog 3
018
#define LCD_CD A2 // Command/Data goes to Analog 2
019
#define LCD_WR A1 // LCD Write goes to Analog 1
020
#define LCD_RD A0 // LCD Read goes to Analog 0
021
022
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
023
024
// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
025
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
026
// D0 connects to digital pin 8 (Notice these are
027
// D1 connects to digital pin 9 NOT in order!)
028
// D2 connects to digital pin 2
029
// D3 connects to digital pin 3
030
// D4 connects to digital pin 4
031
// D5 connects to digital pin 5
032
// D6 connects to digital pin 6
033
// D7 connects to digital pin 7
034
// For the Arduino Mega, use digital pins 22 through 29
035
// (on the 2-row header at the end of the board).
036
037
// Assign human-readable names to some common 16-bit color values:
038
#define BLACK 0x0000
039
#define BLUE 0x001F
040
#define RED 0xF800
041
#define GREEN 0x07E0
042
#define CYAN 0x07FF
043
#define MAGENTA 0xF81F
044
#define YELLOW 0xFFE0
045
#define WHITE 0xFFFF
046
047
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
048
// If using the shield, all control and data lines are fixed, and
049
// a simpler declaration can optionally be used:
050
// Adafruit_TFTLCD tft;
051
052
// -- Setup
053
054
void
setup
(
void
) {
055
056
Serial
.begin(9600);
057
058
progmemPrintln(PSTR(
"TFT LCD test"
));
059
060
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
061
progmemPrintln(PSTR(
"Using Adafruit 2.8\" TFT Arduino Shield Pinout"
));
062
#else
063
progmemPrintln(PSTR(
"Using Adafruit 2.8\" TFT Breakout Board Pinout"
));
064
#endif
065
066
tft.reset();
067
068
// *** SPFD5408 change -- Begin
069
070
// Original code commented
071
072
// uint16_t identifier = tft.readID();
073
//
074
// if(identifier == 0x9325) {
075
// Serial.println(F("Found ILI9325 LCD driver"));
076
// } else if(identifier == 0x9328) {
077
// Serial.println(F("Found ILI9328 LCD driver"));
078
// } else if(identifier == 0x7575) {
079
// Serial.println(F("Found HX8347G LCD driver"));
080
// } else if(identifier == 0x9341) {
081
// Serial.println(F("Found ILI9341 LCD driver"));
082
// } else if(identifier == 0x8357) {
083
// Serial.println(F("Found HX8357D LCD driver"));
084
// } else {
085
// Serial.print(F("Unknown LCD driver chip: "));
086
// Serial.println(identifier, HEX);
087
// Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
088
// Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
089
// Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
090
// Serial.println(F("If using the breakout board, it should NOT be #defined!"));
091
// Serial.println(F("Also if using the breakout, double-check that all wiring"));
092
// Serial.println(F("matches the tutorial."));
093
// return;
094
// }
095
//
096
// tft.begin(identifier);
097
098
// Code changed to works
099
100
tft.begin(0x9341);
// SDFP5408
101
102
tft.setRotation(0);
// Need for the Mega, please changed for your choice or rotation initial
103
104
// *** SPFD5408 change -- End
105
106
progmemPrintln(PSTR(
"Benchmark Time (microseconds)"
));
107
108
progmemPrint(PSTR(
"Screen fill "
));
109
Serial
.println(testFillScreen());
110
delay(500);
111
112
progmemPrint(PSTR(
"Text "
));
113
Serial
.println(testText());
114
delay(3000);
115
116
progmemPrint(PSTR(
"Lines "
));
117
Serial
.println(testLines(CYAN));
118
delay(500);
119
120
progmemPrint(PSTR(
"Horiz/Vert Lines "
));
121
Serial
.println(testFastLines(RED, BLUE));
122
delay(500);
123
124
progmemPrint(PSTR(
"Rectangles (outline) "
));
125
Serial
.println(testRects(GREEN));
126
delay(500);
127
128
progmemPrint(PSTR(
"Rectangles (filled) "
));
129
Serial
.println(testFilledRects(YELLOW, MAGENTA));
130
delay(500);
131
132
progmemPrint(PSTR(
"Circles (filled) "
));
133
Serial
.println(testFilledCircles(10, MAGENTA));
134
135
progmemPrint(PSTR(
"Circles (outline) "
));
136
Serial
.println(testCircles(10, WHITE));
137
delay(500);
138
139
progmemPrint(PSTR(
"Triangles (outline) "
));
140
Serial
.println(testTriangles());
141
delay(500);
142
143
progmemPrint(PSTR(
"Triangles (filled) "
));
144
Serial
.println(testFilledTriangles());
145
delay(500);
146
147
progmemPrint(PSTR(
"Rounded rects (outline) "
));
148
Serial
.println(testRoundRects());
149
delay(500);
150
151
progmemPrint(PSTR(
"Rounded rects (filled) "
));
152
Serial
.println(testFilledRoundRects());
153
delay(500);
154
155
progmemPrintln(PSTR(
"Done!"
));
156
}
157
158
void
loop
(
void
) {
159
for
(uint8_t rotation=0; rotation<4; rotation++) {
160
tft.setRotation(rotation);
161
testText();
162
delay(2000);
163
}
164
}
165
166
unsigned
long
testFillScreen() {
167
unsigned
long
start = micros();
168
tft.fillScreen(BLACK);
169
tft.fillScreen(RED);
170
tft.fillScreen(GREEN);
171
tft.fillScreen(BLUE);
172
tft.fillScreen(BLACK);
173
return
micros() - start;
174
}
175
176
unsigned
long
testText() {
177
tft.fillScreen(BLACK);
178
unsigned
long
start = micros();
179
tft.setCursor(0, 0);
180
tft.setTextColor(WHITE); tft.setTextSize(1);
181
tft.println(
"Hello World!"
);
182
tft.setTextColor(YELLOW); tft.setTextSize(2);
183
tft.println(1234.56);
184
tft.setTextColor(RED); tft.setTextSize(3);
185
tft.println(0xDEADBEEF, HEX);
186
tft.println();
187
tft.setTextColor(GREEN);
188
tft.setTextSize(5);
189
tft.println(
"Groop"
);
190
tft.setTextSize(2);
191
tft.println(
"I implore thee,"
);
192
tft.setTextSize(1);
193
tft.println(
"my foonting turlingdromes."
);
194
tft.println(
"And hooptiously drangle me"
);
195
tft.println(
"with crinkly bindlewurdles,"
);
196
tft.println(
"Or I will rend thee"
);
197
tft.println(
"in the gobberwarts"
);
198
tft.println(
"with my blurglecruncheon,"
);
199
tft.println(
"see if I don't!"
);
200
return
micros() - start;
201
}
202
203
unsigned
long
testLines(uint16_t color) {
204
unsigned
long
start, t;
205
int
x1, y1, x2, y2,
206
w = tft.width(),
207
h = tft.height();
208
209
tft.fillScreen(BLACK);
210
211
x1 = y1 = 0;
212
y2 = h - 1;
213
start = micros();
214
for
(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
215
x2 = w - 1;
216
for
(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
217
t = micros() - start;
// fillScreen doesn't count against timing
218
219
tft.fillScreen(BLACK);
220
221
x1 = w - 1;
222
y1 = 0;
223
y2 = h - 1;
224
start = micros();
225
for
(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
226
x2 = 0;
227
for
(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
228
t += micros() - start;
229
230
tft.fillScreen(BLACK);
231
232
x1 = 0;
233
y1 = h - 1;
234
y2 = 0;
235
start = micros();
236
for
(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
237
x2 = w - 1;
238
for
(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
239
t += micros() - start;
240
241
tft.fillScreen(BLACK);
242
243
x1 = w - 1;
244
y1 = h - 1;
245
y2 = 0;
246
start = micros();
247
for
(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
248
x2 = 0;
249
for
(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
250
251
return
micros() - start;
252
}
253
254
unsigned
long
testFastLines(uint16_t color1, uint16_t color2) {
255
unsigned
long
start;
256
int
x, y, w = tft.width(), h = tft.height();
257
258
tft.fillScreen(BLACK);
259
start = micros();
260
for
(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
261
for
(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);
262
263
return
micros() - start;
264
}
265
266
unsigned
long
testRects(uint16_t color) {
267
unsigned
long
start;
268
int
n, i, i2,
269
cx = tft.width() / 2,
270
cy = tft.height() / 2;
271
272
tft.fillScreen(BLACK);
273
n = min(tft.width(), tft.height());
274
start = micros();
275
for
(i=2; i<n; i+=6) {
276
i2 = i / 2;
277
tft.drawRect(cx-i2, cy-i2, i, i, color);
278
}
279
280
return
micros() - start;
281
}
282
283
unsigned
long
testFilledRects(uint16_t color1, uint16_t color2) {
284
unsigned
long
start, t = 0;
285
int
n, i, i2,
286
cx = tft.width() / 2 - 1,
287
cy = tft.height() / 2 - 1;
288
289
tft.fillScreen(BLACK);
290
n = min(tft.width(), tft.height());
291
for
(i=n; i>0; i-=6) {
292
i2 = i / 2;
293
start = micros();
294
tft.fillRect(cx-i2, cy-i2, i, i, color1);
295
t += micros() - start;
296
// Outlines are not included in timing results
297
tft.drawRect(cx-i2, cy-i2, i, i, color2);
298
}
299
300
return
t;
301
}
302
303
unsigned
long
testFilledCircles(uint8_t radius, uint16_t color) {
304
unsigned
long
start;
305
int
x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
306
307
tft.fillScreen(BLACK);
308
start = micros();
309
for
(x=radius; x<w; x+=r2) {
310
for
(y=radius; y<h; y+=r2) {
311
tft.fillCircle(x, y, radius, color);
312
}
313
}
314
315
return
micros() - start;
316
}
317
318
unsigned
long
testCircles(uint8_t radius, uint16_t color) {
319
unsigned
long
start;
320
int
x, y, r2 = radius * 2,
321
w = tft.width() + radius,
322
h = tft.height() + radius;
323
324
// Screen is not cleared for this one -- this is
325
// intentional and does not affect the reported time.
326
start = micros();
327
for
(x=0; x<w; x+=r2) {
328
for
(y=0; y<h; y+=r2) {
329
tft.drawCircle(x, y, radius, color);
330
}
331
}
332
333
return
micros() - start;
334
}
335
336
unsigned
long
testTriangles() {
337
unsigned
long
start;
338
int
n, i, cx = tft.width() / 2 - 1,
339
cy = tft.height() / 2 - 1;
340
341
tft.fillScreen(BLACK);
342
n = min(cx, cy);
343
start = micros();
344
for
(i=0; i<n; i+=5) {
345
tft.drawTriangle(
346
cx , cy - i,
// peak
347
cx - i, cy + i,
// bottom left
348
cx + i, cy + i,
// bottom right
349
tft.color565(0, 0, i));
350
}
351
352
return
micros() - start;
353
}
354
355
unsigned
long
testFilledTriangles() {
356
unsigned
long
start, t = 0;
357
int
i, cx = tft.width() / 2 - 1,
358
cy = tft.height() / 2 - 1;
359
360
tft.fillScreen(BLACK);
361
start = micros();
362
for
(i=min(cx,cy); i>10; i-=5) {
363
start = micros();
364
tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
365
tft.color565(0, i, i));
366
t += micros() - start;
367
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
368
tft.color565(i, i, 0));
369
}
370
371
return
t;
372
}
373
374
unsigned
long
testRoundRects() {
375
unsigned
long
start;
376
int
w, i, i2,
377
cx = tft.width() / 2 - 1,
378
cy = tft.height() / 2 - 1;
379
380
tft.fillScreen(BLACK);
381
w = min(tft.width(), tft.height());
382
start = micros();
383
for
(i=0; i<w; i+=6) {
384
i2 = i / 2;
385
tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
386
}
387
388
return
micros() - start;
389
}
390
391
unsigned
long
testFilledRoundRects() {
392
unsigned
long
start;
393
int
i, i2,
394
cx = tft.width() / 2 - 1,
395
cy = tft.height() / 2 - 1;
396
397
tft.fillScreen(BLACK);
398
start = micros();
399
for
(i=min(tft.width(), tft.height()); i>20; i-=6) {
400
i2 = i / 2;
401
tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
402
}
403
404
return
micros() - start;
405
}
406
407
// Copy string from flash to serial port
408
// Source string MUST be inside a PSTR() declaration!
409
void
progmemPrint(
const
char
*str) {
410
char
c;
411
while
(c = pgm_read_byte(str++))
Serial
.print(c);
412
}
413
414
// Same as above, with trailing newline
415
void
progmemPrintln(
const
char
*str) {
416
progmemPrint(str);
417
Serial
.println();
418
}
То компиляция происходит, но выходит предупреждение:
А на экране ноль измененией
Клапауций 232 , моё почтение!)
Столько раз мне помогал)
Какая ардуина? На уне у меня работает.
https://github.com/JoaoLopesF/SPFD5408
И Уно и Мега, китайские, да, именно эту библиотеку брал. Не работает...
Windows 10... Хотя я и на XP пробовал раньше
Пробую
Файл-Примеры- SPFD-5408-master ->tftbmp
выходит ошибка -
Ошибка компиляции для платы Arduino/Genuino Uno.
Ну? отсутствует файл. Распакуй библиотеку заново. От винды ничего не зависит. Плата же у тебя видится и пример пытается загрузиться?
А IDE не слишком новой версии?
Слишком))
Есть там этот файл. Adafruit_TFTLCD.h вручную просмотрел. Именно в папке библиотеке
Есть там этот файл. Adafruit_TFTLCD.h вручную просмотрел. Именно в папке библиотеке
Либо там, но не этот, либо этот но не там. Компилер напраслину не погонит, он его не видет просто.
Попробуй другую библиотеку. UTFT на пример.
поробовал... Но экран всё белый)
Хотя, ошибок с UTFT Нет)
попробуйте эту
https://github.com/prenticedavid/MCUFRIEND_kbv
О!!! Вот оно и есть!!!
Спасибо огромное!!!!
Походу дело не в библиотеке а в настройках контроллера. Скорее всего последняя библиотека совпала по настройкам с контроллером вашего дисплея. По сути любая библиотека подойдет. Главное правильно кантроллер настроить. На эту тему есть отдельный равернутый топик http://arduino.ru/forum/apparatnye-voprosy/arduino-i-displei-ot-sotikov-mobilnykh-telefonov
Китаец с Али, прислал этот файл.
Сказал, что библиотека, но установить не могу)) Может вы сможете объяснить, что это)) Да и может пригодится еще кому)
https://yadi.sk/d/l3suQMALxCNV5