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

Thread: ILI9163C 128x128 TFT driver

  1. #1
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421

    ILI9163C 128x128 & ILI9340 240x320TFT driver

    Click image for larger version. 

Name:	CIMG6810.jpg 
Views:	2181 
Size:	134.5 KB 
ID:	2043

    Here's a working driver for ILI9163C 1.44" 128x128 (but can works with other resolution's TFT) SPI TFT, prolly the most cheap display available. I got several on ebay for about less than 4 Euro (free expedition) but I've seen even cheaper.
    Just search in ebay for "1.44" Red Serial 128X128 SPI Color TFT". This display use the ILI9163C chip that has no know library for Arduino and Teensy and this probably the reason why it's so cheap. Thanks to Paul's fast SPI routines I build up this library that drive really fast this display and it's fully compatible with Adafruit ones (I'm using Adafruit_GFX) so it can be easily used in different projects without learn from scratch commands.
    The maker of those display's (a chinese for sure) forgot to set the hardware addressing for fix the memory map to a certain resolution (in this case 128 x 128) and leaved at 128 * 160 so this display showed big pixel addressing problems that fortunatly I fixed after a couple of days over the damn clumsy datasheet.
    Here's a video that shows it with a Teensy3.1 at 24Mhz/SPI


    Can be really good for experimenting without spend a lot of money for prototypes, also I like the square resolution, useful for gauges. Remember that it's extremely cheap display!
    Hope it's useful.

    Edit 1/6/2014:
    Added ILI9340 and ILI9340C library that uses Paul's Native SPI (tipically 2.2" 240*320 display's from Adafruit and on Ebay, RED pcb ones).
    On GitHub:
    https://github.com/sumotoy/TFT_ILI9340/

    On Github:
    https://github.com/sumotoy/TFT_ILI9163C

    Last edited by sumotoy; 06-01-2014 at 11:24 PM. Reason: forget library address!

  2. #2
    Member
    Join Date
    Jun 2013
    Location
    Southern Colorado
    Posts
    66
    Where is the driver ?

  3. #3
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    Oooops!!! Fixed!

  4. #4
    Member
    Join Date
    Jun 2013
    Location
    Southern Colorado
    Posts
    66
    Thank you sumotoy for all of your hard work. I have a couple displays on order
    .......anxious to try out your lib.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,682
    Where did you buy this display?

  6. #6
    Member
    Join Date
    Jun 2013
    Location
    Southern Colorado
    Posts
    66
    Hi Paul, bought it from an ebay seller.

    http://www.ebay.com/itm/271422122271...84.m1439.l2649

  7. #7
    Member
    Join Date
    Jun 2013
    Location
    Southern Colorado
    Posts
    66
    Hi again sumotoy, received my displays today but I have not had any luck getting one to work Using a Teensy 3.1 with
    teensyduino 1.19 rc2. The pinout on the display is: LED, SCK, SDA, A0, RESET, CS, GND, and VCC. I am powering it with
    3.3 vdc and using pwm for the LED backlight. Can you suggest a hook up for the Teensy 3.1 using your libs ?? The text
    on the back of the pcb is: 1.44' SPI 128*128 V1.1.

    EDIT: Never mind sumotoy, I figured it out. I think you were probably assuming that no 'SPI idiots' like me would
    be trying to use your libs. It's working fine now. Teensy 3.1 pins to LCD: using the t3.1's 3.3 vdc out to power
    the display, analogWrite(3,150) to LED, pin 13 to SCK, pin 11 to SDA, pin 9 to A0, pin 15 to RESET, pin 10 to
    CS. It sure is a nice display for the price. Thanks again for the libs.
    Last edited by pxgator; 06-03-2014 at 03:46 AM. Reason: figured it out

  8. #8
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    Cool!
    There's also the library for ILI9340C (link on top), this time 240x320, around 6 buks on Ebay.

  9. #9
    Member
    Join Date
    Jun 2013
    Location
    Southern Colorado
    Posts
    66
    Your lib seems to work pretty well, but with my setup (described above), display.clearScreen() causes a bit of flicker.
    Is there any way to stop the flicker ??

  10. #10
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    This can be because the data is sent so fast that display react it's slower than data processed by controller. I got the same problem with the 3d cube example that require a complete screen refresh every frame, it flickers at the bottom.
    Sending data much slow will give better results but certenly it's not acceptable solution.
    I found that tuning some of the initialization values give better (or worst) results so I will investigate this weekend.

  11. #11
    Junior Member
    Join Date
    Aug 2014
    Posts
    3
    Hello,
    I have also bought one of these screens but am having difficulty getting it to work.
    I'll try to be as clear as I can. It's the same screen, on the back is printed "1.44' SPI 128*128 V1.1", the board itself is black.

    sumotoy you mentioned on your github that one of your friends also had the black version but needed to change something,
    what did they do to get it working?

    As it sits right now, I've got the ILI9163C and Adafruit_GFX libraries and have the screen connected to an arduino uno through a level converter as follows
    Code:
    Printed		What I		Arduino
    Name		Think it is	Connection
    
    LED		(BACKLIGHT)	3.3v
    SCK		(SCLK)		pin 13
    SDA		(MOSI)		pin 11
    A0		(DC)		pin 9
    RESET		(RESET)		pin 8
    CS		(CS)		3.3v
    GND		(GND)		GND
    VCC		(VCC)		3.3v
    When I load the test program it doesn't appear to do anything, the screen is white but just looks the same as when the backlight is on.

    I'm really stuck at this point and would really appreciate any help anyone can give.

    Thanks in advance

  12. #12
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    can you give me the link where you buy it? Have to check if I can find any info about it, maybe different chipset?

    Edit:
    You have connected CS to 3V3? It will never work like that!
    CS it's a part of the SPI, tied to + will block any SPI communication with the display

    You should connect:

    SCK -> 13 (cannot change this)
    SDA -> 11 (cannot change this)
    A0(DC) -> 9 (you can change but not all pins are usable, see library)
    CS -> 10 (you can change but not all pins are usable, see library)
    RESET -> 8 (any pin, you can also avoid, check library .h)


    TFT_ILI9163C(uint8_t cspin,uint8_t dcpin,uint8_t rstpin);

    will be:

    TFT_ILI9163C tft = TFT_ILI9163C(10, 9, 8);

    Try like this!

    Sorry for delay, I'm in vacation in an island in Greece and internet not always available, also a lot of power loss, last day 12 hour of blackout.
    Last edited by sumotoy; 08-29-2014 at 08:06 PM.

  13. #13
    Junior Member
    Join Date
    Aug 2014
    Posts
    3
    Hi sumotoy,

    Thanks for your reply.
    Yes bit of a dumb moment on my part, it's been a while since I did anything with spi and I forgot that CS is active low, d'oh!

    Anyway unfortunately that didn't solve my issue, however I found that if I run the logic at 5v the display works, but im a little hesitant to run it like this,
    can you confirm if this is ok for this chip? I looked through the data sheet and I couldn't find any part that said the chip was 5v tolerant.

    Here is the link to the screen, I believe that is is the same as the one you mentioned your friend having because this also has slightly different memory addressing.
    http://www.ebay.co.uk/itm/New-1-44-Serial...

    Thanks and enjoy your holiday!

  14. #14
    Junior Member
    Join Date
    Feb 2015
    Posts
    3

    Tft 128 x 128

    Hi,

    I tried the driver above and the examples and can't for the life of me get it to work ! I think I'm having a similar problem that Hallam had. I had tried attaching an image of the setup:
    Click image for larger version. 

