Programme et Driver for MIKROE-495 REV 2.
Fork of SPI_TFTx2_ILI9341 by
Ce programme est issu du projet https://developer.mbed.org/users/TickTock/code/CANary/ Merci
Diff: SPI_TFTx2_ILI9341.cpp
- Revision:
- 11:69ce6c784cae
- Parent:
- 10:aca12a61d2b1
--- a/SPI_TFTx2_ILI9341.cpp Sun May 18 12:45:24 2014 +0000 +++ b/SPI_TFTx2_ILI9341.cpp Tue Mar 15 14:55:32 2016 +0000 @@ -1,3 +1,6 @@ +/* Rem modifie par Schneider Francois le 13/3/2016 */ +/* adapte a un seul afficheur */ + /* mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller * Copyright (c) 2013 Peter Drescher - DC2PD * Updated by Yoong HM for maintaining SPI_TFTx2 and SPI_TFTx2_ILI9341 in the @@ -27,13 +30,13 @@ //extern Serial pc; //extern DigitalOut xx; // debug !! -SPI_TFTx2_ILI9341::SPI_TFTx2_ILI9341(PinName mosi, PinName miso, PinName sclk, PinName cs0, PinName cs1, PinName reset, PinName dc, const char *name) - : _spi(mosi, miso, sclk), _cs0(cs0), _cs1(cs1), _reset(reset), _dc(dc), GraphicsDisplay(name) +SPI_TFTx2_ILI9341::SPI_TFTx2_ILI9341(PinName mosi, PinName miso, PinName sclk, PinName cs0, PinName reset, PinName dc, const char *name) + : _spi(mosi, miso, sclk), _cs0(cs0), _reset(reset), _dc(dc), GraphicsDisplay(name) { clk = sclk; orientation = 0; char_x = 0; - seldisp = 2; +// seldisp = 0; tft_reset(); } @@ -70,7 +73,6 @@ break; } _cs0 = 1; - _cs1 = 1; WindowMax(); } @@ -84,16 +86,7 @@ void SPI_TFTx2_ILI9341::wr_cmd(unsigned char cmd) { _dc = 0; - if (seldisp == 0) { - _cs0 = 0; - _cs1 = 1; - } else if (seldisp == 1) { - _cs0 = 1; - _cs1 = 0; - } else { - _cs0 = 0; - _cs1 = 0; - } + _cs0 = 0; _spi.write(cmd); // mbed lib _dc = 1; } @@ -102,16 +95,7 @@ void SPI_TFTx2_ILI9341::wr_dat(unsigned char dat) { - if (seldisp == 0) { _cs0 = 0; - _cs1 = 1; - } else if (seldisp == 1) { - _cs0 = 1; - _cs1 = 0; - } else { - _cs0 = 0; - _cs1 = 0; - } _spi.write(dat); // mbed lib } @@ -123,22 +107,11 @@ { char r; _dc = 0; - if (seldisp == 0) { - _cs0 = 0; - _cs1 = 1; - } else if (seldisp == 1) { - _cs0 = 1; - _cs1 = 0; - } else { - _cs0 = 0; - _cs1 = 0; - } + _cs0 = 0; _spi.write(cmd); // mbed lib _cs0 = 1; - _cs1 = 1; r = _spi.write(0xff); _cs0 = 1; - _cs1 = 1; return(r); } @@ -148,16 +121,7 @@ int d; char r; _dc = 0; - if (seldisp == 0) { - _cs0 = 0; - _cs1 = 1; - } else if (seldisp == 1) { - _cs0 = 1; - _cs1 = 0; - } else { - _cs0 = 0; - _cs1 = 0; - } + _cs0 = 0; d = cmd; d = d << 1; _spi.format(9,3); // we have to add a dummy clock cycle @@ -173,7 +137,6 @@ r = _spi.write(0xff); d = (d << 8) | r; _cs0 = 1; - _cs1 = 1; return(d); } @@ -194,7 +157,6 @@ _spi.format(8,3); // 8 bit spi mode 3 _spi.frequency(48000000); // 48 Mhz SPI clock _cs0 = 1; // cs high - _cs1 = 1; _dc = 1; // dc high _reset = 0; // display reset @@ -212,23 +174,17 @@ _spi.write(0x83); _spi.write(0x30); _cs0 = 1; - _cs1 = 1; - wr_cmd(0xED); _spi.write(0x64); _spi.write(0x03); _spi.write(0x12); _spi.write(0x81); _cs0 = 1; - _cs1 = 1; - wr_cmd(0xE8); _spi.write(0x85); _spi.write(0x01); _spi.write(0x79); _cs0 = 1; - _cs1 = 1; - wr_cmd(0xCB); _spi.write(0x39); _spi.write(0x2C); @@ -236,65 +192,52 @@ _spi.write(0x34); _spi.write(0x02); _cs0 = 1; - _cs1 = 1; wr_cmd(0xF7); _spi.write(0x20); _cs0 = 1; - _cs1 = 1; wr_cmd(0xEA); _spi.write(0x00); _spi.write(0x00); _cs0 = 1; - _cs1 = 1; wr_cmd(0xC0); // POWER_CONTROL_1 _spi.write(0x26); _cs0 = 1; - _cs1 = 1; wr_cmd(0xC1); // POWER_CONTROL_2 _spi.write(0x11); _cs0 = 1; - _cs1 = 1; wr_cmd(0xC5); // VCOM_CONTROL_1 _spi.write(0x35); _spi.write(0x3E); _cs0 = 1; - _cs1 = 1; wr_cmd(0xC7); // VCOM_CONTROL_2 _spi.write(0xBE); - _cs0 = 1; - _cs1 = 1; wr_cmd(0x36); // MEMORY_ACCESS_CONTROL _spi.write(0x48); _cs0 = 1; - _cs1 = 1; wr_cmd(0x3A); // COLMOD_PIXEL_FORMAT_SET _spi.write(0x55); // 16 bit pixel _cs0 = 1; - _cs1 = 1; wr_cmd(0xB1); // Frame Rate _spi.write(0x00); _spi.write(0x1B); _cs0 = 1; - _cs1 = 1; - + wr_cmd(0xF2); // Gamma Function Disable _spi.write(0x08); _cs0 = 1; - _cs1 = 1; wr_cmd(0x26); _spi.write(0x01); // gamma set for curve 01/2/04/08 _cs0 = 1; - _cs1 = 1; wr_cmd(0xE0); // positive gamma correction _spi.write(0x1F); @@ -313,7 +256,6 @@ _spi.write(0x05); _spi.write(0x00); _cs0 = 1; - _cs1 = 1; wr_cmd(0xE1); // negativ gamma correction _spi.write(0x00); @@ -332,7 +274,6 @@ _spi.write(0x3A); _spi.write(0x1F); _cs0 = 1; - _cs1 = 1; WindowMax (); @@ -345,7 +286,6 @@ wr_cmd(0xB7); // entry mode _spi.write(0x07); _cs0 = 1; - _cs1 = 1; wr_cmd(0xB6); // display function control _spi.write(0x0A); @@ -353,17 +293,14 @@ _spi.write(0x27); _spi.write(0x00); _cs0 = 1; - _cs1 = 1; wr_cmd(0x11); // sleep out _cs0 = 1; - _cs1 = 1; wait_ms(100); wr_cmd(0x29); // display on _cs0 = 1; - _cs1 = 1; wait_ms(100); @@ -376,12 +313,10 @@ _spi.write(x >> 8); _spi.write(x); _cs0 = 1; - _cs1 = 1; wr_cmd(0x2B); _spi.write(y >> 8); _spi.write(y); _cs0 = 1; - _cs1 = 1; wr_cmd(0x2C); // send pixel #if defined TARGET_KL25Z // 8 Bit SPI _spi.write(color >> 8); @@ -392,7 +327,6 @@ _spi.format(8,3); #endif _cs0 = 1; - _cs1 = 1; } @@ -405,14 +339,12 @@ _spi.write(x+w-1); _cs0 = 1; - _cs1 = 1; wr_cmd(0x2B); _spi.write(y >> 8); _spi.write(y); _spi.write((y+h-1) >> 8); _spi.write(y+h-1); _cs0 = 1; - _cs1 = 1; } @@ -443,7 +375,6 @@ _spi.format(8,3); #endif _cs0 = 1; - _cs1 = 1; } @@ -503,7 +434,6 @@ _spi.format(8,3); #endif _cs0 = 1; - _cs1 = 1; WindowMax(); return; } @@ -527,7 +457,6 @@ _spi.format(8,3); #endif _cs0 = 1; - _cs1 = 1; WindowMax(); return; } @@ -647,7 +576,6 @@ _spi.format(8,3); #endif _cs0 = 1; - _cs1 = 1; WindowMax(); return; } @@ -740,7 +668,6 @@ } } _cs0 = 1; - _cs1 = 1; #ifndef TARGET_KL25Z // 16 Bit SPI _spi.format(8,3); #endif @@ -796,7 +723,6 @@ bitmap_ptr -= padd; } _cs0 = 1; - _cs1 = 1; #ifndef TARGET_KL25Z // 16 Bit SPI _spi.format(8,3); #endif @@ -887,7 +813,6 @@ } } _cs0 = 1; - _cs1 = 1; _spi.format(8,3); free (line); fclose(Image);