Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TFTLCDSCREEN Pong_ILI9163C
Fork of TFT_ILI9163C by
TFT_ILI9163C.cpp@1:c271e7e2e330, 2015-01-22 (annotated)
- Committer:
- peu605
- Date:
- Thu Jan 22 12:16:31 2015 +0000
- Revision:
- 1:c271e7e2e330
- Parent:
- 0:f90a4405ef98
- Child:
- 2:6c1fadae252f
enabled to use mbed general SPI
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
peu605 | 0:f90a4405ef98 | 1 | #include "TFT_ILI9163C.h" |
peu605 | 0:f90a4405ef98 | 2 | #include "mbed.h" |
peu605 | 0:f90a4405ef98 | 3 | |
peu605 | 0:f90a4405ef98 | 4 | /** |
peu605 | 0:f90a4405ef98 | 5 | * TFT_ILI9163C library for ST Nucleo F411RE |
peu605 | 0:f90a4405ef98 | 6 | * |
peu605 | 0:f90a4405ef98 | 7 | * @author Copyright (c) 2014, .S.U.M.O.T.O.Y., coded by Max MC Costa |
peu605 | 0:f90a4405ef98 | 8 | * https://github.com/sumotoy/TFT_ILI9163C |
peu605 | 0:f90a4405ef98 | 9 | * |
peu605 | 0:f90a4405ef98 | 10 | * @author modified by masuda, Masuda Naika |
peu605 | 0:f90a4405ef98 | 11 | */ |
peu605 | 0:f90a4405ef98 | 12 | |
peu605 | 0:f90a4405ef98 | 13 | //constructors |
peu605 | 0:f90a4405ef98 | 14 | TFT_ILI9163C::TFT_ILI9163C(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName dc, PinName reset) |
peu605 | 0:f90a4405ef98 | 15 | : Adafruit_GFX(_TFTWIDTH,_TFTHEIGHT) , SPI(mosi,miso,sclk,NC), _cs(cs), _dc(dc) { |
peu605 | 0:f90a4405ef98 | 16 | |
peu605 | 0:f90a4405ef98 | 17 | _resetPinName = reset; |
peu605 | 0:f90a4405ef98 | 18 | } |
peu605 | 0:f90a4405ef98 | 19 | |
peu605 | 0:f90a4405ef98 | 20 | TFT_ILI9163C::TFT_ILI9163C(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName dc) |
peu605 | 0:f90a4405ef98 | 21 | : Adafruit_GFX(_TFTWIDTH,_TFTHEIGHT) , SPI(mosi,miso,sclk,NC), _cs(cs), _dc(dc) { |
peu605 | 0:f90a4405ef98 | 22 | |
peu605 | 0:f90a4405ef98 | 23 | _resetPinName = NC; |
peu605 | 0:f90a4405ef98 | 24 | } |
peu605 | 0:f90a4405ef98 | 25 | |
peu605 | 0:f90a4405ef98 | 26 | |
peu605 | 0:f90a4405ef98 | 27 | //Serial pc(SERIAL_TX, SERIAL_RX); |
peu605 | 0:f90a4405ef98 | 28 | |
peu605 | 1:c271e7e2e330 | 29 | // F411RE specific |
peu605 | 1:c271e7e2e330 | 30 | #if defined(__F411RE__) |
peu605 | 0:f90a4405ef98 | 31 | inline void TFT_ILI9163C::waitSpiFree() { |
peu605 | 0:f90a4405ef98 | 32 | |
peu605 | 0:f90a4405ef98 | 33 | while ((spi_ptr->SR & SPI_SR_TXE) == 0); |
peu605 | 0:f90a4405ef98 | 34 | while ((spi_ptr->SR & SPI_SR_BSY) != 0); |
peu605 | 0:f90a4405ef98 | 35 | } |
peu605 | 0:f90a4405ef98 | 36 | |
peu605 | 0:f90a4405ef98 | 37 | |
peu605 | 0:f90a4405ef98 | 38 | inline void TFT_ILI9163C::writecommand(uint8_t c){ |
peu605 | 0:f90a4405ef98 | 39 | |
peu605 | 0:f90a4405ef98 | 40 | spi_ptr->CR1 &= ~SPI_CR1_DFF; |
peu605 | 0:f90a4405ef98 | 41 | |
peu605 | 0:f90a4405ef98 | 42 | _dc = 0; |
peu605 | 0:f90a4405ef98 | 43 | _cs = 0; |
peu605 | 0:f90a4405ef98 | 44 | |
peu605 | 0:f90a4405ef98 | 45 | spi_ptr->DR = c; |
peu605 | 0:f90a4405ef98 | 46 | |
peu605 | 0:f90a4405ef98 | 47 | waitSpiFree(); |
peu605 | 0:f90a4405ef98 | 48 | _cs = 1; |
peu605 | 0:f90a4405ef98 | 49 | } |
peu605 | 0:f90a4405ef98 | 50 | |
peu605 | 0:f90a4405ef98 | 51 | |
peu605 | 0:f90a4405ef98 | 52 | inline void TFT_ILI9163C::writedata(uint8_t c){ |
peu605 | 0:f90a4405ef98 | 53 | |
peu605 | 0:f90a4405ef98 | 54 | spi_ptr->CR1 &= ~SPI_CR1_DFF; |
peu605 | 0:f90a4405ef98 | 55 | |
peu605 | 0:f90a4405ef98 | 56 | _dc = 1; |
peu605 | 0:f90a4405ef98 | 57 | _cs = 0; |
peu605 | 0:f90a4405ef98 | 58 | |
peu605 | 0:f90a4405ef98 | 59 | spi_ptr->DR = c; |
peu605 | 0:f90a4405ef98 | 60 | |
peu605 | 0:f90a4405ef98 | 61 | waitSpiFree(); |
peu605 | 0:f90a4405ef98 | 62 | _cs = 1; |
peu605 | 0:f90a4405ef98 | 63 | } |
peu605 | 0:f90a4405ef98 | 64 | |
peu605 | 0:f90a4405ef98 | 65 | |
peu605 | 0:f90a4405ef98 | 66 | inline void TFT_ILI9163C::writedata16(uint16_t d){ |
peu605 | 0:f90a4405ef98 | 67 | |
peu605 | 0:f90a4405ef98 | 68 | spi_ptr->CR1 |= SPI_CR1_DFF; |
peu605 | 0:f90a4405ef98 | 69 | |
peu605 | 0:f90a4405ef98 | 70 | _dc = 1; |
peu605 | 0:f90a4405ef98 | 71 | _cs = 0; |
peu605 | 0:f90a4405ef98 | 72 | |
peu605 | 0:f90a4405ef98 | 73 | spi_ptr->DR = d; |
peu605 | 0:f90a4405ef98 | 74 | |
peu605 | 0:f90a4405ef98 | 75 | waitSpiFree(); |
peu605 | 0:f90a4405ef98 | 76 | _cs = 1; |
peu605 | 0:f90a4405ef98 | 77 | } |
peu605 | 0:f90a4405ef98 | 78 | |
peu605 | 0:f90a4405ef98 | 79 | |
peu605 | 0:f90a4405ef98 | 80 | inline void TFT_ILI9163C::writedata32(uint16_t d1, uint16_t d2){ |
peu605 | 0:f90a4405ef98 | 81 | |
peu605 | 0:f90a4405ef98 | 82 | spi_ptr->CR1 |= SPI_CR1_DFF; |
peu605 | 0:f90a4405ef98 | 83 | |
peu605 | 0:f90a4405ef98 | 84 | _dc = 1; |
peu605 | 0:f90a4405ef98 | 85 | _cs = 0; |
peu605 | 0:f90a4405ef98 | 86 | |
peu605 | 0:f90a4405ef98 | 87 | spi_ptr->DR = d1; |
peu605 | 0:f90a4405ef98 | 88 | while ((spi_ptr->SR & SPI_SR_TXE) == 0); |
peu605 | 0:f90a4405ef98 | 89 | spi_ptr->DR = d2; |
peu605 | 0:f90a4405ef98 | 90 | |
peu605 | 0:f90a4405ef98 | 91 | waitSpiFree(); |
peu605 | 0:f90a4405ef98 | 92 | _cs = 1; |
peu605 | 0:f90a4405ef98 | 93 | } |
peu605 | 0:f90a4405ef98 | 94 | |
peu605 | 0:f90a4405ef98 | 95 | |
peu605 | 0:f90a4405ef98 | 96 | inline void TFT_ILI9163C::writedata16burst(uint16_t d, int32_t len) { |
peu605 | 0:f90a4405ef98 | 97 | |
peu605 | 0:f90a4405ef98 | 98 | if (len < 0) { |
peu605 | 0:f90a4405ef98 | 99 | len = -len; |
peu605 | 0:f90a4405ef98 | 100 | } |
peu605 | 0:f90a4405ef98 | 101 | |
peu605 | 0:f90a4405ef98 | 102 | spi_ptr->CR1 |= SPI_CR1_DFF; |
peu605 | 0:f90a4405ef98 | 103 | |
peu605 | 0:f90a4405ef98 | 104 | _dc = 1; |
peu605 | 0:f90a4405ef98 | 105 | _cs = 0; |
peu605 | 0:f90a4405ef98 | 106 | |
peu605 | 0:f90a4405ef98 | 107 | #if defined(__F411RE_DMA__) |
peu605 | 0:f90a4405ef98 | 108 | // use DMA, but polling... :-( |
peu605 | 0:f90a4405ef98 | 109 | |
peu605 | 0:f90a4405ef98 | 110 | // clear DMA flags |
peu605 | 0:f90a4405ef98 | 111 | // __HAL_DMA_CLEAR_FLAG(&hdma, __HAL_DMA_GET_TE_FLAG_INDEX(&hdma)); |
peu605 | 0:f90a4405ef98 | 112 | __HAL_DMA_CLEAR_FLAG(&hdma, __HAL_DMA_GET_TC_FLAG_INDEX(&hdma)); |
peu605 | 0:f90a4405ef98 | 113 | |
peu605 | 0:f90a4405ef98 | 114 | hdma.Instance->M0AR = (uint32_t) &d; |
peu605 | 0:f90a4405ef98 | 115 | hdma.Instance->NDTR = len; |
peu605 | 0:f90a4405ef98 | 116 | // enable DMA |
peu605 | 0:f90a4405ef98 | 117 | hdma.Instance->CR |= DMA_SxCR_EN; |
peu605 | 0:f90a4405ef98 | 118 | |
peu605 | 0:f90a4405ef98 | 119 | // enable DMA request from SPI |
peu605 | 0:f90a4405ef98 | 120 | spi_ptr->CR2 |= SPI_CR2_TXDMAEN; |
peu605 | 0:f90a4405ef98 | 121 | // wait DMA complete |
peu605 | 0:f90a4405ef98 | 122 | while (hdma.Instance->NDTR); |
peu605 | 0:f90a4405ef98 | 123 | // disable SPI-DMA |
peu605 | 0:f90a4405ef98 | 124 | spi_ptr->CR2 &= ~SPI_CR2_TXDMAEN; |
peu605 | 0:f90a4405ef98 | 125 | |
peu605 | 0:f90a4405ef98 | 126 | // disable DMA |
peu605 | 0:f90a4405ef98 | 127 | hdma.Instance->CR &= ~DMA_SxCR_EN; |
peu605 | 0:f90a4405ef98 | 128 | while (hdma.Instance->CR & DMA_SxCR_EN); |
peu605 | 0:f90a4405ef98 | 129 | |
peu605 | 0:f90a4405ef98 | 130 | #else |
peu605 | 0:f90a4405ef98 | 131 | // use software loop, fast enough :-) |
peu605 | 0:f90a4405ef98 | 132 | while (len--) { |
peu605 | 0:f90a4405ef98 | 133 | while ((spi_ptr->SR & SPI_SR_TXE) == 0); |
peu605 | 0:f90a4405ef98 | 134 | spi_ptr->DR = d; |
peu605 | 0:f90a4405ef98 | 135 | } |
peu605 | 0:f90a4405ef98 | 136 | #endif |
peu605 | 0:f90a4405ef98 | 137 | |
peu605 | 0:f90a4405ef98 | 138 | waitSpiFree(); |
peu605 | 0:f90a4405ef98 | 139 | _cs = 1; |
peu605 | 0:f90a4405ef98 | 140 | } |
peu605 | 0:f90a4405ef98 | 141 | |
peu605 | 1:c271e7e2e330 | 142 | // mbed general |
peu605 | 1:c271e7e2e330 | 143 | #else |
peu605 | 1:c271e7e2e330 | 144 | inline void TFT_ILI9163C::waitSpiFree() { |
peu605 | 1:c271e7e2e330 | 145 | } |
peu605 | 1:c271e7e2e330 | 146 | |
peu605 | 1:c271e7e2e330 | 147 | inline void TFT_ILI9163C::writecommand(uint8_t c){ |
peu605 | 1:c271e7e2e330 | 148 | |
peu605 | 1:c271e7e2e330 | 149 | _dc = 0; |
peu605 | 1:c271e7e2e330 | 150 | _cs = 0; |
peu605 | 1:c271e7e2e330 | 151 | |
peu605 | 1:c271e7e2e330 | 152 | SPI::write(c); |
peu605 | 1:c271e7e2e330 | 153 | |
peu605 | 1:c271e7e2e330 | 154 | _cs = 1; |
peu605 | 1:c271e7e2e330 | 155 | } |
peu605 | 1:c271e7e2e330 | 156 | |
peu605 | 1:c271e7e2e330 | 157 | |
peu605 | 1:c271e7e2e330 | 158 | inline void TFT_ILI9163C::writedata(uint8_t c){ |
peu605 | 1:c271e7e2e330 | 159 | |
peu605 | 1:c271e7e2e330 | 160 | _dc = 1; |
peu605 | 1:c271e7e2e330 | 161 | _cs = 0; |
peu605 | 1:c271e7e2e330 | 162 | |
peu605 | 1:c271e7e2e330 | 163 | SPI::write(c); |
peu605 | 1:c271e7e2e330 | 164 | |
peu605 | 1:c271e7e2e330 | 165 | _cs = 1; |
peu605 | 1:c271e7e2e330 | 166 | } |
peu605 | 1:c271e7e2e330 | 167 | |
peu605 | 1:c271e7e2e330 | 168 | |
peu605 | 1:c271e7e2e330 | 169 | inline void TFT_ILI9163C::writedata16(uint16_t d){ |
peu605 | 1:c271e7e2e330 | 170 | |
peu605 | 1:c271e7e2e330 | 171 | _dc = 1; |
peu605 | 1:c271e7e2e330 | 172 | _cs = 0; |
peu605 | 1:c271e7e2e330 | 173 | |
peu605 | 1:c271e7e2e330 | 174 | SPI::write(d >> 8); |
peu605 | 1:c271e7e2e330 | 175 | SPI::write(d & 0xff); |
peu605 | 1:c271e7e2e330 | 176 | |
peu605 | 1:c271e7e2e330 | 177 | _cs = 1; |
peu605 | 1:c271e7e2e330 | 178 | } |
peu605 | 1:c271e7e2e330 | 179 | |
peu605 | 1:c271e7e2e330 | 180 | |
peu605 | 1:c271e7e2e330 | 181 | inline void TFT_ILI9163C::writedata32(uint16_t d1, uint16_t d2){ |
peu605 | 1:c271e7e2e330 | 182 | |
peu605 | 1:c271e7e2e330 | 183 | _dc = 1; |
peu605 | 1:c271e7e2e330 | 184 | _cs = 0; |
peu605 | 1:c271e7e2e330 | 185 | |
peu605 | 1:c271e7e2e330 | 186 | SPI::write(d1 >> 8); |
peu605 | 1:c271e7e2e330 | 187 | SPI::write(d1 & 0xff); |
peu605 | 1:c271e7e2e330 | 188 | SPI::write(d2 >> 8); |
peu605 | 1:c271e7e2e330 | 189 | SPI::write(d2 & 0xff); |
peu605 | 1:c271e7e2e330 | 190 | |
peu605 | 1:c271e7e2e330 | 191 | _cs = 1; |
peu605 | 1:c271e7e2e330 | 192 | } |
peu605 | 1:c271e7e2e330 | 193 | |
peu605 | 1:c271e7e2e330 | 194 | |
peu605 | 1:c271e7e2e330 | 195 | inline void TFT_ILI9163C::writedata16burst(uint16_t d, int32_t len) { |
peu605 | 1:c271e7e2e330 | 196 | |
peu605 | 1:c271e7e2e330 | 197 | if (len < 0) { |
peu605 | 1:c271e7e2e330 | 198 | len = -len; |
peu605 | 1:c271e7e2e330 | 199 | } |
peu605 | 1:c271e7e2e330 | 200 | |
peu605 | 1:c271e7e2e330 | 201 | _dc = 1; |
peu605 | 1:c271e7e2e330 | 202 | _cs = 0; |
peu605 | 1:c271e7e2e330 | 203 | |
peu605 | 1:c271e7e2e330 | 204 | while (len--) { |
peu605 | 1:c271e7e2e330 | 205 | SPI::write(d >> 8); |
peu605 | 1:c271e7e2e330 | 206 | SPI::write(d & 0xff); |
peu605 | 1:c271e7e2e330 | 207 | } |
peu605 | 1:c271e7e2e330 | 208 | |
peu605 | 1:c271e7e2e330 | 209 | _cs = 1; |
peu605 | 1:c271e7e2e330 | 210 | } |
peu605 | 1:c271e7e2e330 | 211 | #endif |
peu605 | 1:c271e7e2e330 | 212 | |
peu605 | 0:f90a4405ef98 | 213 | |
peu605 | 0:f90a4405ef98 | 214 | void TFT_ILI9163C::setBitrate(uint32_t n){ |
peu605 | 0:f90a4405ef98 | 215 | SPI::frequency(n); |
peu605 | 0:f90a4405ef98 | 216 | } |
peu605 | 0:f90a4405ef98 | 217 | |
peu605 | 0:f90a4405ef98 | 218 | |
peu605 | 0:f90a4405ef98 | 219 | void TFT_ILI9163C::begin(void) { |
peu605 | 0:f90a4405ef98 | 220 | |
peu605 | 0:f90a4405ef98 | 221 | SPI::format(8,0); // 8 bit spi mode 0 |
peu605 | 0:f90a4405ef98 | 222 | SPI::frequency(5000000L); // 5MHz |
peu605 | 0:f90a4405ef98 | 223 | |
peu605 | 1:c271e7e2e330 | 224 | #if defined(__F411RE__) |
peu605 | 0:f90a4405ef98 | 225 | spi_ptr = (SPI_TypeDef*) _spi.spi; |
peu605 | 1:c271e7e2e330 | 226 | |
peu605 | 0:f90a4405ef98 | 227 | #if defined(__F411RE_DMA__) |
peu605 | 0:f90a4405ef98 | 228 | hdma.Init.Direction = DMA_MEMORY_TO_PERIPH; |
peu605 | 0:f90a4405ef98 | 229 | hdma.Init.PeriphInc = DMA_PINC_DISABLE; |
peu605 | 0:f90a4405ef98 | 230 | hdma.Init.MemInc = DMA_MINC_DISABLE; |
peu605 | 0:f90a4405ef98 | 231 | hdma.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; |
peu605 | 0:f90a4405ef98 | 232 | hdma.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; |
peu605 | 0:f90a4405ef98 | 233 | hdma.Init.Mode = DMA_NORMAL; |
peu605 | 0:f90a4405ef98 | 234 | hdma.Init.Priority = DMA_PRIORITY_MEDIUM; |
peu605 | 0:f90a4405ef98 | 235 | hdma.Init.FIFOMode = DMA_FIFOMODE_DISABLE; |
peu605 | 0:f90a4405ef98 | 236 | hdma.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_HALFFULL; |
peu605 | 0:f90a4405ef98 | 237 | hdma.Init.MemBurst = DMA_MBURST_SINGLE; |
peu605 | 0:f90a4405ef98 | 238 | hdma.Init.PeriphBurst = DMA_PBURST_SINGLE; |
peu605 | 0:f90a4405ef98 | 239 | |
peu605 | 0:f90a4405ef98 | 240 | if(_spi.spi == SPI_1){ |
peu605 | 0:f90a4405ef98 | 241 | hdma.Instance = DMA2_Stream3; // DMA2_Stream2 |
peu605 | 0:f90a4405ef98 | 242 | hdma.Init.Channel = DMA_CHANNEL_3; // DMA_CHANNEL_2 |
peu605 | 0:f90a4405ef98 | 243 | __DMA2_CLK_ENABLE(); |
peu605 | 0:f90a4405ef98 | 244 | } else if(_spi.spi == SPI_2){ |
peu605 | 0:f90a4405ef98 | 245 | hdma.Instance = DMA1_Stream4; |
peu605 | 0:f90a4405ef98 | 246 | hdma.Init.Channel = DMA_CHANNEL_0; |
peu605 | 0:f90a4405ef98 | 247 | __DMA1_CLK_ENABLE(); |
peu605 | 0:f90a4405ef98 | 248 | } else if(_spi.spi == SPI_3){ |
peu605 | 0:f90a4405ef98 | 249 | hdma.Instance = DMA1_Stream5; // DMA1_Stream7 |
peu605 | 0:f90a4405ef98 | 250 | hdma.Init.Channel = DMA_CHANNEL_0; // DMA_CHANNEL0 |
peu605 | 0:f90a4405ef98 | 251 | __DMA1_CLK_ENABLE(); |
peu605 | 0:f90a4405ef98 | 252 | } else if(_spi.spi == SPI_4){ |
peu605 | 0:f90a4405ef98 | 253 | hdma.Instance = DMA2_Stream1; // DMA2_Stream4 |
peu605 | 0:f90a4405ef98 | 254 | hdma.Init.Channel = DMA_CHANNEL_4; // DMA_CHANNEL_5 |
peu605 | 0:f90a4405ef98 | 255 | __DMA2_CLK_ENABLE(); |
peu605 | 0:f90a4405ef98 | 256 | } else if(_spi.spi == SPI_5){ |
peu605 | 0:f90a4405ef98 | 257 | hdma.Instance = DMA2_Stream4; // DMA2_Stream5, DMA2_Stream6 |
peu605 | 0:f90a4405ef98 | 258 | hdma.Init.Channel = DMA_CHANNEL_2; // DMA_CHANNEL5, DMA_CHANNEL7 |
peu605 | 0:f90a4405ef98 | 259 | __DMA2_CLK_ENABLE(); |
peu605 | 0:f90a4405ef98 | 260 | } |
peu605 | 0:f90a4405ef98 | 261 | |
peu605 | 0:f90a4405ef98 | 262 | HAL_DMA_Init(&hdma); |
peu605 | 0:f90a4405ef98 | 263 | |
peu605 | 0:f90a4405ef98 | 264 | // set SPI DR ss Peripheral address |
peu605 | 0:f90a4405ef98 | 265 | hdma.Instance->PAR = (uint32_t) &spi_ptr->DR; |
peu605 | 0:f90a4405ef98 | 266 | #endif |
peu605 | 1:c271e7e2e330 | 267 | #endif |
peu605 | 0:f90a4405ef98 | 268 | |
peu605 | 0:f90a4405ef98 | 269 | if (_resetPinName != NC) { |
peu605 | 0:f90a4405ef98 | 270 | DigitalOut _reset(_resetPinName); |
peu605 | 0:f90a4405ef98 | 271 | _reset = 1; |
peu605 | 0:f90a4405ef98 | 272 | wait_ms(1); |
peu605 | 0:f90a4405ef98 | 273 | _reset = 0; |
peu605 | 0:f90a4405ef98 | 274 | wait_ms(2); |
peu605 | 0:f90a4405ef98 | 275 | _reset = 1; |
peu605 | 0:f90a4405ef98 | 276 | wait_ms(120); |
peu605 | 0:f90a4405ef98 | 277 | } |
peu605 | 0:f90a4405ef98 | 278 | |
peu605 | 0:f90a4405ef98 | 279 | /* |
peu605 | 0:f90a4405ef98 | 280 | 7) MY: 1(bottom to top), 0(top to bottom) Row Address Order |
peu605 | 0:f90a4405ef98 | 281 | 6) MX: 1(R to L), 0(L to R) Column Address Order |
peu605 | 0:f90a4405ef98 | 282 | 5) MV: 1(Exchanged), 0(normal) Row/Column exchange |
peu605 | 0:f90a4405ef98 | 283 | 4) ML: 1(bottom to top), 0(top to bottom) Vertical Refresh Order |
peu605 | 0:f90a4405ef98 | 284 | 3) RGB: 1(BGR), 0(RGB) Color Space |
peu605 | 0:f90a4405ef98 | 285 | 2) MH: 1(R to L), 0(L to R) Horizontal Refresh Order |
peu605 | 0:f90a4405ef98 | 286 | 1) |
peu605 | 0:f90a4405ef98 | 287 | 0) |
peu605 | 0:f90a4405ef98 | 288 | |
peu605 | 0:f90a4405ef98 | 289 | MY, MX, MV, ML,RGB, MH, D1, D0 |
peu605 | 0:f90a4405ef98 | 290 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 //normal |
peu605 | 0:f90a4405ef98 | 291 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 //Y-Mirror |
peu605 | 0:f90a4405ef98 | 292 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 //X-Mirror |
peu605 | 0:f90a4405ef98 | 293 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 //X-Y-Mirror |
peu605 | 0:f90a4405ef98 | 294 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 //X-Y Exchange |
peu605 | 0:f90a4405ef98 | 295 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 //X-Y Exchange, Y-Mirror |
peu605 | 0:f90a4405ef98 | 296 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 //XY exchange |
peu605 | 0:f90a4405ef98 | 297 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 |
peu605 | 0:f90a4405ef98 | 298 | */ |
peu605 | 0:f90a4405ef98 | 299 | _Mactrl_Data = 0; // 0b00000000; |
peu605 | 0:f90a4405ef98 | 300 | _colorspaceData = __COLORSPC;//start with default data; |
peu605 | 0:f90a4405ef98 | 301 | chipInit(); |
peu605 | 0:f90a4405ef98 | 302 | } |
peu605 | 0:f90a4405ef98 | 303 | |
peu605 | 0:f90a4405ef98 | 304 | |
peu605 | 0:f90a4405ef98 | 305 | void TFT_ILI9163C::chipInit() { |
peu605 | 0:f90a4405ef98 | 306 | writecommand(CMD_SWRESET);//software reset |
peu605 | 0:f90a4405ef98 | 307 | wait_ms(120); |
peu605 | 0:f90a4405ef98 | 308 | writecommand(CMD_SLPOUT);//exit sleep |
peu605 | 0:f90a4405ef98 | 309 | wait_ms(5); |
peu605 | 0:f90a4405ef98 | 310 | writecommand(CMD_PIXFMT);//Set Color Format 16bit |
peu605 | 0:f90a4405ef98 | 311 | writedata(0x05); |
peu605 | 0:f90a4405ef98 | 312 | wait_ms(5); |
peu605 | 0:f90a4405ef98 | 313 | writecommand(CMD_GAMMASET);//default gamma curve 3 |
peu605 | 0:f90a4405ef98 | 314 | writedata(0x04);//0x04 |
peu605 | 0:f90a4405ef98 | 315 | wait_ms(1); |
peu605 | 0:f90a4405ef98 | 316 | writecommand(CMD_GAMRSEL);//Enable Gamma adj |
peu605 | 0:f90a4405ef98 | 317 | writedata(0x01); |
peu605 | 0:f90a4405ef98 | 318 | wait_ms(1); |
peu605 | 0:f90a4405ef98 | 319 | writecommand(CMD_NORML); |
peu605 | 0:f90a4405ef98 | 320 | |
peu605 | 0:f90a4405ef98 | 321 | writecommand(CMD_DFUNCTR); |
peu605 | 0:f90a4405ef98 | 322 | writedata(0xff); // writedata(0b11111111);// |
peu605 | 0:f90a4405ef98 | 323 | writedata(0x06); // writedata(0b00000110);// |
peu605 | 0:f90a4405ef98 | 324 | |
peu605 | 0:f90a4405ef98 | 325 | writecommand(CMD_PGAMMAC);//Positive Gamma Correction Setting |
peu605 | 0:f90a4405ef98 | 326 | #if defined(__GAMMASET1) |
peu605 | 0:f90a4405ef98 | 327 | writedata(0x36);//p1 |
peu605 | 0:f90a4405ef98 | 328 | writedata(0x29);//p2 |
peu605 | 0:f90a4405ef98 | 329 | writedata(0x12);//p3 |
peu605 | 0:f90a4405ef98 | 330 | writedata(0x22);//p4 |
peu605 | 0:f90a4405ef98 | 331 | writedata(0x1C);//p5 |
peu605 | 0:f90a4405ef98 | 332 | writedata(0x15);//p6 |
peu605 | 0:f90a4405ef98 | 333 | writedata(0x42);//p7 |
peu605 | 0:f90a4405ef98 | 334 | writedata(0xB7);//p8 |
peu605 | 0:f90a4405ef98 | 335 | writedata(0x2F);//p9 |
peu605 | 0:f90a4405ef98 | 336 | writedata(0x13);//p10 |
peu605 | 0:f90a4405ef98 | 337 | writedata(0x12);//p11 |
peu605 | 0:f90a4405ef98 | 338 | writedata(0x0A);//p12 |
peu605 | 0:f90a4405ef98 | 339 | writedata(0x11);//p13 |
peu605 | 0:f90a4405ef98 | 340 | writedata(0x0B);//p14 |
peu605 | 0:f90a4405ef98 | 341 | writedata(0x06);//p15 |
peu605 | 0:f90a4405ef98 | 342 | #else |
peu605 | 0:f90a4405ef98 | 343 | writedata(0x3F);//p1 |
peu605 | 0:f90a4405ef98 | 344 | writedata(0x25);//p2 |
peu605 | 0:f90a4405ef98 | 345 | writedata(0x1C);//p3 |
peu605 | 0:f90a4405ef98 | 346 | writedata(0x1E);//p4 |
peu605 | 0:f90a4405ef98 | 347 | writedata(0x20);//p5 |
peu605 | 0:f90a4405ef98 | 348 | writedata(0x12);//p6 |
peu605 | 0:f90a4405ef98 | 349 | writedata(0x2A);//p7 |
peu605 | 0:f90a4405ef98 | 350 | writedata(0x90);//p8 |
peu605 | 0:f90a4405ef98 | 351 | writedata(0x24);//p9 |
peu605 | 0:f90a4405ef98 | 352 | writedata(0x11);//p10 |
peu605 | 0:f90a4405ef98 | 353 | writedata(0x00);//p11 |
peu605 | 0:f90a4405ef98 | 354 | writedata(0x00);//p12 |
peu605 | 0:f90a4405ef98 | 355 | writedata(0x00);//p13 |
peu605 | 0:f90a4405ef98 | 356 | writedata(0x00);//p14 |
peu605 | 0:f90a4405ef98 | 357 | writedata(0x00);//p15 |
peu605 | 0:f90a4405ef98 | 358 | #endif |
peu605 | 0:f90a4405ef98 | 359 | |
peu605 | 0:f90a4405ef98 | 360 | writecommand(CMD_NGAMMAC);//Negative Gamma Correction Setting |
peu605 | 0:f90a4405ef98 | 361 | #if defined(__GAMMASET1) |
peu605 | 0:f90a4405ef98 | 362 | writedata(0x09);//p1 |
peu605 | 0:f90a4405ef98 | 363 | writedata(0x16);//p2 |
peu605 | 0:f90a4405ef98 | 364 | writedata(0x2D);//p3 |
peu605 | 0:f90a4405ef98 | 365 | writedata(0x0D);//p4 |
peu605 | 0:f90a4405ef98 | 366 | writedata(0x13);//p5 |
peu605 | 0:f90a4405ef98 | 367 | writedata(0x15);//p6 |
peu605 | 0:f90a4405ef98 | 368 | writedata(0x40);//p7 |
peu605 | 0:f90a4405ef98 | 369 | writedata(0x48);//p8 |
peu605 | 0:f90a4405ef98 | 370 | writedata(0x53);//p9 |
peu605 | 0:f90a4405ef98 | 371 | writedata(0x0C);//p10 |
peu605 | 0:f90a4405ef98 | 372 | writedata(0x1D);//p11 |
peu605 | 0:f90a4405ef98 | 373 | writedata(0x25);//p12 |
peu605 | 0:f90a4405ef98 | 374 | writedata(0x2E);//p13 |
peu605 | 0:f90a4405ef98 | 375 | writedata(0x34);//p14 |
peu605 | 0:f90a4405ef98 | 376 | writedata(0x39);//p15 |
peu605 | 0:f90a4405ef98 | 377 | #else |
peu605 | 0:f90a4405ef98 | 378 | writedata(0x20);//p1 |
peu605 | 0:f90a4405ef98 | 379 | writedata(0x20);//p2 |
peu605 | 0:f90a4405ef98 | 380 | writedata(0x20);//p3 |
peu605 | 0:f90a4405ef98 | 381 | writedata(0x20);//p4 |
peu605 | 0:f90a4405ef98 | 382 | writedata(0x05);//p5 |
peu605 | 0:f90a4405ef98 | 383 | writedata(0x15);//p6 |
peu605 | 0:f90a4405ef98 | 384 | writedata(0x00);//p7 |
peu605 | 0:f90a4405ef98 | 385 | writedata(0xA7);//p8 |
peu605 | 0:f90a4405ef98 | 386 | writedata(0x3D);//p9 |
peu605 | 0:f90a4405ef98 | 387 | writedata(0x18);//p10 |
peu605 | 0:f90a4405ef98 | 388 | writedata(0x25);//p11 |
peu605 | 0:f90a4405ef98 | 389 | writedata(0x2A);//p12 |
peu605 | 0:f90a4405ef98 | 390 | writedata(0x2B);//p13 |
peu605 | 0:f90a4405ef98 | 391 | writedata(0x2B);//p14 |
peu605 | 0:f90a4405ef98 | 392 | writedata(0x3A);//p15 |
peu605 | 0:f90a4405ef98 | 393 | #endif |
peu605 | 0:f90a4405ef98 | 394 | |
peu605 | 0:f90a4405ef98 | 395 | writecommand(CMD_FRMCTR1);//Frame Rate Control (In normal mode/Full colors) |
peu605 | 0:f90a4405ef98 | 396 | writedata(0x08);//0x0C//0x08 |
peu605 | 0:f90a4405ef98 | 397 | writedata(0x02);//0x14//0x08 |
peu605 | 0:f90a4405ef98 | 398 | wait_ms(1); |
peu605 | 0:f90a4405ef98 | 399 | writecommand(CMD_DINVCTR);//display inversion |
peu605 | 0:f90a4405ef98 | 400 | writedata(0x07); |
peu605 | 0:f90a4405ef98 | 401 | wait_ms(1); |
peu605 | 0:f90a4405ef98 | 402 | writecommand(CMD_PWCTR1);//Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD |
peu605 | 0:f90a4405ef98 | 403 | writedata(0x0A);//4.30 - 0x0A |
peu605 | 0:f90a4405ef98 | 404 | writedata(0x02);//0x05 |
peu605 | 0:f90a4405ef98 | 405 | wait_ms(1); |
peu605 | 0:f90a4405ef98 | 406 | writecommand(CMD_PWCTR2);//Set BT[2:0] for AVDD & VCL & VGH & VGL |
peu605 | 0:f90a4405ef98 | 407 | writedata(0x02); |
peu605 | 0:f90a4405ef98 | 408 | wait_ms(1); |
peu605 | 0:f90a4405ef98 | 409 | writecommand(CMD_VCOMCTR1);//Set VMH[6:0] & VML[6:0] for VOMH & VCOML |
peu605 | 0:f90a4405ef98 | 410 | writedata(0x50);//0x50 |
peu605 | 0:f90a4405ef98 | 411 | writedata(99);//0x5b |
peu605 | 0:f90a4405ef98 | 412 | wait_ms(1); |
peu605 | 0:f90a4405ef98 | 413 | writecommand(CMD_VCOMOFFS); |
peu605 | 0:f90a4405ef98 | 414 | writedata(0);//0x40 |
peu605 | 0:f90a4405ef98 | 415 | wait_ms(1); |
peu605 | 0:f90a4405ef98 | 416 | |
peu605 | 0:f90a4405ef98 | 417 | colorSpace(_colorspaceData); |
peu605 | 0:f90a4405ef98 | 418 | setRotation(0); |
peu605 | 0:f90a4405ef98 | 419 | wait_ms(1); |
peu605 | 0:f90a4405ef98 | 420 | |
peu605 | 0:f90a4405ef98 | 421 | fillScreen(BLACK); |
peu605 | 0:f90a4405ef98 | 422 | writecommand(CMD_DISPON);//display ON |
peu605 | 0:f90a4405ef98 | 423 | } |
peu605 | 0:f90a4405ef98 | 424 | |
peu605 | 0:f90a4405ef98 | 425 | /* |
peu605 | 0:f90a4405ef98 | 426 | Colorspace selection: |
peu605 | 0:f90a4405ef98 | 427 | 0: RGB |
peu605 | 0:f90a4405ef98 | 428 | 1: GBR |
peu605 | 0:f90a4405ef98 | 429 | */ |
peu605 | 0:f90a4405ef98 | 430 | void TFT_ILI9163C::colorSpace(uint8_t cspace) { |
peu605 | 0:f90a4405ef98 | 431 | if (cspace < 1){ |
peu605 | 0:f90a4405ef98 | 432 | _Mactrl_Data &= ~(1 << 3); // bitClear(_Mactrl_Data,3); |
peu605 | 0:f90a4405ef98 | 433 | } else { |
peu605 | 0:f90a4405ef98 | 434 | _Mactrl_Data |= 1 << 3; // bitSet(_Mactrl_Data,3); |
peu605 | 0:f90a4405ef98 | 435 | } |
peu605 | 0:f90a4405ef98 | 436 | } |
peu605 | 0:f90a4405ef98 | 437 | |
peu605 | 0:f90a4405ef98 | 438 | |
peu605 | 0:f90a4405ef98 | 439 | void TFT_ILI9163C::clearScreen(uint16_t color) { |
peu605 | 0:f90a4405ef98 | 440 | homeAddress(); |
peu605 | 0:f90a4405ef98 | 441 | writedata16burst(color, _GRAMSIZE); |
peu605 | 0:f90a4405ef98 | 442 | } |
peu605 | 0:f90a4405ef98 | 443 | |
peu605 | 0:f90a4405ef98 | 444 | void TFT_ILI9163C::homeAddress() { |
peu605 | 0:f90a4405ef98 | 445 | setAddrWindow(0x00,0x00,_GRAMWIDTH-1,_GRAMHEIGH-1); |
peu605 | 0:f90a4405ef98 | 446 | } |
peu605 | 0:f90a4405ef98 | 447 | |
peu605 | 0:f90a4405ef98 | 448 | |
peu605 | 0:f90a4405ef98 | 449 | void TFT_ILI9163C::setCursor(int16_t x, int16_t y) { |
peu605 | 0:f90a4405ef98 | 450 | if (boundaryCheck(x,y)) return; |
peu605 | 0:f90a4405ef98 | 451 | setAddrWindow(0x00,0x00,x,y); |
peu605 | 0:f90a4405ef98 | 452 | cursor_x = x; |
peu605 | 0:f90a4405ef98 | 453 | cursor_y = y; |
peu605 | 0:f90a4405ef98 | 454 | } |
peu605 | 0:f90a4405ef98 | 455 | |
peu605 | 0:f90a4405ef98 | 456 | |
peu605 | 0:f90a4405ef98 | 457 | void TFT_ILI9163C::pushColor(uint16_t color) { |
peu605 | 0:f90a4405ef98 | 458 | writedata16(color); |
peu605 | 0:f90a4405ef98 | 459 | } |
peu605 | 0:f90a4405ef98 | 460 | |
peu605 | 0:f90a4405ef98 | 461 | |
peu605 | 0:f90a4405ef98 | 462 | void TFT_ILI9163C::drawPixel(int16_t x, int16_t y, uint16_t color) { |
peu605 | 0:f90a4405ef98 | 463 | if (boundaryCheck(x,y)) return; |
peu605 | 0:f90a4405ef98 | 464 | if ((x < 0) || (y < 0)) return; |
peu605 | 0:f90a4405ef98 | 465 | setAddrWindow(x,y,x+1,y+1); |
peu605 | 0:f90a4405ef98 | 466 | writedata16(color); |
peu605 | 0:f90a4405ef98 | 467 | } |
peu605 | 0:f90a4405ef98 | 468 | |
peu605 | 0:f90a4405ef98 | 469 | |
peu605 | 0:f90a4405ef98 | 470 | void TFT_ILI9163C::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) { |
peu605 | 0:f90a4405ef98 | 471 | // Rudimentary clipping |
peu605 | 0:f90a4405ef98 | 472 | if (boundaryCheck(x,y)) return; |
peu605 | 0:f90a4405ef98 | 473 | if (((y + h) - 1) >= _height) h = _height-y; |
peu605 | 0:f90a4405ef98 | 474 | |
peu605 | 0:f90a4405ef98 | 475 | setAddrWindow(x,y,x,(y+h)-1); |
peu605 | 0:f90a4405ef98 | 476 | writedata16burst(color, h); |
peu605 | 0:f90a4405ef98 | 477 | } |
peu605 | 0:f90a4405ef98 | 478 | |
peu605 | 0:f90a4405ef98 | 479 | inline bool TFT_ILI9163C::boundaryCheck(int16_t x,int16_t y){ |
peu605 | 0:f90a4405ef98 | 480 | if ((x >= _width) || (y >= _height)) return true; |
peu605 | 0:f90a4405ef98 | 481 | return false; |
peu605 | 0:f90a4405ef98 | 482 | } |
peu605 | 0:f90a4405ef98 | 483 | |
peu605 | 0:f90a4405ef98 | 484 | void TFT_ILI9163C::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) { |
peu605 | 0:f90a4405ef98 | 485 | // Rudimentary clipping |
peu605 | 0:f90a4405ef98 | 486 | if (boundaryCheck(x,y)) return; |
peu605 | 0:f90a4405ef98 | 487 | if (((x+w) - 1) >= _width) w = _width-x; |
peu605 | 0:f90a4405ef98 | 488 | |
peu605 | 0:f90a4405ef98 | 489 | setAddrWindow(x,y,(x+w)-1,y); |
peu605 | 0:f90a4405ef98 | 490 | writedata16burst(color, w); |
peu605 | 0:f90a4405ef98 | 491 | } |
peu605 | 0:f90a4405ef98 | 492 | |
peu605 | 0:f90a4405ef98 | 493 | void TFT_ILI9163C::fillScreen(uint16_t color) { |
peu605 | 0:f90a4405ef98 | 494 | clearScreen(color); |
peu605 | 0:f90a4405ef98 | 495 | } |
peu605 | 0:f90a4405ef98 | 496 | |
peu605 | 0:f90a4405ef98 | 497 | // fill a rectangle |
peu605 | 0:f90a4405ef98 | 498 | void TFT_ILI9163C::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { |
peu605 | 0:f90a4405ef98 | 499 | |
peu605 | 0:f90a4405ef98 | 500 | if (boundaryCheck(x,y)) return; |
peu605 | 0:f90a4405ef98 | 501 | if (((x + w) - 1) >= _width) w = _width - x; |
peu605 | 0:f90a4405ef98 | 502 | if (((y + h) - 1) >= _height) h = _height - y; |
peu605 | 0:f90a4405ef98 | 503 | |
peu605 | 0:f90a4405ef98 | 504 | setAddrWindow(x,y,(x+w)-1,(y+h)-1); |
peu605 | 0:f90a4405ef98 | 505 | writedata16burst(color, w * h); |
peu605 | 0:f90a4405ef98 | 506 | } |
peu605 | 0:f90a4405ef98 | 507 | |
peu605 | 0:f90a4405ef98 | 508 | |
peu605 | 0:f90a4405ef98 | 509 | // Pass 8-bit (each) R,G,B, get back 16-bit packed color |
peu605 | 0:f90a4405ef98 | 510 | |
peu605 | 0:f90a4405ef98 | 511 | uint16_t TFT_ILI9163C::Color565(uint8_t r, uint8_t g, uint8_t b) { |
peu605 | 0:f90a4405ef98 | 512 | return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); |
peu605 | 0:f90a4405ef98 | 513 | } |
peu605 | 0:f90a4405ef98 | 514 | |
peu605 | 0:f90a4405ef98 | 515 | |
peu605 | 0:f90a4405ef98 | 516 | void TFT_ILI9163C::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { |
peu605 | 0:f90a4405ef98 | 517 | |
peu605 | 0:f90a4405ef98 | 518 | writecommand(CMD_CLMADRS); // Column |
peu605 | 0:f90a4405ef98 | 519 | |
peu605 | 0:f90a4405ef98 | 520 | if (rotation == 1) { |
peu605 | 0:f90a4405ef98 | 521 | writedata32(x0 + __OFFSET, x1 + __OFFSET); |
peu605 | 0:f90a4405ef98 | 522 | } else { |
peu605 | 0:f90a4405ef98 | 523 | writedata32(x0, x1); |
peu605 | 0:f90a4405ef98 | 524 | } |
peu605 | 0:f90a4405ef98 | 525 | |
peu605 | 0:f90a4405ef98 | 526 | writecommand(CMD_PGEADRS); // Page |
peu605 | 0:f90a4405ef98 | 527 | if (rotation == 0){ |
peu605 | 0:f90a4405ef98 | 528 | writedata32(y0 + __OFFSET, y1 + __OFFSET); |
peu605 | 0:f90a4405ef98 | 529 | } else { |
peu605 | 0:f90a4405ef98 | 530 | writedata32(y0, y1); |
peu605 | 0:f90a4405ef98 | 531 | } |
peu605 | 0:f90a4405ef98 | 532 | |
peu605 | 0:f90a4405ef98 | 533 | writecommand(CMD_RAMWR); //Into RAM |
peu605 | 0:f90a4405ef98 | 534 | } |
peu605 | 0:f90a4405ef98 | 535 | |
peu605 | 0:f90a4405ef98 | 536 | |
peu605 | 0:f90a4405ef98 | 537 | void TFT_ILI9163C::setRotation(uint8_t m) { |
peu605 | 0:f90a4405ef98 | 538 | rotation = m &3; // can't be higher than 3 |
peu605 | 0:f90a4405ef98 | 539 | switch (rotation) { |
peu605 | 0:f90a4405ef98 | 540 | case 0: |
peu605 | 0:f90a4405ef98 | 541 | _Mactrl_Data = 0x08; // 0b00001000; |
peu605 | 0:f90a4405ef98 | 542 | _width = _TFTWIDTH; |
peu605 | 0:f90a4405ef98 | 543 | _height = _TFTHEIGHT;//-__OFFSET; |
peu605 | 0:f90a4405ef98 | 544 | break; |
peu605 | 0:f90a4405ef98 | 545 | case 1: |
peu605 | 0:f90a4405ef98 | 546 | _Mactrl_Data = 0x68; // 0b01101000; |
peu605 | 0:f90a4405ef98 | 547 | _width = _TFTHEIGHT;//-__OFFSET; |
peu605 | 0:f90a4405ef98 | 548 | _height = _TFTWIDTH; |
peu605 | 0:f90a4405ef98 | 549 | break; |
peu605 | 0:f90a4405ef98 | 550 | case 2: |
peu605 | 0:f90a4405ef98 | 551 | _Mactrl_Data = 0xC8; // 0b11001000; |
peu605 | 0:f90a4405ef98 | 552 | _width = _TFTWIDTH; |
peu605 | 0:f90a4405ef98 | 553 | _height = _TFTHEIGHT;//-__OFFSET; |
peu605 | 0:f90a4405ef98 | 554 | break; |
peu605 | 0:f90a4405ef98 | 555 | case 3: |
peu605 | 0:f90a4405ef98 | 556 | _Mactrl_Data = 0xA8; // 0b10101000; |
peu605 | 0:f90a4405ef98 | 557 | _width = _TFTWIDTH; |
peu605 | 0:f90a4405ef98 | 558 | _height = _TFTHEIGHT;//-__OFFSET; |
peu605 | 0:f90a4405ef98 | 559 | break; |
peu605 | 0:f90a4405ef98 | 560 | } |
peu605 | 0:f90a4405ef98 | 561 | colorSpace(_colorspaceData); |
peu605 | 0:f90a4405ef98 | 562 | writecommand(CMD_MADCTL); |
peu605 | 0:f90a4405ef98 | 563 | writedata(_Mactrl_Data); |
peu605 | 0:f90a4405ef98 | 564 | } |
peu605 | 0:f90a4405ef98 | 565 | |
peu605 | 0:f90a4405ef98 | 566 | |
peu605 | 0:f90a4405ef98 | 567 | void TFT_ILI9163C::invertDisplay(bool i) { |
peu605 | 0:f90a4405ef98 | 568 | writecommand(i ? CMD_DINVON : CMD_DINVOF); |
peu605 | 0:f90a4405ef98 | 569 | } |