0

TFT touchscreen selection question
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

TFT touchscreen selection question

by NineFingers on Sat Jun 17, 2017 6:50 pm

All,
I am working on a project that requires a capacitive touch screen interface in excess of 4.5". due to limited motor skills of the user a touch screen rather than physical buttons must be used.

I currently have my proof of concept working with the the. 2.8"tft. PRODUCT ID: 1947, controlled with an Arduino MEGA 2560.

My coding ability is not the strongest, so a strong library support is preferred, and the Arduino control is a must so I do not have to re-code everything.

Your experience and insight appreciate,
Jason
Ninefingers
Last edited by NineFingers on Sun Jun 18, 2017 12:00 pm, edited 1 time in total.

NineFingers
 
Posts: 23
Joined: Fri Jun 02, 2017 1:38 pm

Re: TFT touchscreen selection question

by adafruit_support_rick on Sun Jun 18, 2017 8:00 am

Have a look at this screen:
https://www.adafruit.com/product/1596
and this controller:
https://www.adafruit.com/product/1590

We also have a 7" display that will work with that controller
https://www.adafruit.com/product/2354

adafruit_support_rick
 
Posts: 34590
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: TFT touchscreen selection question

by NineFingers on Sun Jun 18, 2017 12:23 pm

Rick,
Thank you for the input. Will this this driver / library combination support displaying integers as easily as the one I am using now, or will I have to convert integers to a string first?

Currently the ili9341 library supports printing integers by using a simple tft.println(); command. I noticed that this library uses a specific tft.textWrite(string); command. If I have a variable that is stored as an integer will it display it properly?
Example below VAR_4 is a numeric variable stored as an INT.
Code: Select all | TOGGLE FULL SIZE
        tft.setCursor(60, i * 16); // defines starting text position for this code block
        tft.print("Item #"); // prints to the the TFT Screen
        tft.print(i); // prints to the the TFT Screen
        tft.print(" = "); // prints to the the TFT Screen
        tft.println(VAR_4); // prints to the the TFT Screen
        tft.setCursor(60, (i * 16) + 16); //sets cursor for printing


Thank you again for your time, I really want this project to be successful, and have now purchased WAY more hardware than needed due to my failing to research it properly first.

Jason

NineFingers
 
Posts: 23
Joined: Fri Jun 02, 2017 1:38 pm

Re: TFT touchscreen selection question

by adafruit_support_rick on Mon Jun 19, 2017 9:22 am

You don't have to use text mode. If you leave it in graphics mode, then the regular print statements work the same as the tft code you already have. Of course, you'll have to adjust your cursor coordinates, since this is a larger display.

adafruit_support_rick
 
Posts: 34590
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: TFT touchscreen selection question

by NineFingers on Mon Jun 19, 2017 9:30 am

Thank you again Rick. Order incoming. Now to sell the $75.00 worth of buttons I can no longer use,or..... start another project;)

NineFingers
 
Posts: 23
Joined: Fri Jun 02, 2017 1:38 pm

Re: TFT touchscreen selection question

by pburgess on Sun Jun 25, 2017 1:01 am

I don't have the same hardware on-hand to test with...but, since it's a subclass of Adafruit_GFX, all the same print behavior/functionality should be there.

Something you can try that'll give a pretty good indication is to install the Adafruit_RA8875 library and then copy your existing ILI9341 sketch, making changes in the #include and screen declaration to handle the other library...then try compiling. If it succeeds, that's a promising sign. If it complains about something when compiling, let me know and maybe we can get it behaving the same.

pburgess
 
Posts: 3849
Joined: Sun Oct 26, 2008 2:29 am

Re: TFT touchscreen selection question

by NineFingers on Sun Jun 25, 2017 11:36 am

pburgess wrote:I don't have the same hardware on-hand to test with...but, since it's a subclass of Adafruit_GFX, all the same print behavior/functionality should be there.

Something you can try that'll give a pretty good indication is to install the Adafruit_RA8875 library and then copy your existing ILI9341 sketch, making changes in the #include and screen declaration to handle the other library...then try compiling. If it succeeds, that's a promising sign. If it complains about something when compiling, let me know and maybe we can get it behaving the same.


Thank you. I have it partially working now. It is going to be a job to port it all over to a touch screen interface from mechanical buttons, but it will get done eventually. There were some differences in the code required..
such as "tft.textEnlarge" instead of "tft.setTextSize" and "tft.textSetCursor" instead of "tft.setCursor".
of course this could very well be operator error, as we all know I am hacking my way through this with a sledge hammer. Again many thanks for the awesome products, and the supporting nudges in the right direction. The young man who inspired me to build this came over last night and was truly excited to see the next phase of the project. Can't wait to share it with the community when it is done.

Jason
Ninefingers

