Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 10 FirstFirst 1 2 3 4 ... LastLast
Results 26 to 50 of 227

Thread: ILI9163C 128x128 TFT driver

  1. #26
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,674
    My first guess is problems with using pin 7 for CS.

    Quote Originally Posted by vastydeep View Post
    #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.

  2. #27
    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?

  3. #28
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,674
    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.

  4. #29
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    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 by sumotoy; 02-25-2015 at 04:31 PM. Reason: wrong url

  5. #30
    Member
    Join Date
    May 2014
    Location
    Black Forest Colorado
    Posts
    74
    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.

  6. #31
    Quote Originally Posted by craiglindley View Post
    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 by castingflame; 02-26-2015 at 02:35 AM.

  7. #32
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    Thanks Paul,
    always nice to see people that enjoy to do something interesting!
    I will wait you here https://github.com/sumotoy/TFT_ILI9163C/issues/1 , already have some feedbacks maybe useful for you but planning to update all to be SPI Transaction capable and more compatible AVR code.

  8. #33
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    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 by sumotoy; 02-27-2015 at 10:57 PM.

  9. #34
    Junior Member
    Join Date
    Feb 2015
    Posts
    3

    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.

    Click image for larger version. 

Name:	Teensy31_TFT_Flash.jpg 
Views:	1291 
Size:	165.2 KB 
ID:	3741

    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.

  10. #35
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    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

  11. #36
    Member
    Join Date
    May 2014
    Location
    Black Forest Colorado
    Posts
    74
    Hello Sumotoy,

    I just downloaded your latest driver ILI9163C from github and have found that the clearScreen function no longer works reliably.

  12. #37
    Member
    Join Date
    May 2014
    Location
    Black Forest Colorado
    Posts
    74
    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.

  13. #38
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    Tested now with Teensy 3.0 and Teensy 3.1, Working perfectly, Did you load 0.6?

  14. #39
    Member
    Join Date
    May 2014
    Location
    Black Forest Colorado
    Posts
    74
    Quote Originally Posted by sumotoy View Post
    Tested now with Teensy 3.0 and Teensy 3.1, Working perfectly, Did you load 0.6?
    Is that necessary? I guess I could give it a shot.

  15. #40
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    Opps, always some problems with GitHub, please load 0.6b1, it's fixed now, thanks for report!

  16. #41
    Member
    Join Date
    May 2014
    Location
    Black Forest Colorado
    Posts
    74
    Quote Originally Posted by sumotoy View Post
    Opps, always some problems with GitHub, please load 0.6b1, it's fixed now, thanks for report!
    Yes all fixed, thanks

  17. #42

    Cool

    Quote Originally Posted by sumotoy View Post
    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.

  18. #43
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    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.

  19. #44
    is there a possibility of getting this library to play nice with the audio board library?

  20. #45
    oops, nevermind, just had to move all the pins around and everything works fine.

  21. #46
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    It was updated recently to be SPI transaction aware, thanks to Paul!

  22. #47
    Junior Member
    Join Date
    Nov 2012
    Posts
    18

    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:
    Click image for larger version. 

Name:	20150331_080132[1].jpg 
Views:	293 
Size:	87.0 KB 
ID:	3990Click image for larger version. 

Name:	20150331_080221[1].jpg 
Views:	374 
Size:	91.7 KB 
ID:	3991

    Here's a video of the Mandala code that Craig Lindley uses in his necklace.

  23. #48
    Member
    Join Date
    May 2014
    Location
    Black Forest Colorado
    Posts
    74
    Phoebus,

    The video is private so I cannot see it.

  24. #49
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    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 by sumotoy; 06-09-2015 at 12:02 PM.

  25. #50
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    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_ILI91...e-Release-1.0r

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •