for Arduino TFT LCD Screen 160x128

Dependents:   TFTLCDSCREEN Pong_ILI9163C

Fork of TFT_ILI9163C by _ peu605

Committer:
billycorgan123
Date:
Fri Mar 04 08:55:32 2016 +0000
Revision:
12:f0799be044ff
Parent:
10:1ebc27775d92
first trial with Arduino TFT LCD Screen, ILI9163

Who changed what in which revision?

UserRevisionLine numberNew contents of line
peu605 0:f90a4405ef98 1 TFT_ILI9163C
peu605 0:f90a4405ef98 2
peu605 0:f90a4405ef98 3 ILI9163C- A fast SPI driver for TFT that use Ilitek ILI9163C.
peu605 0:f90a4405ef98 4
peu605 0:f90a4405ef98 5 ![ILI9163C](http://i1189.photobucket.com/albums/z437/theamra/github/CIMG6810.jpg)
peu605 0:f90a4405ef98 6
peu605 0:f90a4405ef98 7 Link to a video:
peu605 0:f90a4405ef98 8
peu605 0:f90a4405ef98 9 https://www.youtube.com/watch?v=y5f-VNBxgEk&feature=youtu.be
peu605 0:f90a4405ef98 10
peu605 0:f90a4405ef98 11 ==========================
peu605 0:f90a4405ef98 12
peu605 10:1ebc27775d92 13 <b>Features:</b>
peu605 0:f90a4405ef98 14
peu605 10:1ebc27775d92 15 - Very FAST!, expecially with Teensy 3.x where uses hyper fast SPI.
peu605 0:f90a4405ef98 16 - It uses just 4 or 5 wires.
peu605 0:f90a4405ef98 17 - Compatible at command level with Adafruit display series so it's easy to adapt existing code.
peu605 0:f90a4405ef98 18 - It uses the standard Adafruit_GFX Library (you need to install).
peu605 10:1ebc27775d92 19 - SPI transaction compatible (only where supported, actually only Teensy3 but soon more)
peu605 10:1ebc27775d92 20 - Working with IDE 1.0.6, 1.5.8 (or newer), Energia (soon)
peu605 10:1ebc27775d92 21 - Working with Arduino's (8 and 32 bit), Teensy 3, Teensy 3.1 and Teensy LC
peu605 10:1ebc27775d92 22 - Working with Energia supported MCU (not yet but really soon)
peu605 10:1ebc27775d92 23 - A Fast SPI DMA for Nucleo F411RE porting from MasudaNaika https://github.com/MasudaNaika
peu605 10:1ebc27775d92 24 here: http://developer.mbed.org/users/peu605/code/TFT_ILI9163C/
peu605 0:f90a4405ef98 25
peu605 10:1ebc27775d92 26 <b>Pay Attention to connections!!!!:</b>
peu605 0:f90a4405ef98 27
peu605 0:f90a4405ef98 28 - This display has logic at 3V3 volt so YOU NEED A VOLTAGE CONVERTER if you plan to use with arduino.
peu605 0:f90a4405ef98 29 If you try to connect directly you can burn it very fast so PAY ATTENTION!
peu605 10:1ebc27775d92 30 - My display works at 3V3 volt and uses 3V3 for logic but LED background has resistor for 5V.
peu605 10:1ebc27775d92 31 Your can be different so carefully check out before connect it.
peu605 10:1ebc27775d92 32 - Library works only in SPI mode by using MOSI,SCLK and a CS pin plus an additional pin for DC (or RS).
peu605 0:f90a4405ef98 33 I've used also the reset pin but you can save it by connect it at 3V3 volt and use the constructor without
peu605 0:f90a4405ef98 34 the reset pin. The initialization routine will automatically use the software reset.
peu605 0:f90a4405ef98 35
peu605 10:1ebc27775d92 36 - People using Teensy3 should remember that have to choose for CS and DC a pin that should be:
peu605 10:1ebc27775d92 37 pins:2,6,9 or 10,15 or 20,13 for CS and DC, any for RST (but you can connect RST to +3v3 and forget it.
peu605 0:f90a4405ef98 38
peu605 10:1ebc27775d92 39 <b>Backgrounds:</b>
peu605 0:f90a4405ef98 40
peu605 0:f90a4405ef98 41 I got one of those displays from a chinese ebay seller but unfortunatly I cannot get
peu605 0:f90a4405ef98 42 any working library so I decided to hack it. ILI9163C looks pretty similar to other
peu605 0:f90a4405ef98 43 display driver but it uses it's own commands so it's tricky to work with it unlsess you
peu605 0:f90a4405ef98 44 carefully fight with his gigantic and not so clever datasheet.
peu605 0:f90a4405ef98 45 My display it's a 1.44"", 128x128 that suppose to substitute Nokia 5110 LCD and here's the
peu605 0:f90a4405ef98 46 first confusion! Many sellers claim that it's compatible with Nokia 5110 (that use a philips
peu605 0:f90a4405ef98 47 controller) but the only similarity it's the pin names since that this one it's color and
peu605 0:f90a4405ef98 48 have totally different controller that's not compatible. Altrough I discovered that it's not
peu605 0:f90a4405ef98 49 128x128 but 128x160 (!??)... Check links below to see if it's similar to yours.
peu605 0:f90a4405ef98 50
peu605 0:f90a4405ef98 51 http://www.ebay.com/itm/Replace-Nokia-5110-LCD-1-44-Red-Serial-128X128-SPI-Color-TFT-LCD-Display-Module-/141196897388
peu605 0:f90a4405ef98 52
peu605 0:f90a4405ef98 53 http://www.elecrow.com/144-128x-128-tft-lcd-with-spi-interface-p-855.html
peu605 0:f90a4405ef98 54
peu605 10:1ebc27775d92 55 This TFT it's really cheap but has surprising features since it support very high speed SPI trasfer
peu605 10:1ebc27775d92 56 (over 40Mhz tested!) and can be used as frame buffer, colors are quite tunable and has a tons of settings.
peu605 10:1ebc27775d92 57 It also support repetitive serial transfer so it can react very fast.
peu605 10:1ebc27775d92 58
peu605 10:1ebc27775d92 59 <b>BLACK, RED or ...</b>
peu605 0:f90a4405ef98 60
peu605 10:1ebc27775d92 61 There's different strain of this display on ebay, I have try to tracking all of them but may missing some species! Actually the more popular has a RED pcb and a BLACK pcb that are completely same pcb but mount a different display that need some tweaking, in particular RED ones need offset but also some tweak for colors, etc. In the .h file in the library try to comment out one of the presets:
peu605 10:1ebc27775d92 62 //#define __144_RED_PCB__
peu605 10:1ebc27775d92 63 #define __144_BLACK_PCB__
peu605 10:1ebc27775d92 64 //#define __22_RED_PCB__
peu605 10:1ebc27775d92 65 I have a discussion here where a couple of users claim that the _GRAMHEIGH propriety should be always 128.
peu605 10:1ebc27775d92 66 This is true ONLY if you will never use scroll! Scroll use the entire memory mapped to screen, my RED tag one
peu605 10:1ebc27775d92 67 it's 128x128 but it uses 128x160! If during scroll you have some garbage means that you have not correctly
peu605 10:1ebc27775d92 68 setup the display property:
peu605 10:1ebc27775d92 69
peu605 10:1ebc27775d92 70 #define _TFTWIDTH 128//the REAL W resolution of the TFT
peu605 10:1ebc27775d92 71 #define _TFTHEIGHT 128//the REAL H resolution of the TFT
peu605 10:1ebc27775d92 72 #define _GRAMWIDTH 128
peu605 10:1ebc27775d92 73 #define _GRAMHEIGH 160//Heh? Yes! My display uses offset!
peu605 10:1ebc27775d92 74 #define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH //
peu605 10:1ebc27775d92 75 #define __COLORSPC 1// 1:GBR - 0:RGB
peu605 10:1ebc27775d92 76 #define __GAMMASET3 //uncomment for another gamma (1,2,3)
peu605 10:1ebc27775d92 77 #define __OFFSET 32//this is the offset of my display, 160 - 128 = 32
peu605 10:1ebc27775d92 78
peu605 10:1ebc27775d92 79 You can write your own one by adding it in the .h file but let me know so I can add for other users.
peu605 10:1ebc27775d92 80
peu605 10:1ebc27775d92 81 <b>Code Optimizations:</b>
peu605 0:f90a4405ef98 82
peu605 0:f90a4405ef98 83 The purpose of this library it's SPEED. I have tried to use hardware optimized calls
peu605 0:f90a4405ef98 84 where was possible and results are quite good for most applications.
peu605 0:f90a4405ef98 85 Of course it can be improved so feel free to add suggestions.
peu605 0:f90a4405ef98 86
peu605 10:1ebc27775d92 87 <b>Needed stuff you have to install first!!!</b>
peu605 0:f90a4405ef98 88
peu605 10:1ebc27775d92 89 This library use Adafruit GFX library as all my TFT,OLED and LCD libraries:
peu605 10:1ebc27775d92 90 (Remember to update GFX library often to have more features with this and other library!)
peu605 10:1ebc27775d92 91
peu605 0:f90a4405ef98 92
peu605 0:f90a4405ef98 93 https://github.com/adafruit/Adafruit-GFX-Library
peu605 10:1ebc27775d92 94
peu605 10:1ebc27775d92 95 Since Adafruit are quite reluctant to update often I have a 100% compatible one that it's faster and has
peu605 10:1ebc27775d92 96 more features, faster char rendering, ability to use different fonts etc.
peu605 0:f90a4405ef98 97
peu605 0:f90a4405ef98 98 https://github.com/sumotoy/Adafruit-GFX-Library
peu605 0:f90a4405ef98 99
peu605 10:1ebc27775d92 100 It's 100% compatible with the Adafruit one so don't worry about.
peu605 10:1ebc27775d92 101
peu605 10:1ebc27775d92 102 <b>Wiring:</b>
peu605 0:f90a4405ef98 103
peu605 10:1ebc27775d92 104 You are a newbie and need help? Here's:
peu605 10:1ebc27775d92 105 This display has 8 pin (at the time I'm writing this):
peu605 10:1ebc27775d92 106
peu605 10:1ebc27775d92 107 TFT side -------------------- microprocessor
peu605 10:1ebc27775d92 108 - Vcc --> +3V3V(!!!!)
peu605 10:1ebc27775d92 109 - Gnd --> Gnd
peu605 10:1ebc27775d92 110 - CS --> CS pin (3v3 level!)
peu605 10:1ebc27775d92 111 - RST --> connect to a MCU pin or tie to +3V3
peu605 10:1ebc27775d92 112 - A0 --> DC or RS pin (3v3 level!)
peu605 10:1ebc27775d92 113 - SDA --> Mosi (3v3 level!)
peu605 10:1ebc27775d92 114 - SCK --> Sclk (3v3 level!)
peu605 10:1ebc27775d92 115 - LED --> Some display need a resistor (see note below)
peu605 10:1ebc27775d92 116
peu605 10:1ebc27775d92 117 * Note about led:
peu605 10:1ebc27775d92 118
peu605 10:1ebc27775d92 119 Some display have an internal resistor to limit current, you see on the back of the display, following LED pcb
peu605 10:1ebc27775d92 120 trace with your eyes and if you see a resistor (100 Ohm mine) you can connect this line directly to +5V.
peu605 10:1ebc27775d92 121 But be careful <u>do not try connect to 5V before you check the presence of this resistor on pcb</u>, you can try first by using a resistor of 220 ohm, if the image looks very dark, try 100 and if still very dark, tie directly to 5v.
peu605 10:1ebc27775d92 122
peu605 10:1ebc27775d92 123 <b>Utility included:</b>
peu605 10:1ebc27775d92 124
peu605 10:1ebc27775d92 125 Included you will find LCD Image Converter a free utility to convert in code a 24bit image.
peu605 10:1ebc27775d92 126
peu605 10:1ebc27775d92 127 https://code.google.com/p/lcd-image-converter/
peu605 10:1ebc27775d92 128
peu605 10:1ebc27775d92 129 see example bigPicture.ino.
peu605 10:1ebc27775d92 130 I have included datasheet as well.
peu605 10:1ebc27775d92 131 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
peu605 10:1ebc27775d92 132
peu605 10:1ebc27775d92 133 <b>Special Thanks:</b>
peu605 0:f90a4405ef98 134
peu605 0:f90a4405ef98 135 Thanks Adafruit for his Adafruit_GFX!
peu605 10:1ebc27775d92 136 Thanks to Paul Stoffregen for his beautiful Teensy3 and high speed SPI magic.
peu605 0:f90a4405ef98 137
peu605 10:1ebc27775d92 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
peu605 0:f90a4405ef98 139
peu605 10:1ebc27775d92 140 <b>Version:</b>
peu605 0:f90a4405ef98 141
peu605 0:f90a4405ef98 142 0.1a1: First release, compile correctly. Altrough not fully working!
peu605 0:f90a4405ef98 143 0.1a3: Some bugfix, still some addressing problems, partial rotation solved.
peu605 0:f90a4405ef98 144 0.1b1: Beta version! Fully working but still not tested with Arduino and DUE (altrough it compile)
peu605 0:f90a4405ef98 145 0.2b2: Code cleaned and added support for 2.2" RED PCB displays.
peu605 0:f90a4405ef98 146 0.2b4: Bug fixes and added color space support.
peu605 10:1ebc27775d92 147 0.3b1: Complete rework on Teensy SPI based on Paul Stoffregen work
peu605 10:1ebc27775d92 148 SPI transaction,added BLACK TAG 2.2 display
peu605 10:1ebc27775d92 149 0.3b2: Added 24bit image display code and example.
peu605 10:1ebc27775d92 150 0.5: A lot of changes, preliminary scroll, added sleep and some other command but
peu605 10:1ebc27775d92 151 most important fixed a nasty bug on fillScreen. If you have download any previous
peu605 10:1ebc27775d92 152 version you should upgrade since there was several fixes.
peu605 10:1ebc27775d92 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
peu605 0:f90a4405ef98 154
peu605 10:1ebc27775d92 155 <b> Legal Notes:</b>
peu605 0:f90a4405ef98 156
peu605 10:1ebc27775d92 157 This library it's free to use but if you port for other MCU or include in distribution or whatever you have
peu605 10:1ebc27775d92 158 to leave intact the readme inside the library, add your text about modifications but leave intact the text
peu605 10:1ebc27775d92 159 in the .h file.
peu605 10:1ebc27775d92 160 If you included in distributions please leave me a note.
peu605 10:1ebc27775d92 161 If you porting for other MCU or IDE, leave me a note, I will included in the readme here the link.
peu605 10:1ebc27775d92 162
peu605 10:1ebc27775d92 163 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
peu605 0:f90a4405ef98 164
peu605 10:1ebc27775d92 165 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
peu605 10:1ebc27775d92 166
peu605 10:1ebc27775d92 167 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.