Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

2.8'' TFT Touch Shield V2.0 Seeed Studio


  • Please log in to reply
5 replies to this topic

#1 slaud

slaud

    New Member

  • Members
  • Pip
  • 8 posts

Posted 08 September 2013 - 04:59 PM

http://www.seeedstud...v20-p-1286.html

itl looks realy great for netduino!

did someone get it running with netduino 2



#2 slaud

slaud

    New Member

  • Members
  • Pip
  • 8 posts

Posted 09 September 2013 - 06:59 PM

just started and get in not to work :-(maybe someone can help me a litle bitreadRegister(byte Addr, byte xParameter) doesnt works
using System;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace _2_8_touch_lcd{    class touchLcd    {	    //TFT resolution 240*320	    private ushort MIN_X    = 0;	    private ushort MIN_Y = 0;	    private ushort MAX_X = 239;	    private ushort MAX_Y = 319; //	   private static OutputPort _cs = new OutputPort(Pins.GPIO_PIN_D10, false);	    private static OutputPort _dc = new OutputPort(Pins.GPIO_PIN_D6, false);	    private SPI Spi1;	   		 public touchLcd()	    {		    Spi1 = new SPI(new SPI.Configuration(				  Pins.GPIO_PIN_D6,   //Chip Select pin																   true,			  //Chip Select Active State																   0,				  //Chip Select Setup Time																   0,				  //Chip Select Hold Time																   false,			   //Clock Idle State																   false,			   //Clock Edge																   1000,			   //Clock Rate (kHz)																   SPI.SPI_module.SPI2));	    }	    public bool dc	    {		    get { return _dc.Read(); }		    set { _dc.Write(value); }	    }	    public void sendCMD(byte CMD)	    {		    dc = false;		    Spi1.Write(new byte[] {CMD});	    }	    public void writeDATA(byte DATA)	    {		    dc = true;		    Spi1.Write(new byte[] { DATA });	    }	    public void writeDATA(ushort DATA)	    {		    dc = true;		    Spi1.Write(new ushort[] { DATA });	    }	    public byte readRegister(byte Addr, byte xParameter)	    {		    byte[] data={0};		    sendCMD(0xd9);											    /* ext command				  */		    writeDATA((ushort)(0x1100 + xParameter));						 /* 0x11 is the first Parameter  */		    dc = false;		    Spi1.Write(new byte[] {Addr});		    dc = true;		    Spi1.WriteRead(new byte[] { 0 }, data);		    return data[0];	    }	    public void init()	    {//		   SPI.begin();		    dc = false;		    byte i=0, TFTDriver=0;		    for(i=0;i<3;i++)		    {			    TFTDriver = readID();		    }		    System.Threading.Thread.Sleep(500);		    sendCMD(0x01);		    System.Threading.Thread.Sleep(200);		    sendCMD(0xCF);		    writeDATA(0x00);		    writeDATA(0x8B);		    writeDATA(0X30);		    sendCMD(0xED);		    writeDATA(0x67);		    writeDATA(0x03);		    writeDATA(0X12);		    writeDATA(0X81);		    sendCMD(0xE8);		    writeDATA(0x85);		    writeDATA(0x10);		    writeDATA(0x7A);		    sendCMD(0xCB);		    writeDATA(0x39);		    writeDATA(0x2C);		    writeDATA(0x00);		    writeDATA(0x34);		    writeDATA(0x02);		    sendCMD(0xF7);		    writeDATA(0x20);		    sendCMD(0xEA);		    writeDATA(0x00);		    writeDATA(0x00);		    sendCMD(0xC0);													  /* Power control			    */		    writeDATA(0x1B);												   /* VRH[5:0]					 */		    sendCMD(0xC1);													  /* Power control			    */		    writeDATA(0x10);												   /* SAP[2:0];BT[3:0]			 */		    sendCMD(0xC5);													  /* VCM control				  */		    writeDATA(0x3F);		    writeDATA(0x3C);		    sendCMD(0xC7);													  /* VCM control2				 */		    writeDATA(0XB7);		    sendCMD(0x36);													  /* Memory Access Control	    */		    writeDATA(0x08);		    sendCMD(0x3A);		    writeDATA(0x55);		    sendCMD(0xB1);		    writeDATA(0x00);		    writeDATA(0x1B);		    sendCMD(0xB6);													  /* Display Function Control	 */		    writeDATA(0x0A);		    writeDATA(0xA2);		    sendCMD(0xF2);													  /* 3Gamma Function Disable	  */		    writeDATA(0x00);		    sendCMD(0x26);													  /* Gamma curve selected		 */		    writeDATA(0x01);		    sendCMD(0xE0);													  /* Set Gamma				    */		    writeDATA(0x0F);		    writeDATA(0x2A);		    writeDATA(0x28);		    writeDATA(0x08);		    writeDATA(0x0E);		    writeDATA(0x08);		    writeDATA(0x54);		    writeDATA(0XA9);		    writeDATA(0x43);		    writeDATA(0x0A);		    writeDATA(0x0F);		    writeDATA(0x00);		    writeDATA(0x00);		    writeDATA(0x00);		    writeDATA(0x00);		    sendCMD(0XE1);													  /* Set Gamma				    */		    writeDATA(0x00);		    writeDATA(0x15);		    writeDATA(0x17);		    writeDATA(0x07);		    writeDATA(0x11);		    writeDATA(0x06);		    writeDATA(0x2B);		    writeDATA(0x56);		    writeDATA(0x3C);		    writeDATA(0x05);		    writeDATA(0x10);		    writeDATA(0x0F);		    writeDATA(0x3F);		    writeDATA(0x3F);		    writeDATA(0x0F);		    sendCMD(0x11);													  /* Exit Sleep				   */		    System.Threading.Thread.Sleep(120);		    sendCMD(0x29);													  /* Display on				   */		    fillScreen();	    }	    public byte readID()	    {		    byte i = 0;		    byte[] data = new byte[3];		    byte[] ID = new byte[3] { 0x00, 0x93, 0x41 };		    byte ToF = 1;		    for (i = 0; i < 3; i++)		    {			    data[i] = readRegister(0xd3, (byte)(i + 1));			    if (data[i] != ID[i])			    {				    ToF = 0;			    }		    			 }		    if (ToF==0)														    /* data!=ID					 */		    {			    Debug.Print("Read TFT ID failed, ID should be 0x09341,");			    Debug.Print( "but read ID = 0x" + data[0].ToString("X") + data[1].ToString("X") + data[2].ToString("X"));		    }		    return ToF;	    }	    public void setCol(UInt16 StartCol,UInt16 EndCol)	    {		    sendCMD(0x2A);													  /* Column Command address	   */		    writeDATA(StartCol);		    writeDATA(EndCol);	    }	    public void setPage(UInt16 StartPage,UInt16 EndPage)	    {		    sendCMD(0x2B);													  /* Column Command address	   */		    writeDATA(StartPage);		    writeDATA(EndPage);	    }	    public void fillScreen(ushort XL, ushort XR, ushort YU, ushort YD, ushort color)	    {		    ushort  XY=0;		    ushort i = 0;		    if(XL > XR)		    {			    XL = (ushort)(XL ^ XR);			    XR = (ushort)(XL ^ XR);			    XL = (ushort)(XL ^ XR);		    }		    if(YU > YD)		    {			    YU = (ushort)(YU ^ YD);			    YD = (ushort)(YU ^ YD);			    YU = (ushort)(YU ^ YD);		    }		    XL = constrain(XL, MIN_X,MAX_X);		    XR = constrain(XR, MIN_X,MAX_X);		    YU = constrain(YU, MIN_Y,MAX_Y);		    YD = constrain(YD, MIN_Y,MAX_Y);		    XY = (ushort)(XR - XL + 1);		    XY = (ushort)(XY * (YD - YU + 1));		    setCol(XL,XR);		    setPage(YU, YD);		    sendCMD(0x2c);												  /* start to write to display ra */																			    /* m						    */		    dc = true;		    byte Hcolor =(byte) (color>>8);		    byte Lcolor = (byte)(color & 0xff);		    for(i=0; i < XY; i++)		    {			    Spi1.Write(new byte[]{Hcolor});			    Spi1.Write(new byte[]{Lcolor});		    }	    }	    private ushort constrain(ushort value, ushort MIN_X, ushort MAX_X)	    {		    if (value < MIN_X)		    {			    return MIN_X;		    }		    else if (MAX_X < value)		    {			    return MAX_X;		    }		    else			    return (ushort)value;	    }	    public void fillScreen()	    {		    setCol(0, 239);		    setPage(0, 319);		    sendCMD(0x2c);												  /* start to write to display ra */																		    /* m						    */		    dc = true;		    uint i;		    for(i=0; i<38400; i++)		    {			    Spi1.Write(new byte[] { 0 });			    Spi1.Write(new byte[] { 0 });			    Spi1.Write(new byte[] { 0 });			    Spi1.Write(new byte[] { 0 });		    }	    }}    }


#3 slaud

slaud

    New Member

  • Members
  • Pip
  • 8 posts

Posted 09 September 2013 - 09:37 PM

lol i found some soulder pads to connect the spi ;-) i try it tomorow again



#4 optimist

optimist

    New Member

  • Members
  • Pip
  • 1 posts

Posted 10 September 2013 - 07:24 PM

Hello, did you get in to work? I just received my V2.0 Shield. Please share the code if you could successfully run the TFT display with netduino 2.0.



#5 slaud

slaud

    New Member

  • Members
  • Pip
  • 8 posts

Posted 12 September 2013 - 01:59 PM

is it possible that that display is a realy slow thing?

is it the display or the netduino?



#6 gentlemanjoe

gentlemanjoe

    New Member

  • Members
  • Pip
  • 1 posts

Posted 25 February 2014 - 04:47 PM

Did you ever get this working?  I just got one and I'm struggling.  It fails on read ID.  It gets only 0's instead of 9341.  It doesn't display anything either.  I've soldered the three headers and I've soldered the backlight to the D7 pad and all I can do is toggle the backlight.  Anyway, any help would be greatly appreciated.  Thanks.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.