ILI9163C 128x128 TFT driver

Status
Not open for further replies.
My first guess is problems with using pin 7 for CS.

#define __CS 7
#define __DC 9
#define __RST 8

TFT_ILI9163C display = TFT_ILI9163C(__CS, __DC, __RST);

Sumotoy's library uses the highly optimized SPI code, which requires both CS and DC using the hardware-controlled CS pins. Teensy 3.1's hardware can only generate 5 of those special fast CS signals. The possible pins are 9, 10, 15, 20 and 21. You've already connected DC to pin 9, but CS also needs to be on one of those 5 pins. Using pin 7 won't work (or if it does sometimes work, that's only because the pin happens to "float" to a logic low voltage sometimes). Sumotoy's library won't do anything at all with pin 7, so it's signal will be just random noise.

Regular (not highly optimized) SPI code using the SPI library uses digitalWrite() to control the CS signal. Peter Torelli's SPI Flash code works that way. Because it's using digitalWrite, you can use any digital pin. You're not limited to the 5 special hardware-controlled SPI signals.

To make matters even more confusing, those 5 special signals have alternate pins. We no longer print those on the pin reference card that comes with every Teensy, because it's just too confusing to figure out which ones might conflict with each other. But if you look in the code, you'll see those other pins and special checks for the conflicting combinations. I recommend simply using one of the 5 main pins (9, 10, 15, 20 and 21), but it also also possible to access 4 of those 5 special chip selects on pins 2, 6, 22 and 23.

Of course it's possible something else is wrong, but I'd start by moving the display's CS line from pin 7 to one of those 5 special chip select pins which Sumotoy's library requires.
 
Thanks for the quick reply Paul.

I updated my post to show . . .


Board: Arduino UNO

Wiring

sck - pin 13
reset - pin 9
sda - pin 11
cs - pin 8
A0 (DC) - pin 10
GND - GND
VCC - VCC
LED - 3.3v


Code setup

#define __CS 8
#define __DC 10
#define __RST 9


I changed the wiring and code to

CS 9
DC 10
RST 8

but with the same problem


and

CS 2
DC 10
RST 8

but with same problem


Is this relevent as im using an Arduino UNO?
 
Oh, no, on Arduino Uno you can use any pins for CS & DC.

The fast SPI code that requires specific CS & DC pins is only used on Teensy 3.0 & 3.1.
 
Thanks a lot Paul, you always trying to help!
I was using your SPI optimizations for Teensy so I have commented the pin to use with teensy in the GitHub, btw I will update all set with the new optimized code you have done recently that it's safer,faster and thanks to your SPI Transaction suggestion (that really worked in several other projects I was playing recently) it will be more compatible.
This little displays are really cheap but have some small nasty problems, for example they can handle fast SPI communications but if you refresh screen very fast I always got a white flash in one of the screen side and unfortunatly looks like an hardware problem of the ILI chip, only visible on very fast MCU btw.
Another hardware problem is the SPI lookups (correct logic states of the SPI lines) that Paul observed recently and looks like very popular on cheap cina/taiwan chip (RA8875, ILI9340 are affected), I will try the Paul suggestion but in this case I don't use MISO here but seems like display designer used some kind of pull-up,pull-down load on SPI lines that can affect other devices connected, that's it's the price to pay for some made-in-china poorly designed stuff!

Regarding issues...
Castingflame, I suggest to move the conversation on GitHub if it's a problem related to Arduino's since this is a Teensy board, I don't want to use site resources and confuse the other users here so I promise you to help resolving issues on GitHub.
https://github.com/sumotoy/TFT_ILI9163C/issues/1
I got a couple of 128x128 RED tag display's here ( I never play with a BLACK tag one), also get an UNO so I'm ready to solve your issue.
A note about library's SPI, to get the speed it uses (almost) optimized-for-speed routines for sam/arm and avr so this can be the problem with the SPI flash chi that can be solved (and I will because I will like to play with SPI FLASH chip).
You can see in the video proof on the top of the post that I not haved any problem with addressing, I have a video with UNO and same results but was a RED tag!. I was sure that black one has only differences in color handling but looks like there's more under the skin.

For the AVR SPI issue with other SPI devices here's the link:
https://github.com/sumotoy/TFT_ILI9163C/issues/2
 
Last edited:
Every time I see something cool done on this forum using a Teensy 3.1 I'm inclined to try it myself and in the process have to spend more money and buy more stuff. Luckily this time the stuff was an inexpensive 1.4" Red Serial 128X128 SPI Color TFT LCD display bought on eBay. After reading about somotoy's speedy driver for this display I just had to try it myself.

For the record, I connected the Teensy 3.1 to the display as follows:

Teensy 3.1 Pin LCD Pin
3.3V Vcc
Gnd Gnd
10 CS
14 RESET
9 A0
11 SDA
13 SCK
3 LED

Because of the compact size of the display and the Teensy, I decided to build a necklace for a friend. A 3.7 V 500mAh LiPo battery and switch completed the build. I haven't yet built a case for the necklace but I will when the snow melts and the weather warms up so I can work in the garage.

When the Necklace is powered up it displays a series of six dynamic and colorful patterns over and over. Each pattern is displayed for a set length of time which can be changed in the code.

Enough about the hardware. The necklace would only be as cool as the software for it so besides the code I wrote, I borrowed bits and pieces of code from the FastLED project, the Aurora Project and others. Special mention goes to

Somotoy for the incredibly fast display driver
Stefan Petrick for his beautiful Mandala display code
Jason Coon and Mark Kriegsman for the Noise display code
Jozsef Fejes for his Rainbow Smoke pattern code (which I refer to as Watercolor)
Jason Coon again for his Waves display pattern

Additionally, the following libraries are required to get the code running.
FastLED v.3.1
Adafruit_GFX
TFT_ILI9163C
SPI

I take no credit for other people's code except for porting and modifying the code to run in my "Necklace" environment.

I haven't had time to shoot a video showing the necklace in operation but I assure you it is very beautiful and attention getting.

A zip file for the Necklace code can be found at: http://www.craigandheather.net/misc/Necklace.zip

If you have this display already you should try out this code.
 
Every time I see something cool done on this forum using a Teensy 3.1 I'm inclined to try it myself and in the process have to spend more money and buy more stuff. Luckily this time the stuff was an inexpensive 1.4" Red Serial 128X128 SPI Color TFT LCD display bought on eBay. After reading about somotoy's speedy driver for this display I just had to try it myself.

For the record, I connected the Teensy 3.1 to the display as follows:

Teensy 3.1 Pin LCD Pin
3.3V Vcc
Gnd Gnd
10 CS
14 RESET
9 A0
11 SDA
13 SCK
3 LED

Because of the compact size of the display and the Teensy, I decided to build a necklace for a friend. A 3.7 V 500mAh LiPo battery and switch completed the build. I haven't yet built a case for the necklace but I will when the snow melts and the weather warms up so I can work in the garage.

When the Necklace is powered up it displays a series of six dynamic and colorful patterns over and over. Each pattern is displayed for a set length of time which can be changed in the code.

Enough about the hardware. The necklace would only be as cool as the software for it so besides the code I wrote, I borrowed bits and pieces of code from the FastLED project, the Aurora Project and others. Special mention goes to

Somotoy for the incredibly fast display driver
Stefan Petrick for his beautiful Mandala display code
Jason Coon and Mark Kriegsman for the Noise display code
Jozsef Fejes for his Rainbow Smoke pattern code (which I refer to as Watercolor)
Jason Coon again for his Waves display pattern

Additionally, the following libraries are required to get the code running.
FastLED v.3.1
Adafruit_GFX
TFT_ILI9163C
SPI

I take no credit for other people's code except for porting and modifying the code to run in my "Necklace" environment.

I haven't had time to shoot a video showing the necklace in operation but I assure you it is very beautiful and attention getting.

A zip file for the Necklace code can be found at: http://www.craigandheather.net/misc/Necklace.zip

If you have this display already you should try out this code.



I needed to change your 'printf' statements to just 'print' in your Mandala.h & Watercolour.h files but it runs ok. However I still have the same display issue as before with it only using 3/4 of the screen.


I will comment no longer on here as asked and will move over to the github link kindly provided here by sumotoy.

Thanks, Paul
 
Last edited:
vastydeep, I've just updated library, now it's SPI Transaction compatible and has (I hope) the correct init for the new BLACK tag displays.
I don't have any flash chip around, if you want to test it... But read the great SPI transaction page of Paul Stoffregen, maybe you need to some more info or modify a bit the flash chip library.
Added some new example, check bubbles, quite interesting :)

