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

Having a problem with my adafruit ST7735 LCD


  • Please log in to reply
24 replies to this topic

#1 ricodued

ricodued

    New Member

  • Members
  • Pip
  • 1 posts

Posted 01 January 2012 - 01:07 AM

I got the lovely adafruit ST7735 LCD screen for Christmas and I'm having troubles with it right out of the box.

It's wired up like so:
Reset -> D8
D/C -> D7
TFT_CS -> D9
MOSI -> D11
SCK -> D13
MISO -> D12

(See the board here.)

When I run the following code:

            AdaFruitST7735 lcd = new AdaFruitST7735(
                Pins.GPIO_PIN_D9,
                Pins.GPIO_PIN_D7,
                Pins.GPIO_PIN_D8);

            lcd.ClearScreen(color: (ushort)Colors.Blue);

My LCD looks as it does in the attached picture.

Any ideas why this isn't working?

Thanks!

Attached Files



#2 MBY

MBY

    New Member

  • Members
  • Pip
  • 1 posts

Posted 13 May 2012 - 03:40 AM

I am experiencing the exact same problem. Did you ever manage to resolve the issue?

#3 NicholasSTG

NicholasSTG

    Member

  • Members
  • PipPip
  • 16 posts

Posted 23 September 2012 - 09:53 PM

I am experiencing the exact same problem. Did you ever manage to resolve the issue?


Did you resolve this? I am having the same issue.

#4 supra

supra

    Advanced Member

  • Members
  • PipPipPip
  • 210 posts
  • LocationOntario, Canada

Posted 24 September 2012 - 02:48 PM

AdaFruitST7735 lcd = new AdaFruitST7735( Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8); lcd.ClearScreen(color: (ushort)Colors.Blue);



var lcd = new AdaFruitST7735(Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8);


#5 NicholasSTG

NicholasSTG

    Member

  • Members
  • PipPip
  • 16 posts

Posted 28 September 2012 - 04:22 AM

var lcd = new AdaFruitST7735(Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8);


This seems to be the code I tried already, but I tried anyways and still have the same problem. Did you get this to work?

#6 supra

supra

    Advanced Member

  • Members
  • PipPipPip
  • 210 posts
  • LocationOntario, Canada

Posted 28 September 2012 - 05:01 AM

This seems to be the code I tried already, but I tried anyways and still have the same problem. Did you get this to work?


Here is link/ Look for adafruit ST7735Test
ST7735

#7 NicholasSTG

NicholasSTG

    Member

  • Members
  • PipPip
  • 16 posts

Posted 28 September 2012 - 02:39 PM

Hmmm, that's where I sourced my code originally.

I've just commented out a couple of lines since I don't have an SD card in the screen

public static AdaFruitST7735 tft = new AdaFruitST7735(Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8, speedKHz: 40000);

        public static void Main()
        {
            // DisplayPicture();

            tft.ClearScreen();
            DisplayGradient();

            DisplayCircles();

            tft.ClearScreen();
            DisplayLines();

            // DisplayColorFlow();
        }

There's no change, still all scrambled. The code is running (I've tried breakpoints in the Program.cs class and AdaFruitST7735 class and it is hitting them as it is should) so I'm not sure what's up.

I've checked all the wiring multiple times.

When the program starts the screen goes white and then scrambles. The scrambling occurs when the AdaFruitST7735 class is initiated (in the ClearScreen method).

#8 supra

supra

    Advanced Member

  • Members
  • PipPipPip
  • 210 posts
  • LocationOntario, Canada

Posted 28 September 2012 - 03:01 PM

Hmmm, that's where I sourced my code originally.

I've just commented out a couple of lines since I don't have an SD card in the screen

public static AdaFruitST7735 tft = new AdaFruitST7735(Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8, speedKHz: 40000);

        public static void Main()
        {
            // DisplayPicture();

            tft.ClearScreen();
            DisplayGradient();

            DisplayCircles();

            tft.ClearScreen();
            DisplayLines();

            // DisplayColorFlow();
        }

There's no change, still all scrambled. The code is running (I've tried breakpoints in the Program.cs class and AdaFruitST7735 class and it is hitting them as it is should) so I'm not sure what's up.

I've checked all the wiring multiple times.

When the program starts the screen goes white and then scrambles. The scrambling occurs when the AdaFruitST7735 class is initiated (in the ClearScreen method).



When u not using sd card. U have remove it frm parameter speedKHz: 40000.......public static AdaFruitST7735 tft = new AdaFruitST7735(Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8);


also comment out procedure event .............ReadPicture

Do u have driver for St7735?



#9 supra

supra

    Advanced Member

  • Members
  • PipPipPip
  • 210 posts
  • LocationOntario, Canada

Posted 28 September 2012 - 03:14 PM

St7735 driver
MyDriver

#10 supra

supra

    Advanced Member

  • Members
  • PipPipPip
  • 210 posts
  • LocationOntario, Canada

Posted 28 September 2012 - 03:35 PM

Do u followed frm ricodued wiring?


#11 NicholasSTG

NicholasSTG

    Member

  • Members
  • PipPip
  • 16 posts

Posted 28 September 2012 - 08:27 PM

Thanks for all your help. Your Driver seems to help and seems to be different than the version I got when I downloaded the latest from the netduino library.

I now get a picture, but it seems ... 'skewed'.

For instance