Name:	TFT ARDUINO.jpg 
Views:	16994 
Size:	64.2 KB 
ID:	3447

    Basically it is:
    VCC = 3.3V
    GND = 0V
    LED = 3.3V
    RESET = Arduino Pin 8
    CS = Arduino Pin 10
    A0 = Arduino Pin 9
    SDA = Arduino Pin 11
    SCK = Arduino Pin 13

    Any help would be appreciated as all I seem to get is the Back light

  15. #15
    SumoToy sounds like a really cool display.

    Were you able to write any bitmaps to it? I would be cool to learn how fast that chip can write a bitmap.

    Also if you want to run your Teensy at 96mhz just add a delay to the Shiftout function. Here is my example for a Digole display.
    //Rewrite the Shiftout function for the Teensy 3.1 clock speed
    //Teensy MHz || delayMicroseconds
    // 24 || 5
    // 48 || 10
    // 72 || 20
    // 96 || 25
    void shiftOut2(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val){
    uint8_t i;

    for (i = 0; i < 8; i++) {
    if (bitOrder == LSBFIRST)
    digitalWrite(dataPin, !!(val & (1 << i)));
    else
    digitalWrite(dataPin, !!(val & (1 << (7 - i))));

    digitalWrite(clockPin, HIGH);
    digitalWrite(clockPin, LOW);
    delayMicroseconds(25);//delay goes here
    }

  16. #16
    Junior Member
    Join Date
    Aug 2014
    Posts
    3
    Linkpad,

    In your schematic you've got your backlight linked to ground.
    But if you've wired it up as you have written it, then that is the same as the way I did it.
    Have you changed the pins in the example code? As I remember it the reset pin is set as 14 in the code, so you must change it to 8.

    If you post your code i'll have a look.

  17. #17
    Junior Member
    Join Date
    Feb 2015
    Posts
    3
    Quote Originally Posted by hallam View Post
    Linkpad,

    In your schematic you've got your backlight linked to ground.
    But if you've wired it up as you have written it, then that is the same as the way I did it.
    Have you changed the pins in the example code? As I remember it the reset pin is set as 14 in the code, so you must change it to 8.

    If you post your code i'll have a look.
    Thanks Hallam I did notice that too in the code I will try changing it, as there is no pin 14 on a Uno.

  18. #18
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,309
    On the Uno, pin14 is A0, just like it is on the Teensy 3.1.

    On other chips (Leonardo, Mega, etc.), pin14 may not map into A0

  19. #19
    Junior Member
    Join Date
    Feb 2015
    Posts
    3
    Now i'm confused, i'm struggling to understand how pin A0 = 14 on the arduino ? Now my arduino software won't load anymore and crashes.

  20. #20
    Junior Member
    Join Date
    Feb 2015
    Posts
    1
    Quote Originally Posted by sumotoy View Post
    Click image for larger version. 

Name:	CIMG6810.jpg 
Views:	2181 
Size:	134.5 KB 
ID:	2043

    Here's a working driver for ILI9163C 1.44" 128x128 (but can works with other resolution's TFT) SPI TFT, prolly the most cheap display available. I got several on ebay for about less than 4 Euro (free expedition) but I've seen even cheaper.
    Just search in ebay for "1.44" Red Serial 128X128 SPI Color TFT". This display use the ILI9163C chip that has no know library for Arduino and Teensy and this probably the reason why it's so cheap. Thanks to Paul's fast SPI routines I build up this library that drive really fast this display and it's fully compatible with Adafruit ones (I'm using Adafruit_GFX) so it can be easily used in different projects without learn from scratch commands.
    The maker of those display's (a chinese for sure) forgot to set the hardware addressing for fix the memory map to a certain resolution (in this case 128 x 128) and leaved at 128 * 160 so this display showed big pixel addressing problems that fortunatly I fixed after a couple of days over the damn clumsy datasheet.
    Here's a video that shows it with a Teensy3.1 at 24Mhz/SPI


    Can be really good for experimenting without spend a lot of money for prototypes, also I like the square resolution, useful for gauges. Remember that it's extremely cheap display!
    Hope it's useful.

    Edit 1/6/2014:
    Added ILI9340 and ILI9340C library that uses Paul's Native SPI (tipically 2.2" 240*320 display's from Adafruit and on Ebay, RED pcb ones).
    On GitHub:
    https://github.com/sumotoy/TFT_ILI9340/

    On Github:
    https://github.com/sumotoy/TFT_ILI9163C

    Hi there , thank you for providing this amazing library , is there anyway to convert it for use on stm33f4 or any other arm cortex-m3/m4 MCU ??

  21. #21
    Junior Member
    Join Date
    Feb 2015
    Posts
    3
    I'm using this library to display images from an SPI flash chip and it is working well with an Arduino Mini. Now I want to move to a Teensy 3.1, but the Teensy SPI code is quite different and I can't seem to figure out how to use an additional SPI device. The display works on the Teensy, and with a separate upload I can read from the flash chip, but I don't know how to put them together. Can anyone give me any hints?

  22. #22
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    Good question, even the tons of libraries for Flash chips for Arduino are not reliable at all, for example, I have several 512/1024 chip from Microchip and still now I cannot get working on my UNO. Some chip uses paged memory handle, some use direct addressing, so basically every chip needs it's own library. Are you using this library with Arduino Mini and witch SPI flash chip?

  23. #23
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,682
    Quote Originally Posted by vastydeep View Post
    I'm using this library to display images from an SPI flash chip and it is working well with an Arduino Mini. Now I want to move to a Teensy 3.1, but the Teensy SPI code is quite different and I can't seem to figure out how to use an additional SPI device.
    If you post the actual (complete) code, I'll take a look....

    I really can't offer any useful advise based only on this question, without the code or even the chip's part number.

  24. #24
    Junior Member
    Join Date
    Feb 2015
    Posts
    3
    Quote Originally Posted by sumotoy View Post
    Good question, even the tons of libraries for Flash chips for Arduino are not reliable at all, for example, I have several 512/1024 chip from Microchip and still now I cannot get working on my UNO. Some chip uses paged memory handle, some use direct addressing, so basically every chip needs it's own library. Are you using this library with Arduino Mini and witch SPI flash chip?
    I am using this TFT library with the Mini and the flash chip is a WinBond W25Q80BV 1MB flash. I got the code for accessing the flash chip from this article http://www.instructables.com/id/How-...-Flash-Memory/. Here's the code that works on the Mini:

    Code:
    #include <SPI.h>
    #include <Adafruit_GFX.h>
    #include <TFT_ILI9163C.h>
    #include <Serial.h>
    
    // WinBond flash commands
    #define WB_READ_STATUS_REG_1  0x05
    #define WB_READ_DATA          0x03
    
    #define __CS 7
    #define __DC 9
    #define __RST 8
    
    TFT_ILI9163C display = TFT_ILI9163C(__CS, __DC, __RST);
    
    uint16_t displayRows = 128;
    uint16_t numImages = 3;
    byte pageBuf[256];
    
    void setup() {
      display.begin();
      display.setBitrate(24000000);
      display.clearScreen();
      pinMode(3, OUTPUT);  // backlight control
      analogWrite(3, 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) {
      digitalWrite(SS, HIGH);
      digitalWrite(SS, 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(SS, HIGH);
      not_busy();
    }
    
    void not_busy(void) {
      digitalWrite(SS, HIGH);  
      digitalWrite(SS, LOW);
      SPI.transfer(WB_READ_STATUS_REG_1);       
      while (SPI.transfer(0) & 1) {}; 
      digitalWrite(SS, HIGH);  
    }
    display.writedatabuffer() is just a function I added the TFT library to speed up writing each row:
    Code:
    void TFT_ILI9163C::writedatabuffer(uint16_t y, uint8_t *buf){ 
        setAddrWindow(0,y,_width-1,y);
    	*rsport |=  rspinmask;
    	*csport &= ~cspinmask;
        // assume 256 byte buffer
        for (int b = 0; b < 256; b++) {
            spiwrite(buf[b]);
        }
    	*csport |= cspinmask;
    }
    This is working well on the Mini as the attached image shows.

    Click image for larger version. 

Name:	ILI9163C_W25Q80BV_Mini.jpg 
Views:	1220 
Size:	74.7 KB 
ID:	3659

    But I can't use the same code to access the flash chip when using the Teensy 3.1 - it looks like this TFT library uses advanced SPI features and the code is very different. What I want to know is how to write the equivalent code for the flash chip on the Teensy.

    Hope this is clear enough.

  25. #25
    I have posted ths on the Aurdrino forum but it may well be better suited to here as it is really a question about the sumotoy code. If your unhappy please just remove it. Thanks, Paul


    Hi all.

    I have been playing with a 1.44" 128x128 TFT ILI9163 (Black PCB) display for a week. I have it working under a couple of different graphics libraries and drivers but I have a strange issue with one of them.

    Hardware: 1.44 128x128 TFT ILI9163 display screen *ebay link
    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




    Setup 1

    Driver & Graphics Library: Libraries, Driver & Scratch

    This is built on work done by Paul Kourany and his Multi Font GFX Library (mfGFX Library) on github Here *which in turn is a fork of the Adafruit GFX library.


    The result . . .

    Click image for larger version. 

Name:	Result_1.jpg 
Views:	4982 
Size:	157.9 KB 
ID:	3661



    All good!



    Setup 2


    Driver: TFT_ILI9163C Driver Library by Sumotoy
    Graphics Library: Adafruit-GFX-Library

    This is the thread by Sumotoy that explains it all Sumotoy ILI9163C driver

    The result . . . . .

    Click image for larger version. 

Name:	Result2_1.jpg 
Views:	330 
Size:	166.6 KB 
ID:	3662
    Reset


    Click image for larger version. 

Name:	Result2_2.jpg 
Views:	720 
Size:	148.1 KB 
ID:	3663
    errrr sort of reset


    Click image for larger version. 

Name:	Result2_3.jpg 
Views:	762 
Size:	174.1 KB 
ID:	3664
    the top part of the screen has not been cleared from the previous project code


    Click image for larger version. 

Name:	Result2_4.jpg 
Views:	525 
Size:	82.2 KB 
ID:	3665
    still the same

    Click image for larger version. 

Name:	Result2_5.jpg 
Views:	381 
Size:	78.0 KB 
ID:	3666
    now its clear. As this write to the screen starts from the bottom, it looks like the top got erased for that reason.


    Click image for larger version. 

Name:	Result2_6.jpg 
Views:	531 
Size:	69.8 KB 
ID:	3667
    this time the top area is written to with new display data. Again the write to the screen starts from the bottom.


    Click image for larger version. 

Name:	Result2_7.jpg 
Views:	430 
Size:	77.8 KB 
ID:	3668
    the top area of the screen is still showing the previous write. This time the write is from the top of the screen.



    So it looks like my 'Setup 2' is not referencing the top screen co-ordinates correctly.

    In Sumotoys first comment about this display he says . . 'The maker of those display's (a chinese for sure) forgot to set the hardware addressing for fix the memory map to a certain resolution (in this case 128 x 128) and leaved at 128 * 160 so this display showed big pixel addressing problems that fortunatly I fixed after a couple of days over the damn clumsy datasheet'

    If this is relevent or not I do not know as he says he has sorted it. I have also checked that the library is setup for the black display and not the red one.


    I have only been playing with Audrino for a couple of weeks so it may be that I have just missunderstood something but all and any help with this problem would be very much appreciated.

    Regards, Paul
    Last edited by castingflame; 02-25-2015 at 12:08 PM.

Posting Permissions

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