castingflame, try to comment #define __144_RED_PCB__ and enable #define __144_BLACK_PCB__ in the TFT_ILI9163C.h file, I discovered that the actual black tag display laying around ebay has the same pcb of the red one but different display that needs different setting, I've updated the library to support it (for all mcu's, Teensy included).
I've reworked SPI for Teensy using the great work that Paul done recently but still using Adafruit_GFX since for some reason it's more fast, again, check bubbles.ino example to see how fast is.
 
Last edited:
TFT and SPI Flash

Thanks sumotoy and PaulStoffregen: I'm now able to display images from the flash chip on the TFT using the T3.1.

Teensy31_TFT_Flash.jpg

Here's the code that's working:

Code:
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>

// WinBond flash commands
#define WB_READ_STATUS_REG_1  0x05
#define WB_READ_DATA          0x03

#define FLASH_CS 20

// TFT pins
#define __CS 10
#define __DC 9
#define __RST 6

#define LED_PIN 5

TFT_ILI9163C display = TFT_ILI9163C(__CS, __DC, __RST);

uint16_t displayRows = 128;
uint16_t numImages = 3;
byte pageBuf[256];

void setup() {
  // configure backlight pin
  pinMode(LED_PIN, OUTPUT); 
  
  // set flash CS pin inactive
  pinMode(FLASH_CS, OUTPUT);
  digitalWrite(FLASH_CS, HIGH);
  
  display.begin();
  display.setBitrate(24000000);
  display.clearScreen();
  
  // delay backlighting to avoid TFT flashing 
  delay(200);
  // set backlight to full brightness
  analogWrite(LED_PIN, 255); 
}

