TFT 1.8'' shield with joystick with Leonardo?

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
bergowitch
 
Posts: 2
Joined: Sun Feb 17, 2013 3:56 am

TFT 1.8'' shield with joystick with Leonardo?

Post by bergowitch »

Hello,
I'm trying to get the shield working. So I start with the display. It does work if I use the Uno Board.
But if I try it with the Leonardo it does work in the slow mode, but not in the fast one. It stays white (backlight?). I use the same code which is ok for the Uno.
Is the Problem the init of the pins? I try these:

Code: Select all

#define cs  10
#define dc   8
#define rst  -1  // you can also connect this to the Arduino reset

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);
Are these right?

A different Problem is, that I can't find a doc of the Joystick...

Thank you
Stefan

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: TFT 1.8'' shield with joystick with Leonardo?

Post by adafruit_support_rick »

The Leonardo does not bring out hardware SPI on the digital pins. As stated in the Arduino Leonardo product description, it is only available on the 6-pin ICSP header:
SPI: on the ICSP header. These pins support SPI communication using the SPI library. Note that the SPI pins are not connected to any of the digital I/O pins as they are on the Uno, They are only available on the ICSP connector. This means that if you have a shield that uses SPI, but does NOT have a 6-pin ICSP connector that connects to the Leonardo's 6-pin ICSP header, the shield will not work.
The Adafruit shield will work, but only in Software SPI (i.e., 'slow') mode.

The shieldtest example sketch demonstrates the use of the joystick (function readButton).

bergowitch
 
Posts: 2
Joined: Sun Feb 17, 2013 3:56 am

Re: TFT 1.8'' shield with joystick with Leonardo?

Post by bergowitch »

Hi,
thank you for the reply.
The Adafruit shield will work, but only in Software SPI (i.e., 'slow') mode.
That is realy sad...
The shieldtest example sketch demonstrates the use of the joystick (function readButton).
In this example it seems, that the joystick can only recognicze one direction and not diagonal (up and right at the same time)? is that right?
greetings
Stefan

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: TFT 1.8'' shield with joystick with Leonardo?

Post by adafruit_support_rick »

If you were willing to do violence to your shield (and void the warranty! :shock: ), you could clip off the shield pins that mate with Digital 11 (MOSI), 12 (MISO), and 13 (SCK), and solder three jumper wires in their place. Then, connect the wires to MOSI (pin 1), MISO (pin 4) and SCK (pin 3) on the ICSP header.

If you use something like our male<->female header jumper wires, you wouldn't need to solder to the ICSP pins.

If you're lucky, you might be able to bend the pins on the shield instead of clipping them. Then you could use female<->female jumper wires between the shield pins and the ICSP pins
bergowitch wrote:In this example it seems, that the joystick can only recognicze one direction and not diagonal (up and right at the same time)? is that right?
greetings
Wellll..... yes and no. If you look at the schematic below, you'll see that the joypad works by selecting different resistors to form a resistive voltage divider. The numbers that the example code is comparing with to determine which direction is selected are actually the voltages produced by this circuit. So, then you select UP, you connect to ground through the 10K resistor, which results in voltage reading of about 0.3V. Selecting LEFT connects through the 22Ohm resistor, and you get a voltage reading of around 3.23V*

So, you can compute the voltage readings for diagonal selections and, theoretically, detect those as well. And it almost works. Up is 0.3V, Right is 1.65V, and Right/Up is 1.73V. But the other combinations start to crowd too closely together to expect reliable results. For example Left, Left/Down, and Left/Up are virtually identical, at around 3.23V.
joypad.png
joypad.png (13.91 KiB) Viewed 556 times
You'll also notice that pressing a direction and SELECT simultaneously will produce a different reading than they will individually.

*calculated values. the shieldtest example code appears to use empirically-derived numbers, as they are a bit lower.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”