SPI support for ILI9341

Post your requests and ideas on the future development of Visual TFT Software.
Author
Message
rares.porutiu
Posts: 28
Joined: 18 Apr 2012 16:42

Re: SPI support for ILI9341

#31 Post by rares.porutiu » 16 Aug 2016 18:55

There was this problem , in help it writes :

procedure TFT_Rotate_180(rotate : byte);
...
TFT module needs to be initialized.

Then the example :

// Rotate TFT display for 180 degrees
TFT_Rotate_180(1); //<<<called before initialization

// Initialize TFT display
TFT_Init(240, 320);

When I posted I did Init first, and I had problems, had to clear most memory to reset system variables used by TFT_Init, to get good results. Did not have access to those variables by name.

That was mainly the problem.

dibor
Posts: 208
Joined: 29 Dec 2014 18:59

Re: SPI support for ILI9341

#32 Post by dibor » 27 Oct 2016 11:22

Hello.

3 years is over and ME team do NOTHING, for customers.

I'm only disappointed when I try to use ME software, all world has SPI libs for many TFTs ,also free libs for other compilers, only ME team do not have time to do it.

I'm back to the Bascom.

:( :? :cry: :evil:

rares.porutiu
Posts: 28
Joined: 18 Apr 2012 16:42

Re: SPI support for ILI9341

#33 Post by rares.porutiu » 27 Oct 2016 21:40

Hello DIBOR

I worked with BASCOM, it is much much slower.
Arduino has good TFT SPI library too.
I tried to suggest the mikro team to help them include the support for SPI and they replied that my example is enough contribution. There are still some issues that should be corrected with their help about TFT library. Maybe in the next version.
But please feel free to ask for my help, with a few lines of code you can use this display in Mikro products. Write to me directly at
rares.porutiu@gmail.com

and I will help you start your project if you like, like I helped others on the forum. :)

Rares

User avatar
uros.cvetinovic
mikroElektronika team
Posts: 803
Joined: 14 Dec 2015 09:24

Re: SPI support for ILI9341

#34 Post by uros.cvetinovic » 28 Oct 2016 11:10

Hi,

You can suggest this to be added to "Most desired upgrades and enhancements for MikroE compilers".

You can do it here:
http://forum.mikroe.com/viewtopic.php?f ... w=viewpoll

After we add this to the voting list, you can all vote for it.

Best regards,

Uros

dibor
Posts: 208
Joined: 29 Dec 2014 18:59

Re: SPI support for ILI9341

#35 Post by dibor » 28 Oct 2016 12:28

rares.porutiu wrote: I will help you start your project if you like, like I helped others on the forum. :)
Rares
Hello Rares.
Thank you for coming back. :D
I need basic function for ILI9341 , print few messages in different font size and color.
I have saw your example and how to change ME lib.
I have MikroC for AVR and VTFT and will try to do this changes in the ME libs.

Thank you again!

MicroMark
Posts: 181
Joined: 11 Feb 2011 17:22

Re: SPI support for ILI9341

#36 Post by MicroMark » 28 Oct 2016 17:02

This thread has 10,000 views and you want us to vote on it? :lol:

rares.porutiu
Posts: 28
Joined: 18 Apr 2012 16:42

Re: SPI support for ILI9341

#37 Post by rares.porutiu » 28 Oct 2016 19:33

I work in Pascal, but I will prepare an example for MikroC and write the code here after I test it. I have test board with ATXMEGA128D3, what do you intend to use ?

Rares

dibor
Posts: 208
Joined: 29 Dec 2014 18:59

Re: SPI support for ILI9341

#38 Post by dibor » 28 Oct 2016 22:22

Tnx Rares.
I'll use Mega328p or Mega128.

I do not think if this matter, but I did half of project in the Bascom. (Works under Proteus).

Regards.

dibor
Posts: 208
Joined: 29 Dec 2014 18:59

Re: SPI support for ILI9341

#39 Post by dibor » 30 Oct 2016 07:21