public static void Main()
        {
            // DisplayPicture();

            tft.ClearScreen((ushort)AdaFruitST7735.Colors.White);
            // tft.DrawCircle(AdaFruitST7735.Width / 2, AdaFruitST7735.Height / 2, AdaFruitST7735.Width / 4, (ushort)AdaFruitST7735.Colors.Red);
            tft.DrawCircle(50, 50, 10, (ushort)AdaFruitST7735.Colors.Red);
            tft.Refresh();
            /*
            DisplayGradient();
            */
            // DisplayCircles();
            /*
            tft.ClearScreen();
            DisplayLines();
            */
            // DisplayColorFlow();
        }

generates a picture like the following

Posted Image

I've checked the wiring, etc and it all seems to be good. I also downloaded the ExtededSpiConfiguration class from the same revision as your code, just in case it was that.

It didn't make a change.

#12 NicholasSTG

NicholasSTG

    Member

  • Members
  • PipPip
  • 16 posts

Posted 28 September 2012 - 08:35 PM

I also downloaded that entire commit from codeplex and it did not make a change.

#13 supra

supra

    Advanced Member

  • Members
  • PipPipPip
  • 210 posts
  • LocationOntario, Canada

Posted 28 September 2012 - 08:40 PM

Thanks for all your help. Your Driver seems to help and seems to be different than the version I got when I downloaded the latest from the netduino library.

I now get a picture, but it seems ... 'skewed'.

For instance

public static void Main()
        {
            // DisplayPicture();

            tft.ClearScreen((ushort)AdaFruitST7735.Colors.White);
            // tft.DrawCircle(AdaFruitST7735.Width / 2, AdaFruitST7735.Height / 2, AdaFruitST7735.Width / 4, (ushort)AdaFruitST7735.Colors.Red);
            tft.DrawCircle(50, 50, 10, (ushort)AdaFruitST7735.Colors.Red);
            tft.Refresh();
            /*
            DisplayGradient();
            */
            // DisplayCircles();
            /*
            tft.ClearScreen();
            DisplayLines();
            */
            // DisplayColorFlow();
        }

generates a picture like the following

Posted Image

I've checked the wiring, etc and it all seems to be good. I also downloaded the ExtededSpiConfiguration class from the same revision as your code, just in case it was that.

It didn't make a change.


Did u get error?

#14 NicholasSTG

NicholasSTG

    Member

  • Members
  • PipPip
  • 16 posts

Posted 28 September 2012 - 09:03 PM

I'm guessing you did not have this issue with the skewing?

#15 supra

supra

    Advanced Member

  • Members
  • PipPipPip
  • 210 posts
  • LocationOntario, Canada

Posted 28 September 2012 - 09:14 PM

Does ur circle changed direction?

#16 NicholasSTG

NicholasSTG

    Member

  • Members
  • PipPip
  • 16 posts

Posted 28 September 2012 - 09:26 PM

Does ur circle changed direction?


The circles do animate when I use the appropriate method, yes.

IT almost seems as if 0,0 is in the wrong spot which throws off all of the other calculations.

#17 supra

supra

    Advanced Member

  • Members
  • PipPipPip
  • 210 posts
  • LocationOntario, Canada

Posted 28 September 2012 - 09:46 PM

The circles do animate when I use the appropriate method, yes.

IT almost seems as if 0,0 is in the wrong spot which throws off all of the other calculations.



What abt drawline? Did u try it?

#18 NicholasSTG

NicholasSTG

    Member

  • Members
  • PipPip
  • 16 posts

Posted 28 September 2012 - 11:07 PM

What abt drawline? Did u try it?


I did.

I wrote this code to sort of see what was happening

public static void Main() {
            // DisplayPicture();

            tft.ClearScreen((ushort)AdaFruitST7735.Colors.White);
            // DisplayGradient();

            // DisplayCircles();

            for (int x = 0; x < 86; x++ )
            {
                tft.DrawPixel(x, 20, (ushort)AdaFruitST7735.Colors.Red);
            }

            for (int y = 0; y < 10; y++)
            {
                tft.DrawPixel(10, y, (ushort)AdaFruitST7735.Colors.Red);
            }

            for (int x = 0; x < 100; x++)
            {
                tft.DrawPixel(x, 5, (ushort)AdaFruitST7735.Colors.Green);
            }

            tft.DrawLine(50, 50, 50,100,(ushort)AdaFruitST7735.Colors.Blue);

            tft.DrawLine(50, 50, 100,50,(ushort)AdaFruitST7735.Colors.Yellow);

            tft.Refresh();

            // tft.ClearScreen();
            // DisplayLines();

            // DisplayColorFlow();
        }

The result looked like the attachment.

It seems that the 0 point is wrong so when the it tries to calculate a horizontal line the shifts in the register get out of whack.

Attached File  2012-09-28 15.05.12.jpg   83.9KB   29 downloads

#19 NicholasSTG

NicholasSTG

    Member

  • Members
  • PipPip
  • 16 posts

Posted 29 September 2012 - 12:21 AM

I've got to trackdown the 'why' but changing the driver's SetPixel to

          private void SetPixel(int x, int y, ushort color) {
            if ((x < 0) || (x >= Width) || (y < 0) || (y >= Height)) return;

            var index = ((y * Width) + x) * sizeof(ushort) - y * 4;    

            if (index < 0 || index >= SpiBuffer.Length) return;
            SpiBuffer[index] = (byte) (color >> 8);
            SpiBuffer[++index] = (byte)(color);
        }

seems to have done the trick. The check on the index is just there because I was debugging.

#20 supra

supra

    Advanced Member

  • Members
  • PipPipPip
  • 210 posts
  • LocationOntario, Canada

Posted 29 September 2012 - 11:21 AM

Congratulation nicholasSTG! This sample will only showing u if lcd working. U now ready to create ur own code. Btw, u can try triangle, box, or draw a car, etc




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.