void loop() {
  for (int i = 0; i < numImages; i++) {
    for (int p = 0; p < displayRows; p++) {
      read_page(p + (i * displayRows), pageBuf);
      display.writedatabuffer(p, pageBuf);
    }
    delay(5000);
  }
}

/* Read the WinBond W25Q80BV 1MB SPI flash.
   Code adapted from Instructables article 
    http://www.instructables.com/id/How-to-Design-with-Discrete-SPI-Flash-Memory/
*/

void read_page(word page_number, byte *page_buffer) {
  SPI.beginTransaction(SPISettings(24000000, MSBFIRST, SPI_MODE0));
  digitalWrite(FLASH_CS, HIGH);
  digitalWrite(FLASH_CS, LOW);
  SPI.transfer(WB_READ_DATA);
  // Construct the 24-bit address from the 16-bit page
  // number and 0x00, since we will read 256 bytes (one
  // page).
  SPI.transfer((page_number >> 8) & 0xFF);
  SPI.transfer((page_number >> 0) & 0xFF);
  SPI.transfer(0);
  for (int i = 0; i < 256; ++i) {
    page_buffer[i] = SPI.transfer(0);
  }
  digitalWrite(FLASH_CS, HIGH);
  not_busy();
  SPI.endTransaction();
}

void not_busy(void) {
  digitalWrite(FLASH_CS, HIGH);  
  digitalWrite(FLASH_CS, LOW);
  SPI.transfer(WB_READ_STATUS_REG_1);       
  while (SPI.transfer(0) & 1) {}; 
  digitalWrite(FLASH_CS, HIGH);  
}

BTW To load the flash chip, I'm using code adapted from the Adafruit Trinket Audio Player project.
 
Cool! ;)
If you run the last version of TFT_ILI9163C from github you can delete display.setBitrate(24000000); since it's not used anymore, the SPI now initialize always at 30Mhz. ILI chip it's surprisely capable to run at more than 40Mhz
 
Hello Sumotoy,

I just downloaded your latest driver ILI9163C from github and have found that the clearScreen function no longer works reliably.
 
More info. I tried running your cube example and it fails as well. I'm running my Teensy3.1 at 96 MHz and am using Arduino 1.0.6 and Teensyduino 1.20. Everything worked fine until this new release.
 
Opps, always some problems with GitHub, please load 0.6b1, it's fixed now, thanks for report!
 
vastydeep, I've just updated library, now it's SPI Transaction compatible and has (I hope) the correct init for the new BLACK tag displays.
I don't have any flash chip around, if you want to test it... But read the great SPI transaction page of Paul Stoffregen, maybe you need to some more info or modify a bit the flash chip library.
Added some new example, check bubbles, quite interesting :)

castingflame, try to comment #define __144_RED_PCB__ and enable #define __144_BLACK_PCB__ in the TFT_ILI9163C.h file, I discovered that the actual black tag display laying around ebay has the same pcb of the red one but different display that needs different setting, I've updated the library to support it (for all mcu's, Teensy included).
I've reworked SPI for Teensy using the great work that Paul done recently but still using Adafruit_GFX since for some reason it's more fast, again, check bubbles.ino example to see how fast is.


Thanks for all your efforts sumotoy. You have it licked. Your efforts are very much appreciated.
 
Upgraded library to work with Teensyduino 1.21b on IDE 1.6, now works in both IDE's transparently so it can be used with many MCU's.
 
Nice Work Everyone

This display is great! The least expensive LCD I can find out there. And the code everyone on this thread has provided ... Well thank you to everyone.

I'm playing with the idea of using this to make a small name badge that young people would solder together at Skills Canada summer camps, or Skills Canada competitions to get them hooked on electronics (and to further to allow them to program it as well). Not sure if I can get the price down to something that can be given away by the 100's though.

Here are some screen shots:
20150331_080132[1].jpg20150331_080221[1].jpg

Here's a video of the Mandala code that Craig Lindley uses in his necklace.
 
is there a possibility of getting this library to play nice with the audio board library?
I have updated library to use alternative SPI pin for Teensy 3.1 and added compatibility to Teensy LC (uses native SPI). Teensy LC can use SPI1 as well, also, fixed some small bug.
Should also work with ESP8266.
https://github.com/sumotoy/TFT_ILI9163C
 
Last edited:
UPDATE 14/6/2015

In the meantime there's a preview of the 1.0. It's much faster, works resonable fast with Teensy LC, has initial support for external fonts and has a complete set of graphic primitives.
I have dropped adafruitGFX as well, good idea but never well maintained.
I've also added drawQuad and fillQuad, very useful for 3D rendering (there's an example called solid3D.ino)
https://github.com/sumotoy/TFT_ILI9163C/tree/Pre-Release-1.0r
 
Status
Not open for further replies.
Back
Top