Added a routine to track init errors
This commit is contained in:
parent
2ca4e26eb6
commit
55b1f58e63
5 changed files with 79 additions and 111 deletions
|
|
@ -274,7 +274,7 @@
|
||||||
void TFT_ILI9163C::begin(void)
|
void TFT_ILI9163C::begin(void)
|
||||||
{
|
{
|
||||||
sleep = 0;
|
sleep = 0;
|
||||||
|
_initError = 0b00000000;
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
pinMode(_rs, OUTPUT);
|
pinMode(_rs, OUTPUT);
|
||||||
pinMode(_cs, OUTPUT);
|
pinMode(_cs, OUTPUT);
|
||||||
|
|
@ -325,6 +325,7 @@ void TFT_ILI9163C::begin(void)
|
||||||
SPI.setMOSI(_mosi);
|
SPI.setMOSI(_mosi);
|
||||||
SPI.setSCK(_sclk);
|
SPI.setSCK(_sclk);
|
||||||
} else {
|
} else {
|
||||||
|
bitSet(_initError,1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
|
|
@ -334,6 +335,7 @@ void TFT_ILI9163C::begin(void)
|
||||||
} else {
|
} else {
|
||||||
pcs_data = 0;
|
pcs_data = 0;
|
||||||
pcs_command = 0;
|
pcs_command = 0;
|
||||||
|
bitSet(_initError,0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else//all the rest of possible boards
|
#else//all the rest of possible boards
|
||||||
|
|
@ -384,7 +386,10 @@ void TFT_ILI9163C::begin(void)
|
||||||
chipInit();
|
chipInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t TFT_ILI9163C::errorCode(void)
|
||||||
|
{
|
||||||
|
return _initError;
|
||||||
|
}
|
||||||
|
|
||||||
void TFT_ILI9163C::chipInit() {
|
void TFT_ILI9163C::chipInit() {
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,7 @@ class TFT_ILI9163C : public Adafruit_GFX {
|
||||||
fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color),
|
fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color),
|
||||||
setRotation(uint8_t r),
|
setRotation(uint8_t r),
|
||||||
invertDisplay(boolean i);
|
invertDisplay(boolean i);
|
||||||
|
uint8_t errorCode(void);
|
||||||
void idleMode(boolean onOff);
|
void idleMode(boolean onOff);
|
||||||
void display(boolean onOff);
|
void display(boolean onOff);
|
||||||
void sleepMode(boolean mode);
|
void sleepMode(boolean mode);
|
||||||
|
|
@ -447,5 +448,6 @@ class TFT_ILI9163C : public Adafruit_GFX {
|
||||||
void chipInit();
|
void chipInit();
|
||||||
bool boundaryCheck(int16_t x,int16_t y);
|
bool boundaryCheck(int16_t x,int16_t y);
|
||||||
void homeAddress();
|
void homeAddress();
|
||||||
|
uint8_t _initError;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -87,73 +87,21 @@ Not tested!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Benchmark Time (microseconds)
|
Benchmark Time (microseconds)
|
||||||
Screen fill 74697
|
Screen fill 74698
|
||||||
Text 4841
|
Text 4253
|
||||||
Lines 16025
|
Text2 15366
|
||||||
|
Lines 16034
|
||||||
Horiz/Vert Lines 5028
|
Horiz/Vert Lines 5028
|
||||||
Rectangles (outline) 4181
|
Rectangles (outline) 4183
|
||||||
Rectangles (filled) 91225
|
Rectangles (filled) 91226
|
||||||
Circles (filled) 14452
|
Circles (filled) 14436
|
||||||
Circles (outline) 16397
|
Circles (outline) 14910
|
||||||
Triangles (outline) 5069
|
Triangles (outline) 5069
|
||||||
Triangles (filled) 30715
|
Triangles (filled) 30717
|
||||||
Rounded rects (outline) 10382
|
Rounded rects (outline) 9910
|
||||||
Rounded rects (filled) 99552
|
Rounded rects (filled) 99550
|
||||||
Done!
|
Done!
|
||||||
|
|
||||||
Benchmark Time (microseconds)
|
|
||||||
Screen fill 74697
|
|
||||||
Text 4453
|
|
||||||
Text2 16541
|
|
||||||
Lines 16027
|
|
||||||
Horiz/Vert Lines 5029
|
|
||||||
Rectangles (outline) 4185
|
|
||||||
Rectangles (filled) 91223
|
|
||||||
Circles (filled) 14408
|
|
||||||
Circles (outline) 15082
|
|
||||||
Triangles (outline) 5067
|
|
||||||
Triangles (filled) 17439
|
|
||||||
Rounded rects (outline) 10023
|
|
||||||
Rounded rects (filled) 99513
|
|
||||||
Done!
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Benchmark Time (microseconds)
|
|
||||||
Screen fill 277415
|
|
||||||
Text 11618
|
|
||||||
Text2 36043
|
|
||||||
Lines 58163
|
|
||||||
Horiz/Vert Lines 18655
|
|
||||||
Rectangles (outline) 15391
|
|
||||||
Rectangles (filled) 338450
|
|
||||||
Circles (filled) 53050
|
|
||||||
Circles (outline) 39227
|
|
||||||
Triangles (outline) 18302
|
|
||||||
Triangles (filled) 64198
|
|
||||||
Rounded rects (outline) 29676
|
|
||||||
Rounded rects (filled) 368960
|
|
||||||
Done!
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Benchmark Time (microseconds)
|
|
||||||
Screen fill 277422
|
|
||||||
Text 13066
|
|
||||||
Lines 58240
|
|
||||||
Horiz/Vert Lines 18655
|
|
||||||
Rectangles (outline) 15422
|
|
||||||
Rectangles (filled) 339230
|
|
||||||
Circles (filled) 53049
|
|
||||||
Circles (outline) 43195
|
|
||||||
Triangles (outline) 18350
|
|
||||||
Triangles (filled) 113536
|
|
||||||
Rounded rects (outline) 31470
|
|
||||||
Rounded rects (filled) 369703
|
|
||||||
Done!
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
@ -19,6 +19,8 @@
|
||||||
#define YELLOW 0xFFE0
|
#define YELLOW 0xFFE0
|
||||||
#define WHITE 0xFFFF
|
#define WHITE 0xFFFF
|
||||||
|
|
||||||
|
uint8_t errorCode = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Teensy3.x and Arduino's
|
Teensy3.x and Arduino's
|
||||||
You are using 4 wire SPI here, so:
|
You are using 4 wire SPI here, so:
|
||||||
|
|
@ -28,77 +30,87 @@ You are using 4 wire SPI here, so:
|
||||||
the rest of pin below:
|
the rest of pin below:
|
||||||
*/
|
*/
|
||||||
#define __CS 10
|
#define __CS 10
|
||||||
#define __DC 9
|
#define __DC 6
|
||||||
/*
|
/*
|
||||||
Teensy 3.x can use: 2,6,9,10,15,20,21,22,23
|
Teensy 3.x can use: 2,6,9,10,15,20,21,22,23
|
||||||
Arduino's 8 bit: any
|
Arduino's 8 bit: any
|
||||||
DUE: check arduino site
|
DUE: check arduino site
|
||||||
IMPORTANT!!!
|
If you do not use reset, tie it to +3V3
|
||||||
If you do not use reset pin, tie it to +3V3!! Do not leave floating!
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC);
|
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, 23);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(38400);
|
Serial.begin(38400);
|
||||||
long unsigned debug_start = millis ();
|
long unsigned debug_start = millis ();
|
||||||
while (!Serial && ((millis () - debug_start) <= 5000)) ;
|
while (!Serial && ((millis () - debug_start) <= 5000)) ;
|
||||||
tft.begin();
|
tft.begin();
|
||||||
|
//the following it's mainly for Teensy
|
||||||
|
//it will help you to understand if you have choosed the
|
||||||
|
//wrong combination of pins!
|
||||||
|
errorCode = tft.errorCode();
|
||||||
|
if (errorCode != 0) {
|
||||||
|
Serial.print("Init error! ");
|
||||||
|
if (bitRead(errorCode, 0)) Serial.print("MOSI or SCLK pin mismach!\n");
|
||||||
|
if (bitRead(errorCode, 1)) Serial.print("CS or DC pin mismach!\n");
|
||||||
|
} else {
|
||||||
|
Serial.println(F("Benchmark Time (microseconds)"));
|
||||||
|
}
|
||||||
|
if (errorCode == 0) {
|
||||||
|
Serial.print(F("Screen fill "));
|
||||||
|
Serial.println(testFillScreen());
|
||||||
|
delay(500);
|
||||||
|
|
||||||
Serial.println(F("Benchmark Time (microseconds)"));
|
Serial.print(F("Text "));
|
||||||
Serial.print(F("Screen fill "));
|
Serial.println(testText());
|
||||||
Serial.println(testFillScreen());
|
delay(3000);
|
||||||
delay(500);
|
|
||||||
|
|
||||||
Serial.print(F("Text "));
|
Serial.print(F("Text2 "));
|
||||||
Serial.println(testText());
|
Serial.println(testText2());
|
||||||
delay(3000);
|
delay(3000);
|
||||||
|
|
||||||
Serial.print(F("Text2 "));
|
Serial.print(F("Lines "));
|
||||||
Serial.println(testText2());
|
Serial.println(testLines(CYAN));
|
||||||
delay(3000);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Lines "));
|
Serial.print(F("Horiz/Vert Lines "));
|
||||||
Serial.println(testLines(CYAN));
|
Serial.println(testFastLines(RED, BLUE));
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Horiz/Vert Lines "));
|
Serial.print(F("Rectangles (outline) "));
|
||||||
Serial.println(testFastLines(RED, BLUE));
|
Serial.println(testRects(GREEN));
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Rectangles (outline) "));
|
Serial.print(F("Rectangles (filled) "));
|
||||||
Serial.println(testRects(GREEN));
|
Serial.println(testFilledRects(YELLOW, MAGENTA));
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Rectangles (filled) "));
|
Serial.print(F("Circles (filled) "));
|
||||||
Serial.println(testFilledRects(YELLOW, MAGENTA));
|
Serial.println(testFilledCircles(10, MAGENTA));
|
||||||
delay(500);
|
|
||||||
|
|
||||||
Serial.print(F("Circles (filled) "));
|
Serial.print(F("Circles (outline) "));
|
||||||
Serial.println(testFilledCircles(10, MAGENTA));
|
Serial.println(testCircles(10, WHITE));
|
||||||
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Circles (outline) "));
|
Serial.print(F("Triangles (outline) "));
|
||||||
Serial.println(testCircles(10, WHITE));
|
Serial.println(testTriangles());
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Triangles (outline) "));
|
Serial.print(F("Triangles (filled) "));
|
||||||
Serial.println(testTriangles());
|
Serial.println(testFilledTriangles());
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Triangles (filled) "));
|
Serial.print(F("Rounded rects (outline) "));
|
||||||
Serial.println(testFilledTriangles());
|
Serial.println(testRoundRects());
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Rounded rects (outline) "));
|
Serial.print(F("Rounded rects (filled) "));
|
||||||
Serial.println(testRoundRects());
|
Serial.println(testFilledRoundRects());
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
Serial.print(F("Rounded rects (filled) "));
|
Serial.println(F("Done!"));
|
||||||
Serial.println(testFilledRoundRects());
|
}
|
||||||
delay(500);
|
|
||||||
|
|
||||||
Serial.println(F("Done!"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(void) {
|
void loop(void) {
|
||||||
|
|
@ -17,4 +17,5 @@ endPushData KEYWORD2
|
||||||
defineScrollArea KEYWORD2
|
defineScrollArea KEYWORD2
|
||||||
writeScreen24 KEYWORD2
|
writeScreen24 KEYWORD2
|
||||||
idleMode KEYWORD2
|
idleMode KEYWORD2
|
||||||
|
errorCode KEYWORD2
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue