Added a routine to track init errors

This commit is contained in:
sumotoy 2015-06-09 16:46:48 +02:00
parent 2ca4e26eb6
commit 55b1f58e63
5 changed files with 79 additions and 111 deletions

View file

@ -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;

View file

@ -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

View file

@ -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!
*/ */

View file

@ -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,25 +30,34 @@ 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)")); Serial.println(F("Benchmark Time (microseconds)"));
}
if (errorCode == 0) {
Serial.print(F("Screen fill ")); Serial.print(F("Screen fill "));
Serial.println(testFillScreen()); Serial.println(testFillScreen());
delay(500); delay(500);
@ -100,6 +111,7 @@ void setup() {
Serial.println(F("Done!")); Serial.println(F("Done!"));
} }
}
void loop(void) { void loop(void) {
for (uint8_t rotation = 0; rotation < 4; rotation++) { for (uint8_t rotation = 0; rotation < 4; rotation++) {

View file

@ -17,4 +17,5 @@ endPushData KEYWORD2
defineScrollArea KEYWORD2 defineScrollArea KEYWORD2
writeScreen24 KEYWORD2 writeScreen24 KEYWORD2
idleMode KEYWORD2 idleMode KEYWORD2
errorCode KEYWORD2