Added SPI speed parameter
Dependents: EasyCAT_LAB_simple EasyCAT_LAB
- The default SPI speed has been set to 27MHz, but it can be configured using the last parameter of the constructor.
- This is an optimization for the EasyCAT LAB , a complete educational and experimental EtherCAT® system, composed of one master and two slaves .
SPI_TFT_ILI9341.cpp@12:1cf4e83eb240, 12 months ago (annotated)
- Committer:
- info@bausano.net
- Date:
- Tue Oct 24 23:32:54 2023 +0200
- Revision:
- 12:1cf4e83eb240
- Parent:
- 11:f94024581a44
Added compatibility with parallel interface TFT
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dreschpe | 0:da1bf437cbc1 | 1 | /* mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller |
dreschpe | 0:da1bf437cbc1 | 2 | * Copyright (c) 2013 Peter Drescher - DC2PD |
dreschpe | 0:da1bf437cbc1 | 3 | * |
dreschpe | 0:da1bf437cbc1 | 4 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
dreschpe | 0:da1bf437cbc1 | 5 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
dreschpe | 0:da1bf437cbc1 | 6 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
dreschpe | 0:da1bf437cbc1 | 7 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
dreschpe | 0:da1bf437cbc1 | 8 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
dreschpe | 0:da1bf437cbc1 | 9 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
dreschpe | 0:da1bf437cbc1 | 10 | * THE SOFTWARE. |
dreschpe | 0:da1bf437cbc1 | 11 | */ |
dreschpe | 0:da1bf437cbc1 | 12 | |
dreschpe | 0:da1bf437cbc1 | 13 | // 12.06.13 fork from SPI_TFT code because controller is different ... |
dreschpe | 2:0a16083193a4 | 14 | // 14.07.13 Test with real display and bugfix |
dreschpe | 4:f018e272220b | 15 | // 18.10.13 Better Circle function from Michael Ammann |
dreschpe | 6:55aed13f2630 | 16 | // 22.10.13 Fixes for Kinetis Board - 8 bit spi |
dreschpe | 0:da1bf437cbc1 | 17 | |
dreschpe | 0:da1bf437cbc1 | 18 | #include "SPI_TFT_ILI9341.h" |
dreschpe | 0:da1bf437cbc1 | 19 | #include "mbed.h" |
dreschpe | 0:da1bf437cbc1 | 20 | |
info@bausano.net | 12:1cf4e83eb240 | 21 | |
info@bausano.net | 12:1cf4e83eb240 | 22 | //#ifdef PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 23 | SPI_TFT_ILI9341::SPI_TFT_ILI9341(PinName TFT_D0, PinName TFT_D1, PinName TFT_D2, PinName TFT_D3, |
info@bausano.net | 12:1cf4e83eb240 | 24 | PinName TFT_D4, PinName TFT_D5, PinName TFT_D6, PinName TFT_D7, PinName rd, PinName wr, |
info@bausano.net | 12:1cf4e83eb240 | 25 | PinName cs, PinName dc, PinName res, const char *name) : GraphicsDisplay(name), _cs(cs), _dc(dc), |
info@bausano.net | 12:1cf4e83eb240 | 26 | _TFT_D0(TFT_D0), |
info@bausano.net | 12:1cf4e83eb240 | 27 | _TFT_D1(TFT_D1), |
info@bausano.net | 12:1cf4e83eb240 | 28 | _TFT_D2(TFT_D2), |
info@bausano.net | 12:1cf4e83eb240 | 29 | _TFT_D3(TFT_D3), |
info@bausano.net | 12:1cf4e83eb240 | 30 | _TFT_D4(TFT_D4), |
info@bausano.net | 12:1cf4e83eb240 | 31 | _TFT_D5(TFT_D5), |
info@bausano.net | 12:1cf4e83eb240 | 32 | _TFT_D6(TFT_D6), |
info@bausano.net | 12:1cf4e83eb240 | 33 | _TFT_D7(TFT_D7), |
info@bausano.net | 12:1cf4e83eb240 | 34 | _rd(rd), |
info@bausano.net | 12:1cf4e83eb240 | 35 | _wr(wr), |
info@bausano.net | 12:1cf4e83eb240 | 36 | _res(res), |
info@bausano.net | 12:1cf4e83eb240 | 37 | _spi(D11, D12, D13) |
info@bausano.net | 12:1cf4e83eb240 | 38 | { |
info@bausano.net | 12:1cf4e83eb240 | 39 | iTypeTFT = PARA_TFT_; |
info@bausano.net | 12:1cf4e83eb240 | 40 | |
info@bausano.net | 12:1cf4e83eb240 | 41 | if(strcmp(name, "PARA") == 0) |
info@bausano.net | 12:1cf4e83eb240 | 42 | { |
info@bausano.net | 12:1cf4e83eb240 | 43 | iTypeTFT = PARA_TFT_; |
info@bausano.net | 12:1cf4e83eb240 | 44 | } |
info@bausano.net | 12:1cf4e83eb240 | 45 | |
info@bausano.net | 12:1cf4e83eb240 | 46 | orientation = 1; |
info@bausano.net | 12:1cf4e83eb240 | 47 | char_x = 0; |
info@bausano.net | 12:1cf4e83eb240 | 48 | char_x = 0; |
dreschpe | 0:da1bf437cbc1 | 49 | |
info@bausano.net | 12:1cf4e83eb240 | 50 | _TFT_D0 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 51 | _TFT_D1 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 52 | _TFT_D2 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 53 | _TFT_D3 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 54 | _TFT_D4 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 55 | _TFT_D5 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 56 | _TFT_D6 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 57 | _TFT_D7 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 58 | |
info@bausano.net | 12:1cf4e83eb240 | 59 | _rd = 1; |
info@bausano.net | 12:1cf4e83eb240 | 60 | _wr = 1; |
info@bausano.net | 12:1cf4e83eb240 | 61 | _cs = 1; |
info@bausano.net | 12:1cf4e83eb240 | 62 | _dc = 1; |
info@bausano.net | 12:1cf4e83eb240 | 63 | _res = 1; |
info@bausano.net | 12:1cf4e83eb240 | 64 | |
info@bausano.net | 12:1cf4e83eb240 | 65 | tft_reset(0); |
info@bausano.net | 12:1cf4e83eb240 | 66 | } |
dreschpe | 0:da1bf437cbc1 | 67 | |
info@bausano.net | 12:1cf4e83eb240 | 68 | //#else |
sulymarco | 9:2e5c5943b3fd | 69 | SPI_TFT_ILI9341::SPI_TFT_ILI9341(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset, PinName dc, int spiSpeed, const char *name) |
info@bausano.net | 12:1cf4e83eb240 | 70 | : GraphicsDisplay(name), _spi(mosi, miso, sclk), _cs(cs), _dc(dc), |
info@bausano.net | 12:1cf4e83eb240 | 71 | _TFT_D0(NC), |
info@bausano.net | 12:1cf4e83eb240 | 72 | _TFT_D1(NC), |
info@bausano.net | 12:1cf4e83eb240 | 73 | _TFT_D2(NC), |
info@bausano.net | 12:1cf4e83eb240 | 74 | _TFT_D3(NC), |
info@bausano.net | 12:1cf4e83eb240 | 75 | _TFT_D4(NC), |
info@bausano.net | 12:1cf4e83eb240 | 76 | _TFT_D5(NC), |
info@bausano.net | 12:1cf4e83eb240 | 77 | _TFT_D6(NC), |
info@bausano.net | 12:1cf4e83eb240 | 78 | _TFT_D7(NC), |
info@bausano.net | 12:1cf4e83eb240 | 79 | _rd(NC), |
info@bausano.net | 12:1cf4e83eb240 | 80 | _wr(NC), |
info@bausano.net | 12:1cf4e83eb240 | 81 | _res(NC) |
dreschpe | 0:da1bf437cbc1 | 82 | { |
info@bausano.net | 12:1cf4e83eb240 | 83 | if(strcmp(name, "SEEED") == 0) |
info@bausano.net | 12:1cf4e83eb240 | 84 | { |
info@bausano.net | 12:1cf4e83eb240 | 85 | iTypeTFT = SEEED_TFT_; |
info@bausano.net | 12:1cf4e83eb240 | 86 | } |
info@bausano.net | 12:1cf4e83eb240 | 87 | |
info@bausano.net | 12:1cf4e83eb240 | 88 | if(strcmp(name, "ADA") == 0) |
info@bausano.net | 12:1cf4e83eb240 | 89 | { |
info@bausano.net | 12:1cf4e83eb240 | 90 | iTypeTFT = ADA_TFT_; |
info@bausano.net | 12:1cf4e83eb240 | 91 | } |
info@bausano.net | 12:1cf4e83eb240 | 92 | |
dreschpe | 0:da1bf437cbc1 | 93 | orientation = 0; |
dreschpe | 0:da1bf437cbc1 | 94 | char_x = 0; |
info@bausano.net | 12:1cf4e83eb240 | 95 | char_x = 0; |
info@bausano.net | 12:1cf4e83eb240 | 96 | |
info@bausano.net | 12:1cf4e83eb240 | 97 | _cs = 1; |
info@bausano.net | 12:1cf4e83eb240 | 98 | _dc = 1; |
info@bausano.net | 12:1cf4e83eb240 | 99 | |
mazgch | 5:93cc09de603a | 100 | _reset = reset; |
sulymarco | 9:2e5c5943b3fd | 101 | tft_reset(spiSpeed); |
dreschpe | 0:da1bf437cbc1 | 102 | } |
info@bausano.net | 12:1cf4e83eb240 | 103 | //#endif |
info@bausano.net | 12:1cf4e83eb240 | 104 | |
dreschpe | 0:da1bf437cbc1 | 105 | |
dreschpe | 0:da1bf437cbc1 | 106 | int SPI_TFT_ILI9341::width() |
dreschpe | 0:da1bf437cbc1 | 107 | { |
dreschpe | 0:da1bf437cbc1 | 108 | if (orientation == 0 || orientation == 2) return 240; |
dreschpe | 0:da1bf437cbc1 | 109 | else return 320; |
dreschpe | 0:da1bf437cbc1 | 110 | } |
dreschpe | 0:da1bf437cbc1 | 111 | |
dreschpe | 0:da1bf437cbc1 | 112 | |
dreschpe | 0:da1bf437cbc1 | 113 | int SPI_TFT_ILI9341::height() |
dreschpe | 0:da1bf437cbc1 | 114 | { |
dreschpe | 0:da1bf437cbc1 | 115 | if (orientation == 0 || orientation == 2) return 320; |
dreschpe | 0:da1bf437cbc1 | 116 | else return 240; |
dreschpe | 0:da1bf437cbc1 | 117 | } |
dreschpe | 0:da1bf437cbc1 | 118 | |
dreschpe | 0:da1bf437cbc1 | 119 | |
dreschpe | 2:0a16083193a4 | 120 | void SPI_TFT_ILI9341::set_orientation(unsigned int o) |
dreschpe | 0:da1bf437cbc1 | 121 | { |
dreschpe | 0:da1bf437cbc1 | 122 | orientation = o; |
info@bausano.net | 12:1cf4e83eb240 | 123 | wr_cmd(0x36); // memory acces control |
info@bausano.net | 12:1cf4e83eb240 | 124 | switch (orientation) |
info@bausano.net | 12:1cf4e83eb240 | 125 | { |
dreschpe | 0:da1bf437cbc1 | 126 | case 0: |
info@bausano.net | 12:1cf4e83eb240 | 127 | wr_dat(0x48); |
dreschpe | 0:da1bf437cbc1 | 128 | break; |
dreschpe | 0:da1bf437cbc1 | 129 | case 1: |
info@bausano.net | 12:1cf4e83eb240 | 130 | wr_dat(0x28); |
dreschpe | 0:da1bf437cbc1 | 131 | break; |
dreschpe | 0:da1bf437cbc1 | 132 | case 2: |
info@bausano.net | 12:1cf4e83eb240 | 133 | wr_dat(0x88); |
dreschpe | 0:da1bf437cbc1 | 134 | break; |
dreschpe | 0:da1bf437cbc1 | 135 | case 3: |
info@bausano.net | 12:1cf4e83eb240 | 136 | wr_dat(0xE8); |
dreschpe | 0:da1bf437cbc1 | 137 | break; |
dreschpe | 0:da1bf437cbc1 | 138 | } |
dreschpe | 2:0a16083193a4 | 139 | _cs = 1; |
dreschpe | 0:da1bf437cbc1 | 140 | WindowMax(); |
dreschpe | 2:0a16083193a4 | 141 | } |
dreschpe | 0:da1bf437cbc1 | 142 | |
dreschpe | 0:da1bf437cbc1 | 143 | |
info@bausano.net | 12:1cf4e83eb240 | 144 | void SPI_TFT_ILI9341::wr_cmd(unsigned char cmd) // write command to tft register |
dreschpe | 0:da1bf437cbc1 | 145 | { |
dreschpe | 0:da1bf437cbc1 | 146 | _dc = 0; |
dreschpe | 0:da1bf437cbc1 | 147 | _cs = 0; |
info@bausano.net | 12:1cf4e83eb240 | 148 | wr_dat(cmd); |
dreschpe | 0:da1bf437cbc1 | 149 | _dc = 1; |
dreschpe | 0:da1bf437cbc1 | 150 | } |
dreschpe | 0:da1bf437cbc1 | 151 | |
dreschpe | 0:da1bf437cbc1 | 152 | |
dreschpe | 0:da1bf437cbc1 | 153 | void SPI_TFT_ILI9341::wr_dat(unsigned char dat) |
dreschpe | 0:da1bf437cbc1 | 154 | { |
info@bausano.net | 12:1cf4e83eb240 | 155 | if (iTypeTFT == PARA_TFT_) //PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 156 | { |
info@bausano.net | 12:1cf4e83eb240 | 157 | if (dat & 0x01) |
info@bausano.net | 12:1cf4e83eb240 | 158 | _TFT_D0 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 159 | else |
info@bausano.net | 12:1cf4e83eb240 | 160 | _TFT_D0 = 0; |
info@bausano.net | 12:1cf4e83eb240 | 161 | |
info@bausano.net | 12:1cf4e83eb240 | 162 | if (dat & 0x02) |
info@bausano.net | 12:1cf4e83eb240 | 163 | _TFT_D1 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 164 | else |
info@bausano.net | 12:1cf4e83eb240 | 165 | _TFT_D1 = 0; |
info@bausano.net | 12:1cf4e83eb240 | 166 | |
info@bausano.net | 12:1cf4e83eb240 | 167 | if (dat & 0x04) |
info@bausano.net | 12:1cf4e83eb240 | 168 | _TFT_D2 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 169 | else |
info@bausano.net | 12:1cf4e83eb240 | 170 | _TFT_D2 = 0; |
info@bausano.net | 12:1cf4e83eb240 | 171 | |
info@bausano.net | 12:1cf4e83eb240 | 172 | if (dat & 0x08) |
info@bausano.net | 12:1cf4e83eb240 | 173 | _TFT_D3 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 174 | else |
info@bausano.net | 12:1cf4e83eb240 | 175 | _TFT_D3 = 0; |
info@bausano.net | 12:1cf4e83eb240 | 176 | |
info@bausano.net | 12:1cf4e83eb240 | 177 | if (dat & 0x10) |
info@bausano.net | 12:1cf4e83eb240 | 178 | _TFT_D4 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 179 | else |
info@bausano.net | 12:1cf4e83eb240 | 180 | _TFT_D4 = 0; |
info@bausano.net | 12:1cf4e83eb240 | 181 | |
info@bausano.net | 12:1cf4e83eb240 | 182 | if (dat & 0x20) |
info@bausano.net | 12:1cf4e83eb240 | 183 | _TFT_D5 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 184 | else |
info@bausano.net | 12:1cf4e83eb240 | 185 | _TFT_D5 = 0; |
info@bausano.net | 12:1cf4e83eb240 | 186 | |
info@bausano.net | 12:1cf4e83eb240 | 187 | if (dat & 0x40) |
info@bausano.net | 12:1cf4e83eb240 | 188 | _TFT_D6 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 189 | else |
info@bausano.net | 12:1cf4e83eb240 | 190 | _TFT_D6 = 0; |
info@bausano.net | 12:1cf4e83eb240 | 191 | |
info@bausano.net | 12:1cf4e83eb240 | 192 | if (dat & 0x80) |
info@bausano.net | 12:1cf4e83eb240 | 193 | _TFT_D7 = 1; |
info@bausano.net | 12:1cf4e83eb240 | 194 | else |
info@bausano.net | 12:1cf4e83eb240 | 195 | _TFT_D7 = 0; |
info@bausano.net | 12:1cf4e83eb240 | 196 | |
info@bausano.net | 12:1cf4e83eb240 | 197 | _wr = 0; |
info@bausano.net | 12:1cf4e83eb240 | 198 | _wr = 1; |
info@bausano.net | 12:1cf4e83eb240 | 199 | } |
info@bausano.net | 12:1cf4e83eb240 | 200 | else |
info@bausano.net | 12:1cf4e83eb240 | 201 | { |
info@bausano.net | 12:1cf4e83eb240 | 202 | _spi.write(dat); // mbed lib |
info@bausano.net | 12:1cf4e83eb240 | 203 | } |
info@bausano.net | 12:1cf4e83eb240 | 204 | |
dreschpe | 0:da1bf437cbc1 | 205 | } |
dreschpe | 0:da1bf437cbc1 | 206 | |
dreschpe | 0:da1bf437cbc1 | 207 | |
info@bausano.net | 12:1cf4e83eb240 | 208 | void SPI_TFT_ILI9341::tft_reset(int spiSpeed) // Init TFT |
dreschpe | 0:da1bf437cbc1 | 209 | { |
info@bausano.net | 12:1cf4e83eb240 | 210 | if (iTypeTFT == PARA_TFT_) //PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 211 | { |
info@bausano.net | 12:1cf4e83eb240 | 212 | _res = 0; // display hw reset |
info@bausano.net | 12:1cf4e83eb240 | 213 | wait_us(50); // |
info@bausano.net | 12:1cf4e83eb240 | 214 | _res = 1; // |
mazgch | 5:93cc09de603a | 215 | } |
info@bausano.net | 12:1cf4e83eb240 | 216 | else |
info@bausano.net | 12:1cf4e83eb240 | 217 | { |
info@bausano.net | 12:1cf4e83eb240 | 218 | _spi.format(8,0); // 8 bit spi mode 0 |
info@bausano.net | 12:1cf4e83eb240 | 219 | _spi.frequency(spiSpeed); // SPI clock |
info@bausano.net | 12:1cf4e83eb240 | 220 | if (_reset != NC) |
info@bausano.net | 12:1cf4e83eb240 | 221 | { |
info@bausano.net | 12:1cf4e83eb240 | 222 | DigitalOut _res(_reset); |
info@bausano.net | 12:1cf4e83eb240 | 223 | _res = 0; // display hw reset |
info@bausano.net | 12:1cf4e83eb240 | 224 | wait_us(50); |
info@bausano.net | 12:1cf4e83eb240 | 225 | _res = 1; // |
info@bausano.net | 12:1cf4e83eb240 | 226 | } |
info@bausano.net | 12:1cf4e83eb240 | 227 | } |
info@bausano.net | 12:1cf4e83eb240 | 228 | |
info@bausano.net | 12:1cf4e83eb240 | 229 | ThisThread::sleep_for(5ms); |
info@bausano.net | 12:1cf4e83eb240 | 230 | wr_cmd(0x01); // SW reset |
info@bausano.net | 12:1cf4e83eb240 | 231 | ThisThread::sleep_for(5ms); |
info@bausano.net | 12:1cf4e83eb240 | 232 | wr_cmd(0x28); // display off |
dreschpe | 0:da1bf437cbc1 | 233 | |
dreschpe | 0:da1bf437cbc1 | 234 | /* Start Initial Sequence ----------------------------------------------------*/ |
dreschpe | 1:6d6125e88de7 | 235 | wr_cmd(0xCF); |
info@bausano.net | 12:1cf4e83eb240 | 236 | wr_dat(0x00); |
info@bausano.net | 12:1cf4e83eb240 | 237 | wr_dat(0x83); |
info@bausano.net | 12:1cf4e83eb240 | 238 | wr_dat(0x30); |
dreschpe | 1:6d6125e88de7 | 239 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 240 | |
dreschpe | 1:6d6125e88de7 | 241 | wr_cmd(0xED); |
info@bausano.net | 12:1cf4e83eb240 | 242 | wr_dat(0x64); |
info@bausano.net | 12:1cf4e83eb240 | 243 | wr_dat(0x03); |
info@bausano.net | 12:1cf4e83eb240 | 244 | wr_dat(0x12); |
info@bausano.net | 12:1cf4e83eb240 | 245 | wr_dat(0x81); |
dreschpe | 1:6d6125e88de7 | 246 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 247 | |
dreschpe | 1:6d6125e88de7 | 248 | wr_cmd(0xE8); |
info@bausano.net | 12:1cf4e83eb240 | 249 | wr_dat(0x85); |
info@bausano.net | 12:1cf4e83eb240 | 250 | wr_dat(0x01); |
info@bausano.net | 12:1cf4e83eb240 | 251 | wr_dat(0x79); |
dreschpe | 1:6d6125e88de7 | 252 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 253 | |
dreschpe | 1:6d6125e88de7 | 254 | wr_cmd(0xCB); |
info@bausano.net | 12:1cf4e83eb240 | 255 | wr_dat(0x39); |
info@bausano.net | 12:1cf4e83eb240 | 256 | wr_dat(0x2C); |
info@bausano.net | 12:1cf4e83eb240 | 257 | wr_dat(0x00); |
info@bausano.net | 12:1cf4e83eb240 | 258 | wr_dat(0x34); |
info@bausano.net | 12:1cf4e83eb240 | 259 | wr_dat(0x02); |
dreschpe | 0:da1bf437cbc1 | 260 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 261 | |
dreschpe | 1:6d6125e88de7 | 262 | wr_cmd(0xF7); |
info@bausano.net | 12:1cf4e83eb240 | 263 | wr_dat(0x20); |
dreschpe | 0:da1bf437cbc1 | 264 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 265 | |
dreschpe | 1:6d6125e88de7 | 266 | wr_cmd(0xEA); |
info@bausano.net | 12:1cf4e83eb240 | 267 | wr_dat(0x00); |
info@bausano.net | 12:1cf4e83eb240 | 268 | wr_dat(0x00); |
dreschpe | 0:da1bf437cbc1 | 269 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 270 | |
dreschpe | 0:da1bf437cbc1 | 271 | wr_cmd(0xC0); // POWER_CONTROL_1 |
info@bausano.net | 12:1cf4e83eb240 | 272 | wr_dat(0x26); |
dreschpe | 0:da1bf437cbc1 | 273 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 274 | |
dreschpe | 0:da1bf437cbc1 | 275 | wr_cmd(0xC1); // POWER_CONTROL_2 |
info@bausano.net | 12:1cf4e83eb240 | 276 | wr_dat(0x11); |
dreschpe | 0:da1bf437cbc1 | 277 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 278 | |
dreschpe | 0:da1bf437cbc1 | 279 | wr_cmd(0xC5); // VCOM_CONTROL_1 |
info@bausano.net | 12:1cf4e83eb240 | 280 | wr_dat(0x35); |
info@bausano.net | 12:1cf4e83eb240 | 281 | wr_dat(0x3E); |
dreschpe | 0:da1bf437cbc1 | 282 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 283 | |
dreschpe | 0:da1bf437cbc1 | 284 | wr_cmd(0xC7); // VCOM_CONTROL_2 |
info@bausano.net | 12:1cf4e83eb240 | 285 | wr_dat(0xBE); |
dreschpe | 0:da1bf437cbc1 | 286 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 287 | |
dreschpe | 0:da1bf437cbc1 | 288 | wr_cmd(0x36); // MEMORY_ACCESS_CONTROL |
info@bausano.net | 12:1cf4e83eb240 | 289 | wr_dat(0x48); |
info@bausano.net | 12:1cf4e83eb240 | 290 | |
info@bausano.net | 12:1cf4e83eb240 | 291 | wr_dat(0xC8); |
info@bausano.net | 12:1cf4e83eb240 | 292 | |
dreschpe | 0:da1bf437cbc1 | 293 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 294 | |
dreschpe | 1:6d6125e88de7 | 295 | wr_cmd(0x3A); // COLMOD_PIXEL_FORMAT_SET |
info@bausano.net | 12:1cf4e83eb240 | 296 | wr_dat(0x55); // 16 bit pixel |
dreschpe | 1:6d6125e88de7 | 297 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 298 | |
dreschpe | 1:6d6125e88de7 | 299 | wr_cmd(0xB1); // Frame Rate |
info@bausano.net | 12:1cf4e83eb240 | 300 | wr_dat(0x00); |
info@bausano.net | 12:1cf4e83eb240 | 301 | wr_dat(0x1B); |
dreschpe | 1:6d6125e88de7 | 302 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 303 | |
dreschpe | 1:6d6125e88de7 | 304 | wr_cmd(0xF2); // Gamma Function Disable |
info@bausano.net | 12:1cf4e83eb240 | 305 | wr_dat(0x08); |
dreschpe | 1:6d6125e88de7 | 306 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 307 | |
dreschpe | 1:6d6125e88de7 | 308 | wr_cmd(0x26); |
info@bausano.net | 12:1cf4e83eb240 | 309 | wr_dat(0x01); // gamma set for curve 01/2/04/08 |
dreschpe | 1:6d6125e88de7 | 310 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 311 | |
dreschpe | 1:6d6125e88de7 | 312 | wr_cmd(0xE0); // positive gamma correction |
info@bausano.net | 12:1cf4e83eb240 | 313 | wr_dat(0x1F); |
info@bausano.net | 12:1cf4e83eb240 | 314 | wr_dat(0x1A); |
info@bausano.net | 12:1cf4e83eb240 | 315 | wr_dat(0x18); |
info@bausano.net | 12:1cf4e83eb240 | 316 | wr_dat(0x0A); |
info@bausano.net | 12:1cf4e83eb240 | 317 | wr_dat(0x0F); |
info@bausano.net | 12:1cf4e83eb240 | 318 | wr_dat(0x06); |
info@bausano.net | 12:1cf4e83eb240 | 319 | wr_dat(0x45); |
info@bausano.net | 12:1cf4e83eb240 | 320 | wr_dat(0x87); |
info@bausano.net | 12:1cf4e83eb240 | 321 | wr_dat(0x32); |
info@bausano.net | 12:1cf4e83eb240 | 322 | wr_dat(0x0A); |
info@bausano.net | 12:1cf4e83eb240 | 323 | wr_dat(0x07); |
info@bausano.net | 12:1cf4e83eb240 | 324 | wr_dat(0x02); |
info@bausano.net | 12:1cf4e83eb240 | 325 | wr_dat(0x07); |
info@bausano.net | 12:1cf4e83eb240 | 326 | wr_dat(0x05); |
info@bausano.net | 12:1cf4e83eb240 | 327 | wr_dat(0x00); |
dreschpe | 1:6d6125e88de7 | 328 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 329 | |
dreschpe | 1:6d6125e88de7 | 330 | wr_cmd(0xE1); // negativ gamma correction |
info@bausano.net | 12:1cf4e83eb240 | 331 | wr_dat(0x00); |
info@bausano.net | 12:1cf4e83eb240 | 332 | wr_dat(0x25); |
info@bausano.net | 12:1cf4e83eb240 | 333 | wr_dat(0x27); |
info@bausano.net | 12:1cf4e83eb240 | 334 | wr_dat(0x05); |
info@bausano.net | 12:1cf4e83eb240 | 335 | wr_dat(0x10); |
info@bausano.net | 12:1cf4e83eb240 | 336 | wr_dat(0x09); |
info@bausano.net | 12:1cf4e83eb240 | 337 | wr_dat(0x3A); |
info@bausano.net | 12:1cf4e83eb240 | 338 | wr_dat(0x78); |
info@bausano.net | 12:1cf4e83eb240 | 339 | wr_dat(0x4D); |
info@bausano.net | 12:1cf4e83eb240 | 340 | wr_dat(0x05); |
info@bausano.net | 12:1cf4e83eb240 | 341 | wr_dat(0x18); |
info@bausano.net | 12:1cf4e83eb240 | 342 | wr_dat(0x0D); |
info@bausano.net | 12:1cf4e83eb240 | 343 | wr_dat(0x38); |
info@bausano.net | 12:1cf4e83eb240 | 344 | wr_dat(0x3A); |
info@bausano.net | 12:1cf4e83eb240 | 345 | wr_dat(0x1F); |
dreschpe | 1:6d6125e88de7 | 346 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 347 | |
dreschpe | 1:6d6125e88de7 | 348 | WindowMax (); |
dreschpe | 1:6d6125e88de7 | 349 | |
dreschpe | 1:6d6125e88de7 | 350 | //wr_cmd(0x34); // tearing effect off |
dreschpe | 1:6d6125e88de7 | 351 | //_cs = 1; |
dreschpe | 1:6d6125e88de7 | 352 | |
dreschpe | 1:6d6125e88de7 | 353 | //wr_cmd(0x35); // tearing effect on |
dreschpe | 1:6d6125e88de7 | 354 | //_cs = 1; |
dreschpe | 1:6d6125e88de7 | 355 | |
dreschpe | 1:6d6125e88de7 | 356 | wr_cmd(0xB7); // entry mode |
info@bausano.net | 12:1cf4e83eb240 | 357 | wr_dat(0x07); |
dreschpe | 1:6d6125e88de7 | 358 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 359 | |
dreschpe | 1:6d6125e88de7 | 360 | wr_cmd(0xB6); // display function control |
info@bausano.net | 12:1cf4e83eb240 | 361 | wr_dat(0x0A); |
info@bausano.net | 12:1cf4e83eb240 | 362 | wr_dat(0x82); |
info@bausano.net | 12:1cf4e83eb240 | 363 | wr_dat(0x27); |
info@bausano.net | 12:1cf4e83eb240 | 364 | wr_dat(0x00); |
dreschpe | 1:6d6125e88de7 | 365 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 366 | |
dreschpe | 1:6d6125e88de7 | 367 | wr_cmd(0x11); // sleep out |
dreschpe | 1:6d6125e88de7 | 368 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 369 | |
info@bausano.net | 12:1cf4e83eb240 | 370 | ThisThread::sleep_for(100ms); |
info@bausano.net | 12:1cf4e83eb240 | 371 | |
info@bausano.net | 12:1cf4e83eb240 | 372 | wr_cmd(0x29); // display on |
info@bausano.net | 12:1cf4e83eb240 | 373 | _cs = 1; |
dreschpe | 1:6d6125e88de7 | 374 | |
info@bausano.net | 12:1cf4e83eb240 | 375 | ThisThread::sleep_for(100ms); |
dreschpe | 1:6d6125e88de7 | 376 | } |
dreschpe | 0:da1bf437cbc1 | 377 | |
dreschpe | 0:da1bf437cbc1 | 378 | |
dreschpe | 0:da1bf437cbc1 | 379 | void SPI_TFT_ILI9341::pixel(int x, int y, int color) |
dreschpe | 0:da1bf437cbc1 | 380 | { |
dreschpe | 0:da1bf437cbc1 | 381 | wr_cmd(0x2A); |
info@bausano.net | 12:1cf4e83eb240 | 382 | wr_dat(x >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 383 | wr_dat(x); |
dreschpe | 0:da1bf437cbc1 | 384 | _cs = 1; |
info@bausano.net | 12:1cf4e83eb240 | 385 | |
dreschpe | 0:da1bf437cbc1 | 386 | wr_cmd(0x2B); |
info@bausano.net | 12:1cf4e83eb240 | 387 | wr_dat(y >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 388 | wr_dat(y); |
dreschpe | 0:da1bf437cbc1 | 389 | _cs = 1; |
info@bausano.net | 12:1cf4e83eb240 | 390 | |
info@bausano.net | 12:1cf4e83eb240 | 391 | wr_cmd(0x2C); // send pixel |
info@bausano.net | 12:1cf4e83eb240 | 392 | |
info@bausano.net | 12:1cf4e83eb240 | 393 | if (iTypeTFT == PARA_TFT_) //PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 394 | { |
info@bausano.net | 12:1cf4e83eb240 | 395 | wr_dat(color >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 396 | wr_dat(color & 0xff); |
info@bausano.net | 12:1cf4e83eb240 | 397 | |
info@bausano.net | 12:1cf4e83eb240 | 398 | } |
info@bausano.net | 12:1cf4e83eb240 | 399 | else |
info@bausano.net | 12:1cf4e83eb240 | 400 | { // 16 bit SPI transfer |
info@bausano.net | 12:1cf4e83eb240 | 401 | _spi.format(16,0); |
info@bausano.net | 12:1cf4e83eb240 | 402 | _spi.write(color); |
info@bausano.net | 12:1cf4e83eb240 | 403 | _spi.format(8,0); |
info@bausano.net | 12:1cf4e83eb240 | 404 | } |
info@bausano.net | 12:1cf4e83eb240 | 405 | |
dreschpe | 0:da1bf437cbc1 | 406 | _cs = 1; |
dreschpe | 0:da1bf437cbc1 | 407 | } |
dreschpe | 0:da1bf437cbc1 | 408 | |
dreschpe | 0:da1bf437cbc1 | 409 | |
dreschpe | 0:da1bf437cbc1 | 410 | void SPI_TFT_ILI9341::window (unsigned int x, unsigned int y, unsigned int w, unsigned int h) |
dreschpe | 0:da1bf437cbc1 | 411 | { |
dreschpe | 0:da1bf437cbc1 | 412 | wr_cmd(0x2A); |
info@bausano.net | 12:1cf4e83eb240 | 413 | wr_dat(x >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 414 | wr_dat(x); |
info@bausano.net | 12:1cf4e83eb240 | 415 | wr_dat((x+w-1) >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 416 | wr_dat(x+w-1); |
dreschpe | 0:da1bf437cbc1 | 417 | _cs = 1; |
info@bausano.net | 12:1cf4e83eb240 | 418 | |
dreschpe | 0:da1bf437cbc1 | 419 | wr_cmd(0x2B); |
info@bausano.net | 12:1cf4e83eb240 | 420 | wr_dat(y >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 421 | wr_dat(y); |
info@bausano.net | 12:1cf4e83eb240 | 422 | wr_dat((y+h-1) >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 423 | wr_dat(y+h-1); |
dreschpe | 0:da1bf437cbc1 | 424 | _cs = 1; |
dreschpe | 0:da1bf437cbc1 | 425 | } |
dreschpe | 0:da1bf437cbc1 | 426 | |
dreschpe | 0:da1bf437cbc1 | 427 | |
dreschpe | 0:da1bf437cbc1 | 428 | void SPI_TFT_ILI9341::WindowMax (void) |
dreschpe | 0:da1bf437cbc1 | 429 | { |
dreschpe | 0:da1bf437cbc1 | 430 | window (0, 0, width(), height()); |
dreschpe | 0:da1bf437cbc1 | 431 | } |
dreschpe | 0:da1bf437cbc1 | 432 | |
dreschpe | 0:da1bf437cbc1 | 433 | |
dreschpe | 0:da1bf437cbc1 | 434 | void SPI_TFT_ILI9341::cls (void) |
dreschpe | 0:da1bf437cbc1 | 435 | { |
dreschpe | 0:da1bf437cbc1 | 436 | int pixel = ( width() * height()); |
dreschpe | 0:da1bf437cbc1 | 437 | WindowMax(); |
info@bausano.net | 12:1cf4e83eb240 | 438 | wr_cmd(0x2C); // send pixel |
info@bausano.net | 12:1cf4e83eb240 | 439 | |
info@bausano.net | 12:1cf4e83eb240 | 440 | if (iTypeTFT == PARA_TFT_) //PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 441 | { |
info@bausano.net | 12:1cf4e83eb240 | 442 | unsigned int i; |
info@bausano.net | 12:1cf4e83eb240 | 443 | for (i = 0; i < ( width() * height()); i++) |
info@bausano.net | 12:1cf4e83eb240 | 444 | { |
info@bausano.net | 12:1cf4e83eb240 | 445 | wr_dat(_background >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 446 | wr_dat(_background & 0xff); |
dreschpe | 6:55aed13f2630 | 447 | } |
info@bausano.net | 12:1cf4e83eb240 | 448 | } |
info@bausano.net | 12:1cf4e83eb240 | 449 | else |
info@bausano.net | 12:1cf4e83eb240 | 450 | { // 16 bit SPI transfer |
info@bausano.net | 12:1cf4e83eb240 | 451 | _spi.format(16,0); |
info@bausano.net | 12:1cf4e83eb240 | 452 | unsigned int i; |
info@bausano.net | 12:1cf4e83eb240 | 453 | for (i = 0; i < ( width() * height()); i++) |
info@bausano.net | 12:1cf4e83eb240 | 454 | _spi.write(_background); |
info@bausano.net | 12:1cf4e83eb240 | 455 | _spi.format(8,0); |
info@bausano.net | 12:1cf4e83eb240 | 456 | } |
info@bausano.net | 12:1cf4e83eb240 | 457 | |
dreschpe | 6:55aed13f2630 | 458 | _cs = 1; |
dreschpe | 0:da1bf437cbc1 | 459 | } |
dreschpe | 0:da1bf437cbc1 | 460 | |
dreschpe | 0:da1bf437cbc1 | 461 | |
dreschpe | 0:da1bf437cbc1 | 462 | void SPI_TFT_ILI9341::circle(int x0, int y0, int r, int color) |
dreschpe | 0:da1bf437cbc1 | 463 | { |
dreschpe | 0:da1bf437cbc1 | 464 | |
mazgch | 3:3d7298360e45 | 465 | int x = -r, y = 0, err = 2-2*r, e2; |
mazgch | 3:3d7298360e45 | 466 | do { |
mazgch | 3:3d7298360e45 | 467 | pixel(x0-x, y0+y,color); |
mazgch | 3:3d7298360e45 | 468 | pixel(x0+x, y0+y,color); |
mazgch | 3:3d7298360e45 | 469 | pixel(x0+x, y0-y,color); |
mazgch | 3:3d7298360e45 | 470 | pixel(x0-x, y0-y,color); |
mazgch | 3:3d7298360e45 | 471 | e2 = err; |
mazgch | 3:3d7298360e45 | 472 | if (e2 <= y) { |
mazgch | 3:3d7298360e45 | 473 | err += ++y*2+1; |
mazgch | 3:3d7298360e45 | 474 | if (-x == y && e2 <= x) e2 = 0; |
mazgch | 3:3d7298360e45 | 475 | } |
mazgch | 3:3d7298360e45 | 476 | if (e2 > x) err += ++x*2+1; |
mazgch | 3:3d7298360e45 | 477 | } while (x <= 0); |
dreschpe | 0:da1bf437cbc1 | 478 | } |
dreschpe | 0:da1bf437cbc1 | 479 | |
mazgch | 3:3d7298360e45 | 480 | void SPI_TFT_ILI9341::fillcircle(int x0, int y0, int r, int color) |
dreschpe | 0:da1bf437cbc1 | 481 | { |
mazgch | 3:3d7298360e45 | 482 | int x = -r, y = 0, err = 2-2*r, e2; |
mazgch | 3:3d7298360e45 | 483 | do { |
mazgch | 3:3d7298360e45 | 484 | vline(x0-x, y0-y, y0+y, color); |
mazgch | 3:3d7298360e45 | 485 | vline(x0+x, y0-y, y0+y, color); |
mazgch | 3:3d7298360e45 | 486 | e2 = err; |
mazgch | 3:3d7298360e45 | 487 | if (e2 <= y) { |
mazgch | 3:3d7298360e45 | 488 | err += ++y*2+1; |
mazgch | 3:3d7298360e45 | 489 | if (-x == y && e2 <= x) e2 = 0; |
mazgch | 3:3d7298360e45 | 490 | } |
mazgch | 3:3d7298360e45 | 491 | if (e2 > x) err += ++x*2+1; |
mazgch | 3:3d7298360e45 | 492 | } while (x <= 0); |
dreschpe | 0:da1bf437cbc1 | 493 | } |
dreschpe | 0:da1bf437cbc1 | 494 | |
dreschpe | 0:da1bf437cbc1 | 495 | |
dreschpe | 0:da1bf437cbc1 | 496 | void SPI_TFT_ILI9341::hline(int x0, int x1, int y, int color) |
dreschpe | 0:da1bf437cbc1 | 497 | { |
dreschpe | 0:da1bf437cbc1 | 498 | int w; |
dreschpe | 0:da1bf437cbc1 | 499 | w = x1 - x0 + 1; |
dreschpe | 0:da1bf437cbc1 | 500 | window(x0,y,w,1); |
dreschpe | 6:55aed13f2630 | 501 | wr_cmd(0x2C); // send pixel |
info@bausano.net | 12:1cf4e83eb240 | 502 | |
info@bausano.net | 12:1cf4e83eb240 | 503 | if (iTypeTFT == PARA_TFT_) //PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 504 | { |
info@bausano.net | 12:1cf4e83eb240 | 505 | int j; |
info@bausano.net | 12:1cf4e83eb240 | 506 | for (j=0; j<w; j++) |
info@bausano.net | 12:1cf4e83eb240 | 507 | { |
info@bausano.net | 12:1cf4e83eb240 | 508 | wr_dat(color >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 509 | wr_dat(color & 0xff); |
info@bausano.net | 12:1cf4e83eb240 | 510 | } |
info@bausano.net | 12:1cf4e83eb240 | 511 | |
info@bausano.net | 12:1cf4e83eb240 | 512 | } |
info@bausano.net | 12:1cf4e83eb240 | 513 | else |
info@bausano.net | 12:1cf4e83eb240 | 514 | { // 16 bit SPI transfer |
info@bausano.net | 12:1cf4e83eb240 | 515 | _spi.format(16,0); |
info@bausano.net | 12:1cf4e83eb240 | 516 | int j; |
info@bausano.net | 12:1cf4e83eb240 | 517 | for (j=0; j<w; j++) |
info@bausano.net | 12:1cf4e83eb240 | 518 | { |
info@bausano.net | 12:1cf4e83eb240 | 519 | _spi.write(color); |
info@bausano.net | 12:1cf4e83eb240 | 520 | } |
info@bausano.net | 12:1cf4e83eb240 | 521 | _spi.format(8,0); |
dreschpe | 6:55aed13f2630 | 522 | } |
dreschpe | 0:da1bf437cbc1 | 523 | _cs = 1; |
info@bausano.net | 12:1cf4e83eb240 | 524 | |
dreschpe | 0:da1bf437cbc1 | 525 | WindowMax(); |
dreschpe | 0:da1bf437cbc1 | 526 | return; |
dreschpe | 0:da1bf437cbc1 | 527 | } |
dreschpe | 0:da1bf437cbc1 | 528 | |
info@bausano.net | 12:1cf4e83eb240 | 529 | |
dreschpe | 0:da1bf437cbc1 | 530 | void SPI_TFT_ILI9341::vline(int x, int y0, int y1, int color) |
dreschpe | 0:da1bf437cbc1 | 531 | { |
dreschpe | 0:da1bf437cbc1 | 532 | int h; |
dreschpe | 0:da1bf437cbc1 | 533 | h = y1 - y0 + 1; |
dreschpe | 0:da1bf437cbc1 | 534 | window(x,y0,1,h); |
dreschpe | 6:55aed13f2630 | 535 | wr_cmd(0x2C); // send pixel |
info@bausano.net | 12:1cf4e83eb240 | 536 | |
info@bausano.net | 12:1cf4e83eb240 | 537 | if (iTypeTFT == PARA_TFT_) //PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 538 | { |
info@bausano.net | 12:1cf4e83eb240 | 539 | for (int y=0; y<h; y++) |
info@bausano.net | 12:1cf4e83eb240 | 540 | { |
info@bausano.net | 12:1cf4e83eb240 | 541 | wr_dat(color >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 542 | wr_dat(color & 0xff); |
info@bausano.net | 12:1cf4e83eb240 | 543 | } |
dreschpe | 0:da1bf437cbc1 | 544 | } |
info@bausano.net | 12:1cf4e83eb240 | 545 | else |
info@bausano.net | 12:1cf4e83eb240 | 546 | { // 16 bit SPI transfer |
info@bausano.net | 12:1cf4e83eb240 | 547 | _spi.format(16,0); |
info@bausano.net | 12:1cf4e83eb240 | 548 | for (int y=0; y<h; y++) |
info@bausano.net | 12:1cf4e83eb240 | 549 | { |
info@bausano.net | 12:1cf4e83eb240 | 550 | _spi.write(color); |
info@bausano.net | 12:1cf4e83eb240 | 551 | } |
info@bausano.net | 12:1cf4e83eb240 | 552 | _spi.format(8,0); |
info@bausano.net | 12:1cf4e83eb240 | 553 | } |
info@bausano.net | 12:1cf4e83eb240 | 554 | |
dreschpe | 0:da1bf437cbc1 | 555 | _cs = 1; |
info@bausano.net | 12:1cf4e83eb240 | 556 | |
dreschpe | 0:da1bf437cbc1 | 557 | WindowMax(); |
dreschpe | 0:da1bf437cbc1 | 558 | return; |
dreschpe | 0:da1bf437cbc1 | 559 | } |
dreschpe | 0:da1bf437cbc1 | 560 | |
dreschpe | 0:da1bf437cbc1 | 561 | |
dreschpe | 0:da1bf437cbc1 | 562 | void SPI_TFT_ILI9341::line(int x0, int y0, int x1, int y1, int color) |
dreschpe | 0:da1bf437cbc1 | 563 | { |
dreschpe | 0:da1bf437cbc1 | 564 | int dx = 0, dy = 0; |
dreschpe | 0:da1bf437cbc1 | 565 | int dx_sym = 0, dy_sym = 0; |
dreschpe | 0:da1bf437cbc1 | 566 | int dx_x2 = 0, dy_x2 = 0; |
dreschpe | 0:da1bf437cbc1 | 567 | int di = 0; |
dreschpe | 0:da1bf437cbc1 | 568 | |
dreschpe | 0:da1bf437cbc1 | 569 | dx = x1-x0; |
dreschpe | 0:da1bf437cbc1 | 570 | dy = y1-y0; |
dreschpe | 0:da1bf437cbc1 | 571 | |
info@bausano.net | 12:1cf4e83eb240 | 572 | if (dx == 0) // vertical line |
info@bausano.net | 12:1cf4e83eb240 | 573 | { |
dreschpe | 0:da1bf437cbc1 | 574 | if (y1 > y0) vline(x0,y0,y1,color); |
dreschpe | 0:da1bf437cbc1 | 575 | else vline(x0,y1,y0,color); |
dreschpe | 0:da1bf437cbc1 | 576 | return; |
dreschpe | 0:da1bf437cbc1 | 577 | } |
dreschpe | 0:da1bf437cbc1 | 578 | |
info@bausano.net | 12:1cf4e83eb240 | 579 | if (dx > 0) |
info@bausano.net | 12:1cf4e83eb240 | 580 | { |
dreschpe | 0:da1bf437cbc1 | 581 | dx_sym = 1; |
dreschpe | 0:da1bf437cbc1 | 582 | } else { |
dreschpe | 0:da1bf437cbc1 | 583 | dx_sym = -1; |
dreschpe | 0:da1bf437cbc1 | 584 | } |
info@bausano.net | 12:1cf4e83eb240 | 585 | if (dy == 0) // horizontal line |
info@bausano.net | 12:1cf4e83eb240 | 586 | { |
dreschpe | 0:da1bf437cbc1 | 587 | if (x1 > x0) hline(x0,x1,y0,color); |
dreschpe | 0:da1bf437cbc1 | 588 | else hline(x1,x0,y0,color); |
dreschpe | 0:da1bf437cbc1 | 589 | return; |
dreschpe | 0:da1bf437cbc1 | 590 | } |
dreschpe | 0:da1bf437cbc1 | 591 | |
info@bausano.net | 12:1cf4e83eb240 | 592 | if (dy > 0) |
info@bausano.net | 12:1cf4e83eb240 | 593 | { |
dreschpe | 0:da1bf437cbc1 | 594 | dy_sym = 1; |
info@bausano.net | 12:1cf4e83eb240 | 595 | } else |
info@bausano.net | 12:1cf4e83eb240 | 596 | { |
dreschpe | 0:da1bf437cbc1 | 597 | dy_sym = -1; |
dreschpe | 0:da1bf437cbc1 | 598 | } |
dreschpe | 0:da1bf437cbc1 | 599 | |
dreschpe | 0:da1bf437cbc1 | 600 | dx = dx_sym*dx; |
dreschpe | 0:da1bf437cbc1 | 601 | dy = dy_sym*dy; |
dreschpe | 0:da1bf437cbc1 | 602 | |
dreschpe | 0:da1bf437cbc1 | 603 | dx_x2 = dx*2; |
dreschpe | 0:da1bf437cbc1 | 604 | dy_x2 = dy*2; |
dreschpe | 0:da1bf437cbc1 | 605 | |
info@bausano.net | 12:1cf4e83eb240 | 606 | if (dx >= dy) |
info@bausano.net | 12:1cf4e83eb240 | 607 | { |
dreschpe | 0:da1bf437cbc1 | 608 | di = dy_x2 - dx; |
info@bausano.net | 12:1cf4e83eb240 | 609 | while (x0 != x1) |
info@bausano.net | 12:1cf4e83eb240 | 610 | { |
dreschpe | 0:da1bf437cbc1 | 611 | |
dreschpe | 0:da1bf437cbc1 | 612 | pixel(x0, y0, color); |
dreschpe | 0:da1bf437cbc1 | 613 | x0 += dx_sym; |
info@bausano.net | 12:1cf4e83eb240 | 614 | if (di<0) |
info@bausano.net | 12:1cf4e83eb240 | 615 | { |
dreschpe | 0:da1bf437cbc1 | 616 | di += dy_x2; |
info@bausano.net | 12:1cf4e83eb240 | 617 | } else |
info@bausano.net | 12:1cf4e83eb240 | 618 | { |
dreschpe | 0:da1bf437cbc1 | 619 | di += dy_x2 - dx_x2; |
dreschpe | 0:da1bf437cbc1 | 620 | y0 += dy_sym; |
dreschpe | 0:da1bf437cbc1 | 621 | } |
dreschpe | 0:da1bf437cbc1 | 622 | } |
dreschpe | 0:da1bf437cbc1 | 623 | pixel(x0, y0, color); |
info@bausano.net | 12:1cf4e83eb240 | 624 | } |
info@bausano.net | 12:1cf4e83eb240 | 625 | else |
info@bausano.net | 12:1cf4e83eb240 | 626 | { |
dreschpe | 0:da1bf437cbc1 | 627 | di = dx_x2 - dy; |
info@bausano.net | 12:1cf4e83eb240 | 628 | while (y0 != y1) |
info@bausano.net | 12:1cf4e83eb240 | 629 | { |
dreschpe | 0:da1bf437cbc1 | 630 | pixel(x0, y0, color); |
dreschpe | 0:da1bf437cbc1 | 631 | y0 += dy_sym; |
info@bausano.net | 12:1cf4e83eb240 | 632 | if (di < 0) |
info@bausano.net | 12:1cf4e83eb240 | 633 | { |
dreschpe | 0:da1bf437cbc1 | 634 | di += dx_x2; |
info@bausano.net | 12:1cf4e83eb240 | 635 | } else |
info@bausano.net | 12:1cf4e83eb240 | 636 | { |
dreschpe | 0:da1bf437cbc1 | 637 | di += dx_x2 - dy_x2; |
dreschpe | 0:da1bf437cbc1 | 638 | x0 += dx_sym; |
dreschpe | 0:da1bf437cbc1 | 639 | } |
dreschpe | 0:da1bf437cbc1 | 640 | } |
dreschpe | 0:da1bf437cbc1 | 641 | pixel(x0, y0, color); |
dreschpe | 0:da1bf437cbc1 | 642 | } |
dreschpe | 0:da1bf437cbc1 | 643 | return; |
dreschpe | 0:da1bf437cbc1 | 644 | } |
dreschpe | 0:da1bf437cbc1 | 645 | |
dreschpe | 0:da1bf437cbc1 | 646 | |
dreschpe | 0:da1bf437cbc1 | 647 | void SPI_TFT_ILI9341::rect(int x0, int y0, int x1, int y1, int color) |
dreschpe | 0:da1bf437cbc1 | 648 | { |
dreschpe | 0:da1bf437cbc1 | 649 | |
dreschpe | 0:da1bf437cbc1 | 650 | if (x1 > x0) hline(x0,x1,y0,color); |
dreschpe | 0:da1bf437cbc1 | 651 | else hline(x1,x0,y0,color); |
dreschpe | 0:da1bf437cbc1 | 652 | |
dreschpe | 0:da1bf437cbc1 | 653 | if (y1 > y0) vline(x0,y0,y1,color); |
dreschpe | 0:da1bf437cbc1 | 654 | else vline(x0,y1,y0,color); |
dreschpe | 0:da1bf437cbc1 | 655 | |
dreschpe | 0:da1bf437cbc1 | 656 | if (x1 > x0) hline(x0,x1,y1,color); |
dreschpe | 0:da1bf437cbc1 | 657 | else hline(x1,x0,y1,color); |
dreschpe | 0:da1bf437cbc1 | 658 | |
dreschpe | 0:da1bf437cbc1 | 659 | if (y1 > y0) vline(x1,y0,y1,color); |
dreschpe | 0:da1bf437cbc1 | 660 | else vline(x1,y1,y0,color); |
dreschpe | 0:da1bf437cbc1 | 661 | |
dreschpe | 0:da1bf437cbc1 | 662 | return; |
dreschpe | 0:da1bf437cbc1 | 663 | } |
dreschpe | 0:da1bf437cbc1 | 664 | |
dreschpe | 0:da1bf437cbc1 | 665 | |
dreschpe | 0:da1bf437cbc1 | 666 | void SPI_TFT_ILI9341::fillrect(int x0, int y0, int x1, int y1, int color) |
dreschpe | 0:da1bf437cbc1 | 667 | { |
dreschpe | 0:da1bf437cbc1 | 668 | |
dreschpe | 0:da1bf437cbc1 | 669 | int h = y1 - y0 + 1; |
dreschpe | 0:da1bf437cbc1 | 670 | int w = x1 - x0 + 1; |
dreschpe | 0:da1bf437cbc1 | 671 | int pixel = h * w; |
dreschpe | 0:da1bf437cbc1 | 672 | window(x0,y0,w,h); |
dreschpe | 0:da1bf437cbc1 | 673 | wr_cmd(0x2C); // send pixel |
info@bausano.net | 12:1cf4e83eb240 | 674 | if (iTypeTFT == PARA_TFT_) //PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 675 | { |
info@bausano.net | 12:1cf4e83eb240 | 676 | for (int p=0; p<pixel; p++) |
info@bausano.net | 12:1cf4e83eb240 | 677 | { |
info@bausano.net | 12:1cf4e83eb240 | 678 | wr_dat(color >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 679 | wr_dat(color & 0xff); |
info@bausano.net | 12:1cf4e83eb240 | 680 | } |
info@bausano.net | 12:1cf4e83eb240 | 681 | } |
info@bausano.net | 12:1cf4e83eb240 | 682 | else |
info@bausano.net | 12:1cf4e83eb240 | 683 | { // 16 bit SPI transfer |
info@bausano.net | 12:1cf4e83eb240 | 684 | _spi.format(16,0); |
info@bausano.net | 12:1cf4e83eb240 | 685 | for (int p=0; p<pixel; p++) |
info@bausano.net | 12:1cf4e83eb240 | 686 | { |
info@bausano.net | 12:1cf4e83eb240 | 687 | _spi.write(color); |
info@bausano.net | 12:1cf4e83eb240 | 688 | } |
info@bausano.net | 12:1cf4e83eb240 | 689 | _spi.format(8,0); |
info@bausano.net | 12:1cf4e83eb240 | 690 | } |
info@bausano.net | 12:1cf4e83eb240 | 691 | |
dreschpe | 0:da1bf437cbc1 | 692 | _cs = 1; |
dreschpe | 0:da1bf437cbc1 | 693 | WindowMax(); |
dreschpe | 0:da1bf437cbc1 | 694 | return; |
dreschpe | 0:da1bf437cbc1 | 695 | } |
dreschpe | 0:da1bf437cbc1 | 696 | |
dreschpe | 0:da1bf437cbc1 | 697 | |
dreschpe | 0:da1bf437cbc1 | 698 | void SPI_TFT_ILI9341::locate(int x, int y) |
dreschpe | 0:da1bf437cbc1 | 699 | { |
dreschpe | 0:da1bf437cbc1 | 700 | char_x = x; |
dreschpe | 0:da1bf437cbc1 | 701 | char_y = y; |
dreschpe | 0:da1bf437cbc1 | 702 | } |
dreschpe | 0:da1bf437cbc1 | 703 | |
dreschpe | 0:da1bf437cbc1 | 704 | |
dreschpe | 0:da1bf437cbc1 | 705 | int SPI_TFT_ILI9341::columns() |
dreschpe | 0:da1bf437cbc1 | 706 | { |
dreschpe | 0:da1bf437cbc1 | 707 | return width() / font[1]; |
dreschpe | 0:da1bf437cbc1 | 708 | } |
dreschpe | 0:da1bf437cbc1 | 709 | |
dreschpe | 0:da1bf437cbc1 | 710 | |
dreschpe | 0:da1bf437cbc1 | 711 | int SPI_TFT_ILI9341::rows() |
dreschpe | 0:da1bf437cbc1 | 712 | { |
dreschpe | 0:da1bf437cbc1 | 713 | return height() / font[2]; |
dreschpe | 0:da1bf437cbc1 | 714 | } |
dreschpe | 0:da1bf437cbc1 | 715 | |
dreschpe | 0:da1bf437cbc1 | 716 | |
dreschpe | 0:da1bf437cbc1 | 717 | int SPI_TFT_ILI9341::_putc(int value) |
dreschpe | 0:da1bf437cbc1 | 718 | { |
info@bausano.net | 12:1cf4e83eb240 | 719 | if (value == '\n') { // new line |
dreschpe | 0:da1bf437cbc1 | 720 | char_x = 0; |
dreschpe | 0:da1bf437cbc1 | 721 | char_y = char_y + font[2]; |
info@bausano.net | 12:1cf4e83eb240 | 722 | if (char_y >= height() - font[2]) |
info@bausano.net | 12:1cf4e83eb240 | 723 | { |
dreschpe | 0:da1bf437cbc1 | 724 | char_y = 0; |
dreschpe | 0:da1bf437cbc1 | 725 | } |
info@bausano.net | 12:1cf4e83eb240 | 726 | } |
info@bausano.net | 12:1cf4e83eb240 | 727 | else |
info@bausano.net | 12:1cf4e83eb240 | 728 | { |
dreschpe | 0:da1bf437cbc1 | 729 | character(char_x, char_y, value); |
dreschpe | 0:da1bf437cbc1 | 730 | } |
dreschpe | 0:da1bf437cbc1 | 731 | return value; |
dreschpe | 0:da1bf437cbc1 | 732 | } |
dreschpe | 0:da1bf437cbc1 | 733 | |
dreschpe | 0:da1bf437cbc1 | 734 | |
dreschpe | 0:da1bf437cbc1 | 735 | void SPI_TFT_ILI9341::character(int x, int y, int c) |
dreschpe | 0:da1bf437cbc1 | 736 | { |
dreschpe | 0:da1bf437cbc1 | 737 | unsigned int hor,vert,offset,bpl,j,i,b; |
dreschpe | 0:da1bf437cbc1 | 738 | unsigned char* zeichen; |
dreschpe | 0:da1bf437cbc1 | 739 | unsigned char z,w; |
dreschpe | 0:da1bf437cbc1 | 740 | |
dreschpe | 0:da1bf437cbc1 | 741 | if ((c < 31) || (c > 127)) return; // test char range |
dreschpe | 0:da1bf437cbc1 | 742 | |
dreschpe | 0:da1bf437cbc1 | 743 | // read font parameter from start of array |
dreschpe | 0:da1bf437cbc1 | 744 | offset = font[0]; // bytes / char |
dreschpe | 0:da1bf437cbc1 | 745 | hor = font[1]; // get hor size of font |
dreschpe | 0:da1bf437cbc1 | 746 | vert = font[2]; // get vert size of font |
dreschpe | 0:da1bf437cbc1 | 747 | bpl = font[3]; // bytes per line |
dreschpe | 0:da1bf437cbc1 | 748 | |
info@bausano.net | 12:1cf4e83eb240 | 749 | if (char_x + hor > width()) |
info@bausano.net | 12:1cf4e83eb240 | 750 | { |
dreschpe | 0:da1bf437cbc1 | 751 | char_x = 0; |
dreschpe | 0:da1bf437cbc1 | 752 | char_y = char_y + vert; |
info@bausano.net | 12:1cf4e83eb240 | 753 | if (char_y >= height() - font[2]) |
info@bausano.net | 12:1cf4e83eb240 | 754 | { |
dreschpe | 0:da1bf437cbc1 | 755 | char_y = 0; |
dreschpe | 0:da1bf437cbc1 | 756 | } |
dreschpe | 0:da1bf437cbc1 | 757 | } |
info@bausano.net | 12:1cf4e83eb240 | 758 | window(char_x, char_y,hor,vert); // char box |
info@bausano.net | 12:1cf4e83eb240 | 759 | wr_cmd(0x2C); // send pixel |
info@bausano.net | 12:1cf4e83eb240 | 760 | |
info@bausano.net | 12:1cf4e83eb240 | 761 | if (iTypeTFT != PARA_TFT_) //#ifndef PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 762 | { // 16 Bit SPI transfer |
info@bausano.net | 12:1cf4e83eb240 | 763 | _spi.format(16,0); |
info@bausano.net | 12:1cf4e83eb240 | 764 | } |
info@bausano.net | 12:1cf4e83eb240 | 765 | |
info@bausano.net | 12:1cf4e83eb240 | 766 | zeichen = &font[((c -32) * offset) + 4]; // start of char bitmap |
info@bausano.net | 12:1cf4e83eb240 | 767 | w = zeichen[0]; // width of actual char |
info@bausano.net | 12:1cf4e83eb240 | 768 | for (j=0; j<vert; j++) // vert line |
info@bausano.net | 12:1cf4e83eb240 | 769 | { |
info@bausano.net | 12:1cf4e83eb240 | 770 | for (i=0; i<hor; i++) // horz line |
info@bausano.net | 12:1cf4e83eb240 | 771 | { |
dreschpe | 0:da1bf437cbc1 | 772 | z = zeichen[bpl * i + ((j & 0xF8) >> 3)+1]; |
dreschpe | 0:da1bf437cbc1 | 773 | b = 1 << (j & 0x07); |
info@bausano.net | 12:1cf4e83eb240 | 774 | if (( z & b ) == 0x00) |
info@bausano.net | 12:1cf4e83eb240 | 775 | { |
info@bausano.net | 12:1cf4e83eb240 | 776 | if (iTypeTFT != PARA_TFT_) //#ifndef PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 777 | { // 16 bit SPI transfer |
info@bausano.net | 12:1cf4e83eb240 | 778 | _spi.write(_background); |
info@bausano.net | 12:1cf4e83eb240 | 779 | } |
info@bausano.net | 12:1cf4e83eb240 | 780 | else |
info@bausano.net | 12:1cf4e83eb240 | 781 | { // 8 bit parallel transfer |
info@bausano.net | 12:1cf4e83eb240 | 782 | wr_dat(_background >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 783 | wr_dat(_background & 0xff); |
info@bausano.net | 12:1cf4e83eb240 | 784 | } |
info@bausano.net | 12:1cf4e83eb240 | 785 | } |
info@bausano.net | 12:1cf4e83eb240 | 786 | else |
info@bausano.net | 12:1cf4e83eb240 | 787 | { |
info@bausano.net | 12:1cf4e83eb240 | 788 | if (iTypeTFT != PARA_TFT_) //#ifndef PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 789 | { |
info@bausano.net | 12:1cf4e83eb240 | 790 | _spi.write(_foreground); |
info@bausano.net | 12:1cf4e83eb240 | 791 | } |
info@bausano.net | 12:1cf4e83eb240 | 792 | else |
info@bausano.net | 12:1cf4e83eb240 | 793 | { // 8 bit parallel transfer |
info@bausano.net | 12:1cf4e83eb240 | 794 | wr_dat(_foreground >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 795 | wr_dat(_foreground & 0xff); |
info@bausano.net | 12:1cf4e83eb240 | 796 | } |
dreschpe | 0:da1bf437cbc1 | 797 | } |
dreschpe | 0:da1bf437cbc1 | 798 | } |
dreschpe | 0:da1bf437cbc1 | 799 | } |
dreschpe | 0:da1bf437cbc1 | 800 | _cs = 1; |
info@bausano.net | 12:1cf4e83eb240 | 801 | |
info@bausano.net | 12:1cf4e83eb240 | 802 | if (iTypeTFT != PARA_TFT_) //#ifndef PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 803 | { |
info@bausano.net | 12:1cf4e83eb240 | 804 | _spi.format(8,0); |
info@bausano.net | 12:1cf4e83eb240 | 805 | } |
info@bausano.net | 12:1cf4e83eb240 | 806 | |
dreschpe | 0:da1bf437cbc1 | 807 | WindowMax(); |
info@bausano.net | 12:1cf4e83eb240 | 808 | if ((w + 2) < hor) // x offset to next char |
info@bausano.net | 12:1cf4e83eb240 | 809 | { |
dreschpe | 0:da1bf437cbc1 | 810 | char_x += w + 2; |
info@bausano.net | 12:1cf4e83eb240 | 811 | } |
info@bausano.net | 12:1cf4e83eb240 | 812 | else |
info@bausano.net | 12:1cf4e83eb240 | 813 | { |
info@bausano.net | 12:1cf4e83eb240 | 814 | char_x += hor; |
info@bausano.net | 12:1cf4e83eb240 | 815 | } |
dreschpe | 0:da1bf437cbc1 | 816 | } |
dreschpe | 0:da1bf437cbc1 | 817 | |
dreschpe | 0:da1bf437cbc1 | 818 | |
dreschpe | 0:da1bf437cbc1 | 819 | void SPI_TFT_ILI9341::set_font(unsigned char* f) |
dreschpe | 0:da1bf437cbc1 | 820 | { |
dreschpe | 0:da1bf437cbc1 | 821 | font = f; |
dreschpe | 0:da1bf437cbc1 | 822 | } |
dreschpe | 0:da1bf437cbc1 | 823 | |
dreschpe | 0:da1bf437cbc1 | 824 | |
dreschpe | 0:da1bf437cbc1 | 825 | void SPI_TFT_ILI9341::Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap) |
dreschpe | 0:da1bf437cbc1 | 826 | { |
dreschpe | 0:da1bf437cbc1 | 827 | unsigned int j; |
dreschpe | 0:da1bf437cbc1 | 828 | int padd; |
dreschpe | 0:da1bf437cbc1 | 829 | unsigned short *bitmap_ptr = (unsigned short *)bitmap; |
info@bausano.net | 12:1cf4e83eb240 | 830 | |
info@bausano.net | 12:1cf4e83eb240 | 831 | //#ifdef PARA_TFT // 8 bit parallel transfer |
dreschpe | 6:55aed13f2630 | 832 | unsigned short pix_temp; |
info@bausano.net | 12:1cf4e83eb240 | 833 | //#endif |
dreschpe | 6:55aed13f2630 | 834 | |
dreschpe | 2:0a16083193a4 | 835 | unsigned int i; |
dreschpe | 2:0a16083193a4 | 836 | |
info@bausano.net | 12:1cf4e83eb240 | 837 | padd = -1; // the lines are padded to multiple of 4 bytes in a bitmap |
info@bausano.net | 12:1cf4e83eb240 | 838 | do |
info@bausano.net | 12:1cf4e83eb240 | 839 | { |
dreschpe | 0:da1bf437cbc1 | 840 | padd ++; |
info@bausano.net | 12:1cf4e83eb240 | 841 | } |
info@bausano.net | 12:1cf4e83eb240 | 842 | while (2*(w + padd)%4 != 0); |
dreschpe | 0:da1bf437cbc1 | 843 | window(x, y, w, h); |
dreschpe | 2:0a16083193a4 | 844 | bitmap_ptr += ((h - 1)* (w + padd)); |
info@bausano.net | 12:1cf4e83eb240 | 845 | wr_cmd(0x2C); // send pixel |
info@bausano.net | 12:1cf4e83eb240 | 846 | |
info@bausano.net | 12:1cf4e83eb240 | 847 | if (iTypeTFT != PARA_TFT_) //#ifndef PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 848 | { |
info@bausano.net | 12:1cf4e83eb240 | 849 | _spi.format(16,0); |
info@bausano.net | 12:1cf4e83eb240 | 850 | } |
info@bausano.net | 12:1cf4e83eb240 | 851 | |
info@bausano.net | 12:1cf4e83eb240 | 852 | for (j = 0; j < h; j++) //Lines |
info@bausano.net | 12:1cf4e83eb240 | 853 | { |
info@bausano.net | 12:1cf4e83eb240 | 854 | for (i = 0; i < w; i++) // one line |
info@bausano.net | 12:1cf4e83eb240 | 855 | { |
info@bausano.net | 12:1cf4e83eb240 | 856 | if (iTypeTFT == PARA_TFT_) //PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 857 | { |
dreschpe | 6:55aed13f2630 | 858 | pix_temp = *bitmap_ptr; |
info@bausano.net | 12:1cf4e83eb240 | 859 | wr_dat(pix_temp >> 8); |
info@bausano.net | 12:1cf4e83eb240 | 860 | wr_dat(pix_temp); |
dreschpe | 6:55aed13f2630 | 861 | bitmap_ptr++; |
info@bausano.net | 12:1cf4e83eb240 | 862 | } |
info@bausano.net | 12:1cf4e83eb240 | 863 | else |
info@bausano.net | 12:1cf4e83eb240 | 864 | { // 16 bit SPI transfer |
info@bausano.net | 12:1cf4e83eb240 | 865 | _spi.write(*bitmap_ptr); // one line |
dreschpe | 6:55aed13f2630 | 866 | bitmap_ptr++; |
info@bausano.net | 12:1cf4e83eb240 | 867 | } |
dreschpe | 0:da1bf437cbc1 | 868 | } |
dreschpe | 0:da1bf437cbc1 | 869 | bitmap_ptr -= 2*w; |
dreschpe | 0:da1bf437cbc1 | 870 | bitmap_ptr -= padd; |
dreschpe | 0:da1bf437cbc1 | 871 | } |
dreschpe | 0:da1bf437cbc1 | 872 | _cs = 1; |
info@bausano.net | 12:1cf4e83eb240 | 873 | |
info@bausano.net | 12:1cf4e83eb240 | 874 | if (iTypeTFT != PARA_TFT_) //#ifndef PARA_TFT |
info@bausano.net | 12:1cf4e83eb240 | 875 | { |
info@bausano.net | 12:1cf4e83eb240 | 876 | _spi.format(8,0); |
info@bausano.net | 12:1cf4e83eb240 | 877 | } |
info@bausano.net | 12:1cf4e83eb240 | 878 | |
dreschpe | 0:da1bf437cbc1 | 879 | WindowMax(); |
dreschpe | 0:da1bf437cbc1 | 880 | } |
dreschpe | 0:da1bf437cbc1 | 881 |