New TFT Extension Library

Hi HazardsMind,

Heres my problem. Ignore the blob in button 1 area, it's the protective film thats blistered.

Photo 1 is start / reset.
Photo 2 is menu button pressed, to get menu 2.
Photo 3 is menu button pressed, to go back to menu 1.
Photo 4 is menu button pressed, to goto menu 2 again.

From then on, every time the menu button is pressed, all i get is photo 3 or 4?

Dizzwold.

I know you don't want to copy my code directly, so show me what your code looks like.

Whenever I give you a code I test it fully to make sure it looks and works correctly.

Hi HazardsMind,

Heres the code. The only things that i should have changed is for my controller and touch, button sizes and the on screen data.

Dizzwold.

#include <UTFT.h>
#include <UTouch.h>
#include <TFT_Extension.h>
UTFT myGLCD(ILI9327, 38, 39, 40, 41);
UTouch myTouch( 6, 5, 4, 3, 2);
TFT_Extension myTFT(&myGLCD, &myTouch);

#include <VirtualWire.h>

char remote[4] = {'X', 'Y', 'Z', '\0'};
byte Data = 0;
extern uint8_t SmallFont[];

void setup()
{
  //Serial.begin(57600);
  // Initialise the IO and ISR
  vw_setup(2000);	// Bits per sec, must match receiver.
  vw_set_tx_pin(51); // Data Pin, change for your needs

  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();
  myGLCD.setFont(SmallFont);
  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);
  //pinMode(53, OUTPUT); // for my purposes
  //digitalWrite(53, HIGH); // for my purposes
  myTFT.ExtSetup();
  myTFT.SetLatchButtonColors(0, GREEN, BLUE, FILL, ROUNDED);
  myTFT.SetLatchButtonText(0, "Menu 2", "Menu 1", Small, WHITE);

  myGLCD.fillScr(BLACK);
}

void loop()
{
  static byte last = 255, lastMenu = 255;

  byte MenuButton = myTFT.LatchButton_Draw(110, 190, 290, 220, 0);

  if (MenuButton != lastMenu) // set button colors
  {
    lastMenu = MenuButton;
    if (MenuButton == 0)
      Menu_1();
    else
      Menu_2();
      
  myTFT.ResetAllLatchButton();
  
  }

  bitWrite(Data, 0, myTFT.LatchButton_Draw(10, 10, 90, 80, 1 + (MenuButton ? 8 : 0)));
  bitWrite(Data, 1, myTFT.LatchButton_Draw(110, 10, 190, 80, 2 + (MenuButton ? 8 : 0)));
  bitWrite(Data, 2, myTFT.LatchButton_Draw(210, 10, 290, 80, 3 + (MenuButton ? 8 : 0)));
  bitWrite(Data, 3, myTFT.LatchButton_Draw(310, 10, 390, 80, 4 + (MenuButton ? 8 : 0)));
  bitWrite(Data, 4, myTFT.LatchButton_Draw(10, 100, 90, 170, 5 + (MenuButton ? 8 : 0)));
  bitWrite(Data, 5, myTFT.LatchButton_Draw(110, 100, 190, 170, 6 + (MenuButton ? 8 : 0)));
  bitWrite(Data, 6, myTFT.LatchButton_Draw(210, 100, 290, 170, 7 + (MenuButton ? 8 : 0)));
  bitWrite(Data, 7, myTFT.LatchButton_Draw(310, 100, 390, 170, 8 + (MenuButton ? 8 : 0)));


  if (MenuButton == 0)
    remote[1] = Data;
  else
    remote[2] = Data;

  if (Data != last) // Debug and see what the value is
  /*{
    myGLCD.setColor(BLACK);
    myGLCD.print("   ", 0, 220);
    myGLCD.printNumI(int(Data), 0, 220);
    last = Data;
  }*/

  if (Data == 0)
  {
    remote[0] = 'X';
    remote[1] = 0xFF;
    remote[2] = 0xFF;
  }
  else
    remote[0] = 'A';

  //myGLCD.printChar(remote[0], 0, 200);
  vw_send((uint8_t *)remote, strlen(remote));
}