Hi Rares.
Checked your example and do not understood how to modify TFT libs for MikroC (do not know pascal) :(
When you will have time please write small example for MikroC users.

Best Regards.

rares.porutiu
Posts: 28
Joined: 18 Apr 2012 16:42

Re: SPI support for ILI9341

#40 Post by rares.porutiu » 30 Oct 2016 08:33

I send you here a working example, I did modify the TFT_Defs, could not do without, please adapt to your chip SPI and run a test, I'll stand by to help if you have a problem.

Rares


Modifications to __Lib_TFT_Defs.c , the one corresponding to your chip ! (after that is the main.c)

#include <built_in.h>
// Externs



extern sfr sbit TFT_RST_Direction, TFT_RST, TFT_RS_Direction, TFT_RS, TFT_CS_Direction, TFT_CS, TFT_WR, TFT_RD, TFT_WR_Direction, TFT_RD_Direction;
extern sfr unsigned short TFT_DataPort, TFT_DataPort_Direction;

static char TFT_Rotated_180 = 0;
static unsigned char TFT_Disp_Rotation = 0;
const char TFT_NOT_ROTATED = 0;
const char TFT_ROTATED180 = 1;

#define TFT_Write_Strobe() TFT_WR = 0; asm nop; TFT_WR = 1;


//******************** ILI9341SPI MODIFICATION BEGIN *****************************

//forward declarations
void TFT_Init_ILI9341_8bit_Custom_SPI(unsigned int display_width, unsigned int display_height, unsigned long _Set_Index_SPI, unsigned long _Write_Command_SPI, unsigned long _Write_Data_SPI);
static void TFT_Reset_ILI9341();
static void TFT_Set_Address_ILI9481(unsigned int x, unsigned int y);
//replacement routine for init ILI9341SPI, needs the 3 function addresses
void TFT_Init_ILI9341_8bit_Custom_SPI(unsigned int display_width, unsigned int display_height, unsigned long _Set_Index_SPI, unsigned long _Write_Command_SPI, unsigned long _Write_Data_SPI ) {
if (Is_TFT_Set() != 1) {
//************* Here set to SPI instead of parallel ***********************
TFT_Set_Index_Ptr = _Set_Index_SPI;
TFT_Write_Command_Ptr = _Write_Command_SPI;
TFT_Write_Data_Ptr = _Write_Data_SPI;
//*************************************************************************
}

TFT_DISP_WIDTH = display_width;
TFT_DISP_HEIGHT = display_height;
if (display_width >= display_height)
TFT_Disp_Rotation = 0;
else
TFT_Disp_Rotation = 90;

TFT_Set_Pen(CL_BLACK, 1);
TFT_Set_Brush(0, 0, 0, 0, 0, 0);

TFT_Move_Cursor(0, 0);
ExternalFontSet = 0;
// Reset device
TFT_Reset_ILI9341();
TFT_Set_Address_Ptr = TFT_Set_Address_ILI9481;
}
//******************** ILI9341SPI MODIFICATION END *******************************


Now the code in main :


// TFT display connections

//FAKES ! Needed since they are requested as externals in the TFT library, not used in SPI mode
char TFT_DataPort at PORTC_OUT;
sbit TFT_WR at TFT_DataPort.B0;
sbit TFT_RD at TFT_DataPort.B1;

char TFT_DataPort_Direction at PORTC_DIR;
sbit TFT_WR_Direction at TFT_DataPort_Direction.B0;
sbit TFT_RD_Direction at TFT_DataPort_Direction.B1;



//Reals
//Use 3V3 processor voltage, it may not work if the lines provide 5V !!!

sbit TFT_CS at PORTE_OUT.B5;
sbit TFT_CS_Direction at PORTE_DIR.B4;

sbit TFT_RS at PORTE_OUT.B1;
sbit TFT_RS_Direction at PORTE_DIR.B1;

sbit TFT_RST at PORTE_OUT.B4;
sbit TFT_RST_Direction at PORTE_DIR.B4;

// My board has TFT LIGHT Control
sbit TFT_LIGHT at PORTE_OUT.B0;
sbit TFT_LIGHT_Direction at PORTE_DIR.B0;
// My board has Power control for all peripherals
sbit Power at portd_out.B4;
sbit Power_Direction at portd_dir.B4;

//TFT Light control is INVERTED, can be used as PWN also to dimm the light
const TFT_LIGHT_ON=0;
const Power_ON=1;

// End of TFT display connections

//************************** TFT SPI ROUTINES **********************************
//Here replace with your own SPI READ syntax, USE READ because Write does not work !
// I put theese functions in USER code, not in the TFT LIB modifications,
// since you may change SPI number without changing the lib
void TFT_Set_Index_SPI(unsigned short index) {
TFT_RS = 0;
SPID_READ(index);
TFT_RS = 1;
}

void TFT_Write_Command_SPI(unsigned short cmd) {
TFT_RS = 1;
SPID_READ(cmd);
}

void TFT_Write_Data_SPI(unsigned int _data) {
SPID_READ((_data >> 8));
SPID_READ((_data));
}
//******************************************************************************


void main() {
// This is for my board
Power_direction=1;
Power=Power_ON;
// This control is on my board , but you should have a circuit on any board to Power the bright LED's of the 9341
TFT_Light_Direction=1;
TFT_Light=TFT_Light_ON;
//Initialize this first
UARTC0_Init(115200);
//Initialize the SPI used for the TFT
SPID_INIT_Advanced(_SPI_MASTER,_SPI_FCY_DIV2,_SPI_CLK_LO_LEADING);
//Set the rotation before INIT
TFT_Rotate_180(0);//has to be set before TFT_Init
// Initialize TFT display
TFT_Init_ILI9341_8bit_Custom_SPI(320,240,&TFT_Set_Index_SPI,&TFT_Write_Command_SPI,&TFT_Write_Data_SPI);
TFT_Fill_Screen(cl_Blue);//simple fill test
TFT_Set_Font(TFT_defaultFont, CL_WHITE, FO_HORIZONTAL);
TFT_Write_Text("TFT SPI LIBRARY DEMO, WELCOME !", 0, 0);//Test the TEXT routines


//this loop is to test that processor is not frozen, echoes the keys, also RESETS at the character *, like I reset for bootloader
while (1) {
if (UARTC0_Data_Ready() ==1){
char receive = UARTC0_Read();
if (receive =='*'){
CPU_CCP=0xD8;//UNPROTECT IOREG ! 0xD8 for 4 cycles
RST_CTRL.SWRST=1;//issue a software reset;
while (1); //just don't go further
}
UARTC0_Write(receive);
}
asm {wdr} //If you have activated watchdog, prevent from (WD)RESET while the loop loops :)
}
}

dibor
Posts: 208
Joined: 29 Dec 2014 18:59

Re: SPI support for ILI9341

#41 Post by dibor » 30 Oct 2016 20:26

Excellent !!!!!!!!!
WORKS!!!!
Thank you.

Tft commands are works, can I use DrawScreen(&Screen1) function for show screen made by VTFT?
I got black screen after using DrawScreen(&Screen1) function.

BTW : Latest lib for Bascom work faster then older.


Best Regards.

rares.porutiu
Posts: 28
Joined: 18 Apr 2012 16:42

Re: SPI support for ILI9341

#42 Post by rares.porutiu » 30 Oct 2016 20:50

I do not know why that happens, but if it goes through the TFT standard routines it should work. Maybe there is some optimizing shortcut of VTFT , maybe you're mistaking something or maybe there is a bug. I do not use VTFT, I wrote a set o routines to replace most of the TFT library, I did bigger and fancier fonts, menus Android style ...
I wonder if other VTFT command are working there. If you email me a complete example, archived project directories I will look into it when I have time.
But for C users , I'm very glad it works, I do not work in C on daily basis.
BASCOM is rich in solutions for our problems but I hate so much that lousy BASIC code. Sometimes I write in BASCOM a function and then I look in the ASM to see how it did it, and I write a Procedure in Pascal with that particular solution, mostly when DOC is unclear and mikro has not bothered to implement it :)

Rares

dibor
Posts: 208
Joined: 29 Dec 2014 18:59

Re: SPI support for ILI9341

#43 Post by dibor » 31 Oct 2016 14:50

Hi.
TFT routines doesn't works without SSA optimization.
Try to compile w/o SSA optimization - you will got errors.

Anyway, I think, this thread will interested for MikroC users.

Regards.

rares.porutiu
Posts: 28
Joined: 18 Apr 2012 16:42

Re: SPI support for ILI9341

#44 Post by rares.porutiu » 01 Nov 2016 09:18

I knew that for a long time, but I did not need to disable SSA except to blindly try solution to other bugs, maybe like you did.
If your problem with VTFT remains, and you want help, look at my previous post and send me enough data to recreate the situation easily.

Rares

ikrajinovic
Posts: 54
Joined: 20 Oct 2014 12:33

Re: SPI support for ILI9341

#45 Post by ikrajinovic » 21 Nov 2016 20:20

Hi ME

I there any news about this?? Please tell whether this library will be developed or not? Yes or No???

BR,
Ivo

Post Reply

Return to “Visual TFT Wish List”