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 /*
peu605 0:f90a4405ef98 2 ILI9163C - A fast SPI driver for TFT that use Ilitek ILI9163C.
peu605 0:f90a4405ef98 3
peu605 0:f90a4405ef98 4 Features:
peu605 0:f90a4405ef98 5 - Very FAST!, expecially with Teensy 3.x where uses DMA SPI.
peu605 0:f90a4405ef98 6 - It uses just 4 or 5 wires.
peu605 0:f90a4405ef98 7 - Compatible at command level with Adafruit display series so it's easy to adapt existing code.
peu605 0:f90a4405ef98 8 - It uses the standard Adafruit_GFX Library (you need to install).
peu605 0:f90a4405ef98 9
peu605 0:f90a4405ef98 10 Background:
peu605 0:f90a4405ef98 11 I got one of those displays from a chinese ebay seller but unfortunatly I cannot get
peu605 0:f90a4405ef98 12 any working library so I decided to hack it. ILI9163C looks pretty similar to other
peu605 0:f90a4405ef98 13 display driver but it uses it's own commands so it's tricky to work with it unlsess you
peu605 0:f90a4405ef98 14 carefully fight with his gigantic and not so clever datasheet.
peu605 0:f90a4405ef98 15 My display it's a 1.44"", 128x128 that suppose to substitute Nokia 5110 LCD and here's the
peu605 0:f90a4405ef98 16 first confusion! Many sellers claim that it's compatible with Nokia 5110 (that use a philips
peu605 0:f90a4405ef98 17 controller) but the only similarity it's the pin names since that this one it's color and
peu605 0:f90a4405ef98 18 have totally different controller that's not compatible.
peu605 0:f90a4405ef98 19 http://www.ebay.com/itm/Replace-Nokia-5110-LCD-1-44-Red-Serial-128X128-SPI-Color-TFT-LCD-Display-Module-/141196897388
peu605 0:f90a4405ef98 20 http://www.elecrow.com/144-128x-128-tft-lcd-with-spi-interface-p-855.html
peu605 0:f90a4405ef98 21 Pay attention that can drive different resolutions and your display can be
peu605 0:f90a4405ef98 22 160*128 or whatever, also there's a strain of this display with a black PCB that a friend of mine
peu605 0:f90a4405ef98 23 got some weeks ago and need some small changes in library to get working.
peu605 0:f90a4405ef98 24 If you look at TFT_ILI9163C.h file you can add your modifications and let me know so I
peu605 0:f90a4405ef98 25 can include for future versions.
peu605 0:f90a4405ef98 26
peu605 0:f90a4405ef98 27 Code Optimizations:
peu605 0:f90a4405ef98 28 The purpose of this library it's SPEED. I have tried to use hardware optimized calls
peu605 0:f90a4405ef98 29 where was possible and results are quite good for most applications, actually nly filled circles
peu605 0:f90a4405ef98 30 are still a bit slow. Many SPI call has been optimized by reduce un-needed triggers to RS and CS
peu605 0:f90a4405ef98 31 lines. Of course it can be improved so feel free to add suggestions.
peu605 0:f90a4405ef98 32 -------------------------------------------------------------------------------
peu605 0:f90a4405ef98 33 Copyright (c) 2014, .S.U.M.O.T.O.Y., coded by Max MC Costa.
peu605 0:f90a4405ef98 34
peu605 0:f90a4405ef98 35 TFT_ILI9163C Library is free software: you can redistribute it and/or modify
peu605 0:f90a4405ef98 36 it under the terms of the GNU General Public License as published by
peu605 0:f90a4405ef98 37 the Free Software Foundation, either version 3 of the License, or
peu605 0:f90a4405ef98 38 (at your option) any later version.
peu605 0:f90a4405ef98 39
peu605 0:f90a4405ef98 40 TFT_ILI9163C Library is distributed in the hope that it will be useful,
peu605 0:f90a4405ef98 41 but WITHOUT ANY WARRANTY; without even the implied warranty of
peu605 0:f90a4405ef98 42 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
peu605 0:f90a4405ef98 43 GNU General Public License for more details.
peu605 0:f90a4405ef98 44
peu605 0:f90a4405ef98 45 You should have received a copy of the GNU General Public License
peu605 0:f90a4405ef98 46 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
peu605 0:f90a4405ef98 47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
peu605 0:f90a4405ef98 48 This file needs the following Libraries:
peu605 0:f90a4405ef98 49
peu605 0:f90a4405ef98 50 Adafruit_GFX by Adafruit:
peu605 0:f90a4405ef98 51 https://github.com/adafruit/Adafruit-GFX-Library
peu605 0:f90a4405ef98 52 Remember to update GFX library often to have more features with this library!
peu605 0:f90a4405ef98 53 From this version I'm using my version of Adafruit_GFX library:
peu605 0:f90a4405ef98 54 https://github.com/sumotoy/Adafruit-GFX-Library
peu605 0:f90a4405ef98 55 It has faster char rendering and some small little optimizations but you can
peu605 0:f90a4405ef98 56 choose one of the two freely since are both fully compatible.
peu605 0:f90a4405ef98 57 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
peu605 0:f90a4405ef98 58 Special Thanks:
peu605 0:f90a4405ef98 59 Thanks Adafruit for his Adafruit_GFX!
peu605 0:f90a4405ef98 60 Thanks to Paul Stoffregen for his beautiful Teensy3 and DMA SPI.
peu605 0:f90a4405ef98 61
peu605 0:f90a4405ef98 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
peu605 0:f90a4405ef98 63 Version:
peu605 0:f90a4405ef98 64 0.1a1: First release, compile correctly. Altrough not fully working!
peu605 0:f90a4405ef98 65 0.1a3: Better but still some addressing problems.
peu605 0:f90a4405ef98 66 0.1b1: Beta! Addressing solved, now rotation works and boundaries ok.
peu605 0:f90a4405ef98 67 0.2b1: Cleaned up.
peu605 0:f90a4405ef98 68 0.2b3: Added 2.2" Red PCB parameters
peu605 0:f90a4405ef98 69 0.2b4: Bug fixes, added colorSpace (for future send image)
peu605 0:f90a4405ef98 70 0.2b5: Cleaning
peu605 10:1ebc27775d92 71 0.3b1: Complete rework on Teensy SPI based on Paul Stoffregen work
peu605 10:1ebc27775d92 72 SPI transaction,added BLACK TAG 2.2 display
peu605 10:1ebc27775d92 73 0.3b2: Minor fix, load 24bit image, Added conversion utility
peu605 10:1ebc27775d92 74 0.4: some improvement, new ballistic gauge example!
peu605 10:1ebc27775d92 75 0.5: Added scroll and more commands, optimizations
peu605 10:1ebc27775d92 76 Fixed a nasty bug in fill screen!
peu605 0:f90a4405ef98 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
peu605 0:f90a4405ef98 78 BugList of the current version:
peu605 0:f90a4405ef98 79
peu605 10:1ebc27775d92 80 Please report any!
peu605 10:1ebc27775d92 81
peu605 10:1ebc27775d92 82
peu605 10:1ebc27775d92 83 Here's the speed test between 0.2b5 and 0.3b1 on Teensy3.1 (major SPI changes)
peu605 10:1ebc27775d92 84 ------------------------------------------------------------------------
peu605 10:1ebc27775d92 85 Lines 17024 16115 BETTER
peu605 10:1ebc27775d92 86 Horiz/Vert Lines 5360 5080 BETTER
peu605 10:1ebc27775d92 87 Rectangles (outline) 4384 4217 BETTER
peu605 10:1ebc27775d92 88 Rectangles (filled) 96315 91265 BETTER
peu605 10:1ebc27775d92 89 Circles (filled) 16053 15829 LITTLE BETTER
peu605 10:1ebc27775d92 90 Circles (outline) 11540 20320 WORST!
peu605 10:1ebc27775d92 91 Triangles (outline) 5359 5143 BETTER
peu605 10:1ebc27775d92 92 Triangles (filled) 19088 18741 BETTER
peu605 10:1ebc27775d92 93 Rounded rects (outline) 8681 12498 LITTLE WORST
peu605 10:1ebc27775d92 94 Rounded rects (filled) 105453 100213 BETTER
peu605 10:1ebc27775d92 95 Done!
peu605 10:1ebc27775d92 96
peu605 10:1ebc27775d92 97
peu605 10:1ebc27775d92 98 */
peu605 10:1ebc27775d92 99
peu605 10:1ebc27775d92 100 /*
peu605 10:1ebc27775d92 101 Probable RED PCB config, bottom aligned? Can this happen???
peu605 10:1ebc27775d92 102
peu605 10:1ebc27775d92 103 128 cols x 160 rows, GM[2:0] = "011"
peu605 10:1ebc27775d92 104
peu605 10:1ebc27775d92 105 ILI9163C LCD panel
peu605 10:1ebc27775d92 106 ---------------------
peu605 10:1ebc27775d92 107 Gate2 N.C.
peu605 10:1ebc27775d92 108 Gate3 N.C.
peu605 10:1ebc27775d92 109 : :
peu605 10:1ebc27775d92 110 Gate33 N.C.
peu605 10:1ebc27775d92 111 Gate34 Gate1
peu605 10:1ebc27775d92 112 Gate35 Gate2
peu605 10:1ebc27775d92 113 : :
peu605 10:1ebc27775d92 114 Gate160 Gate127
peu605 10:1ebc27775d92 115 Gate161 Gate128
peu605 10:1ebc27775d92 116
peu605 0:f90a4405ef98 117 */
peu605 0:f90a4405ef98 118
peu605 0:f90a4405ef98 119 /**
peu605 0:f90a4405ef98 120 * TFT_ILI9163C library for ST Nucleo F411RE
peu605 0:f90a4405ef98 121 *
peu605 0:f90a4405ef98 122 * @author Copyright (c) 2014, .S.U.M.O.T.O.Y., coded by Max MC Costa
peu605 0:f90a4405ef98 123 * https://github.com/sumotoy/TFT_ILI9163C
peu605 0:f90a4405ef98 124 *
peu605 0:f90a4405ef98 125 * @author modified by masuda, Masuda Naika
peu605 0:f90a4405ef98 126 */
peu605 0:f90a4405ef98 127
peu605 0:f90a4405ef98 128 #ifndef _TFT_ILI9163CLIB_H_
peu605 0:f90a4405ef98 129 #define _TFT_ILI9163CLIB_H_
peu605 0:f90a4405ef98 130
peu605 7:3dcb98ecf29f 131 #if defined(TARGET_NUCLEO_F411RE)
peu605 7:3dcb98ecf29f 132 // #define __F411RE_SOFT__
peu605 7:3dcb98ecf29f 133 // #define __F411RE_DMA__
peu605 7:3dcb98ecf29f 134 #define __F411RE_DMA_IT__
peu605 7:3dcb98ecf29f 135 #elif defined(TARGET_NUCLEO_F302R8)
peu605 7:3dcb98ecf29f 136 // #define __F302R8_SOFT__
peu605 7:3dcb98ecf29f 137 #define __F302R8_DMA__
peu605 7:3dcb98ecf29f 138 #else
peu605 7:3dcb98ecf29f 139 #define __MBED_GENERIC__
peu605 1:c271e7e2e330 140 #endif
peu605 0:f90a4405ef98 141
peu605 0:f90a4405ef98 142
peu605 7:3dcb98ecf29f 143 #if defined(__F411RE_SOFT__)
peu605 7:3dcb98ecf29f 144 #include "TFT_ILI9163C_F411RE_SOFT.h"
peu605 7:3dcb98ecf29f 145 #elif defined(__F411RE_DMA__)
peu605 7:3dcb98ecf29f 146 #include "TFT_ILI9163C_F411RE_DMA.h"
peu605 7:3dcb98ecf29f 147 #elif defined(__F411RE_DMA_IT__)
peu605 7:3dcb98ecf29f 148 #include "TFT_ILI9163C_F411RE_DMA_IT.h"
peu605 7:3dcb98ecf29f 149 #elif defined(__F302R8_SOFT__)
peu605 7:3dcb98ecf29f 150 #include "TFT_ILI9163C_F302R8_SOFT.h"
peu605 7:3dcb98ecf29f 151 #elif defined(__F302R8_DMA__)
peu605 7:3dcb98ecf29f 152 #include "TFT_ILI9163C_F302R8_DMA.h"
peu605 0:f90a4405ef98 153 #else
peu605 7:3dcb98ecf29f 154 #include "TFT_ILI9163C_GENERIC.h"
peu605 0:f90a4405ef98 155 #endif
peu605 6:83f3605478ab 156
peu605 0:f90a4405ef98 157 #endif