void Menu_1()
{
  myGLCD.clrScr();
  
 

  myTFT.SetLatchButtonColors(1, PURPLE, BLUE, FILL, ROUNDED);
  myTFT.SetLatchButtonText(1, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(2, PURPLE, BLUE, FILL, ROUNDED);
  myTFT.SetLatchButtonText(2, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(3, PURPLE, BLUE, FILL, ROUNDED);
  myTFT.SetLatchButtonText(3, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(4, PURPLE, BLUE, FILL, ROUNDED);
  myTFT.SetLatchButtonText(4, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(5, PURPLE, BLUE, FILL, ROUNDED);
  myTFT.SetLatchButtonText(5, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(6, PURPLE, BLUE, FILL, ROUNDED);
  myTFT.SetLatchButtonText(6, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(7, PURPLE, BLUE, FILL, ROUNDED);
  myTFT.SetLatchButtonText(7, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(8, PURPLE, BLUE, FILL, ROUNDED);
  myTFT.SetLatchButtonText(8, "ON", "OFF", Small, WHITE);
  
  //myTFT.SetLatchButtonColors(0, GREEN, BLUE, FILL, ROUNDED);
  //myTFT.SetLatchButtonText(0, "Menu 2", "Menu 1", Small, WHITE);
  
  
}

void Menu_2()
{
 // myGLCD.clrScr();
  
  
  
  myTFT.SetLatchButtonColors(1 + 8, PURPLE, GREEN, FILL, ROUNDED);
  myTFT.SetLatchButtonText(1 + 8, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(2 + 8, PURPLE, GREEN, FILL, ROUNDED);
  myTFT.SetLatchButtonText(2 + 8, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(3 + 8, PURPLE, GREEN, FILL, ROUNDED);
  myTFT.SetLatchButtonText(3 + 8, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(4 + 8, PURPLE, GREEN, FILL, ROUNDED);
  myTFT.SetLatchButtonText(4 + 8, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(5 + 8, PURPLE, GREEN, FILL, ROUNDED);
  myTFT.SetLatchButtonText(5 + 8, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(6 + 8, PURPLE, GREEN, FILL, ROUNDED);
  myTFT.SetLatchButtonText(6 + 8, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(7 + 8, PURPLE, GREEN, FILL, ROUNDED);
  myTFT.SetLatchButtonText(7 + 8, "ON", "OFF", Small, WHITE);
  myTFT.SetLatchButtonColors(8 + 8, PURPLE, GREEN, FILL, ROUNDED);
  myTFT.SetLatchButtonText(8 + 8, "ON", "OFF", Small, WHITE);
  
  //myTFT.SetLatchButtonColors(0, GREEN, BLUE, FILL, ROUNDED);
  //myTFT.SetLatchButtonText(0, "Menu 2", "Menu 1", Small, WHITE);
  
  
}/code]

You should have done this a long way back, but since we are using more buttons, you need to update NumOfButtons in the TFT_Extension.h file. Make it 20 and save, that should clear up the weird Big font issue you are having with your buttons.

Also the clrScr should be commented out from here. This is what is causing your menu button to not work correctly.

void Menu_1()
{
myGLCD.clrScr();

Hi HazardsMind,

How stupid do i feel. Stupid stupid school-boy-error.

Dizzwold.

I've been reading into saving the button states for power saving with a physical on off switch.

I was looking at first, to use the EEPROM, but from reading, most advise is to avoid using the EEPROM, but to us SPRAM instead.

The EEPROM can be used apparently 100,000 times.

Any thoughts on this.

Dizzwold.

Sorry, just read SPRAM = Volatile.

I guess it would have to be EEPROM.

Dizzwold.

Does your display have an SD card slot?

Yeah. But from reading others with a similar TFT, it's not that reliable?

Dizzwold

How so? Have you tried it with your display? All you need to be able to do is be able to write and read two bytes.

To be honest, i've never given it a thought.

Dizzwold.

Give it a try.

To begin with, I wouldn't know where to start, i've never looked at using an SD card. Mostly because of the bed reports i've read and the lack of information.

Since my last post i've been trying to find a pin-out for my TFT.

I've found a board, not quite identical to the 1 in the following Arduino Russia site, post 320.
I have the 3.6" mcufriend unit. The touch controller IC in the upper right, is on my board in the upper left between the double header and the touch pins, but looking a broken TFT i have the pins-outs are the same.

Actually if you goto posts 327 & 328, this is my exact unit.

Also on the previous page, #6, post 274, there are some comments about having to add extra 10k resistors in addition to the resistor packs.

Regarding the extra 10k resistors, this is possibly why i've read bad reports about using the SD card.

Now i've found this wealth of info on my units, i know there are many others on this 'the english forum', that have had the same problems, not knowing pin-out, touch controller and screen controller. This on it's own deserves it's own thread.

Dizzwold.

Hi HazardsMind,

Forgot my manners earlier with my shame.

Thank you for proof read my error. LOL.

Thank you for your assistance.

Dizzwold.

I was playing around with the transmitter sketch and my new library, TFT_ExtensionV2. And although the sketch size in bytes wasn't that different from the one you have now, the global variable usage was incredibly less!

You might not know what this means, but it is VERY good for the SRAM usage (something very precious and limited).

Using my new library, the global variable usage was around 312 bytes, but the one you have now uses 2000+ bytes. Yikes.

Big difference and yet the code looks nicer, performs faster and even the visuals look better. The buttons have padding now, so you get a white rim around the buttons (color can be changed).

The only problem with my new library is, its quite a steep learning curve. Each button is its own class and only uses the memory it needs to work instead of wasting memory on things that are not needed or are never used. I put in all the same features like regular touch and release, latching and even delay touch.

Same 3 types too, Box, Circle and Triangle, but I am also working on allowing the user to design their own custom button. So if you want a button that's a star or a trapezoid, you can now have it. You can also make crazy shapes and it will still function as a button.

I am still deciding whether or not to give you the library, only because it will be an enormous learning curve for you and also because I can see you are still struggling with my current library.

I'll get back to you on that decision.

Hi HazardsMind,

Photos as promised. Sorry for the blurring, but you get the idea.

Dizzwold.

@Dizzworld: i did the same thing for my 5' screen :slight_smile:
There i just one difference: Is splitted the pins for 3.3v and 5V by using an SPI (2x3) connector and soldered some pins together. Now i have 1x6 or 2 inputs for 3.3V, 2 for 5v and 2 for Ground. 3 pins are in use for my screen, 3 are left to do other stuff.

I have an etherDue with Power over ethernet, the reset button is located in the middle of the board instead of the edge of the board. (like most arduino's) :frowning:
So i added the blue cable as reset line. I just touch the other end of the cable against the ethernetjack to reset my board. :slight_smile:

Now i'm looking for a descent GUI library to use. But it seems hard to find these libs...

Hi VinzzB,

Firstly, i'm no master or guru on this subject. The main issue is what is the display driver / controller, but you won't find this from looking. You would basically have to take the TFT apart 'destroy it' ,to find out.

Do you have any other information on the TFT?

Can you contact the vendor / seller for more info?

That's the best start i can advise, with-out more info.

I use Henning Karlsen's UTFT & UTouch libraries. Please donate to Henning, as he has put a lot of time into his libraries.

The reason i've documented some stuff on the TFT 'that i have', is because, so little is known about it. A very poorly documented unit. The most of the information i have found, have been on Russian sites.

If you can give more info on your TFT, i'm more than willing to help if i can.

Dizzwold.

Hi HazardMind I have a few problems with your last Password Sketch from here

http://forum.arduino.cc/index.php?topic=217873.75#bot

first BUG

if I just press the * button and nothing else the display prints GOOD

the same

if I just press the # button and nothing else the display prints GOOD

second BUG

if I just press 3 and then * button the display prints GOOD

the same

if I just press 3 and then # button the display prints GOOD

The password is not checked , it´s always good

I use

IDE 1.6.5
UTFT last
UTouch last
TFT_Extension from your Github

easyplayer

Thats because of this here.

else
{
PassFound = checkPassword(2651);
password = 0;
delay(1000);
myGLCD.print(" ", CENTER, 1);
}

I don't remember if I did this just as a test, but 2651 should be replaced with password