NEW CODE:
Code: Select all | TOGGLE FULL SIZE
    // Begin Total Button instructions block

    if ((tx > (TTLxStart * xScale) && (tx <= (TTLxStart + DxSize) * xScale))) {
      if ((ty > (TRyStart * yScale) && (ty <= (TRyStart + DySize) * yScale))) {
        VAR_Grand_Total = (VAR_4_Sum + VAR_6_Sum + VAR_8_Sum + VAR_10_Sum + VAR_12_Sum + VAR_Mod);
        Serial.println (VAR_Grand_Total);

        tft.textMode();
        tft.textEnlarge(5); // temporary increase to font size
        tft.textSetCursor(350, 200 ); // defines starting text position for this code block
        tft.textTransparent(RA8875_WHITE);
        tft.print(VAR_Grand_Total); // Displays the grand total
        tft.graphicsMode();
      }
    }

NineFingers
 
Posts: 23
Joined: Fri Jun 02, 2017 1:38 pm

Re: TFT touchscreen selection question

by NineFingers on Sun Jun 25, 2017 2:03 pm

Okay I stand corrected, It worked fine until the integers being printed as text exceeded 9. To fix this issue I attempted to use the old ILI sketch as suggested. Test sketch posted below.
The screen background sets to GREEN as expected however none of the text displays. Any ideas what i did wrong?
Many thanks for the insight.
Jason
Ninefingers
Code: Select all | TOGGLE FULL SIZE
/******************************************************************
  This is an example for the Adafruit RA8875 Driver board for TFT displays
  ---------------> http://www.adafruit.com/products/1590
  The RA8875 is a TFT driver for up to 800x480 dotclock'd displays
  It is tested to work with displays in the Adafruit shop. Other displays
  may need timing adjustments and are not guanteed to work.

  Adafruit invests time and resources providing this open
  source code, please support Adafruit and open-source hardware
  by purchasing products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, check license.txt for more information.
  All text above must be included in any redistribution.
 ******************************************************************/
#include <Arduino.h>
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"


// Library only supports hardware SPI at this time
// Connect SCLK to UNO Digital #13 (Hardware SPI clock)
// Connect MISO to UNO Digital #12 (Hardware SPI MISO)
// Connect MOSI to UNO Digital #11 (Hardware SPI MOSI)
#define RA8875_INT 3
#define RA8875_CS 53
#define RA8875_RESET 9


Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
uint16_t tx, ty;

void setup()
{
  Serial.begin(9600);
  Serial.println("RA8875 start");
  /* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
  if (!tft.begin(RA8875_800x480)) {
    Serial.println("RA8875 Not Found!");
    while (1);
  }
  tft.displayOn(true);
  tft.GPIOX(true);      // Enable TFT - display enable tied to GPIOX
  tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
  tft.PWM1out(255);

  pinMode(RA8875_INT, INPUT);
  digitalWrite(RA8875_INT, HIGH);
}


void loop()
{

  tft.fillScreen(RA8875_GREEN); // clears screen and sets color to GREEN
  tft.setTextColor(RA8875_BLACK); // default LCD font color unless defined in a specific code block for one time use.
  tft.setTextSize(5); // default LCD font size unless defined in a specific code block for one time use.
  tft.setCursor(200, 200); // default cursor starting position
  tft.print("SYSTEM READY!"); // only displayed after code has been reloaded to Arduino

}

NineFingers
 
Posts: 23
Joined: Fri Jun 02, 2017 1:38 pm

Re: TFT touchscreen selection question

by adafruit_support_rick on Mon Jun 26, 2017 8:36 am

Phil - I've verified this. The GFX text doesn't work. Native RA8875 text does work.
I'll see if I can spot anything...

adafruit_support_rick
 
Posts: 34590
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: TFT touchscreen selection question

by NineFingers on Mon Jun 26, 2017 11:47 am

adafruit_support_rick wrote:Phil - I've verified this. The GFX text doesn't work. Native RA8875 text does work.
I'll see if I can spot anything...


Not sure what I have done but it appears to e working for now. If I come across a corner case that breaks it again I will post an update.

NineFingers
 
Posts: 23
Joined: Fri Jun 02, 2017 1:38 pm

Re: TFT touchscreen selection question

by NineFingers on Mon Jun 26, 2017 9:23 pm

Hey all,
Just a quick update, and a Many Thanking Ewe's to all of you.,
I now have a working proof of concept with the original mechanical button code, and the new touch screen control. Still have a LONG way to go, but I wanted to share with you. Thanks again Adafruit!!!!

code_merge.jpg
code_merge.jpg (214.55 KiB) Viewed 58 times


Jason
Ninefingers

NineFingers
 
Posts: 23
Joined: Fri Jun 02, 2017 1:38 pm

Please be positive and constructive with your questions and comments.