Little problem with UTFT Buttons and UTFT SDRaw.

Hi all, I have made a code that work very well using utft and utouch libs. I have only one issue.
Tha utft buttons lib can't use the VGA_TRANSPARENT color, so I can't see the picture under the buttons.
I have the images loaded via sdraw lib and I can see them on the display, but ofc the button is on top of the image and it goes "under" the button.
I could use bitmaps, but they fill up my arduino due and I must use the sdcard.
Should I do something like "layer level" like photoshop (supposing it is possible ofc)? or I'm just doing it the wrong way?
Has someone already faced this problem?

I am not a fan of the UTFT_Button library, I find it very stiff. Give mine a try, there should be plenty of examples to show you how it works.

http://forum.arduino.cc/index.php?topic=316351.25

HazardsMind:
I am not a fan of the UTFT_Button library, I find it very stiff. Give mine a try, there should be plenty of examples to show you how it works.

TFT Extension Version 2 - Libraries - Arduino Forum

Ok thank you I'll try the lib asap. Does it have "transparent" color for the buttons? Or the chance to load a RAW image from the SD lib?

It has FILL and NOFILL options. If you set it to NOFILL then the button will have just the outline and the text with no background.

And no, it does not read RAW files from an SD card, you are basically making the button yourself.

Ok it does work as intended with the provided examples, but when I try to load the sd lib I get this error

Arduino:1.6.5 (Windows 8.1), Scheda:"Arduino Due (Programming Port)"

In file included from _8_Buttons.ino:4:0:
C:\Users\Utente\Documents\Arduino\libraries\TFT_ExtensionV2/TFT_ExtensionV2.h:34:14: error: expected unqualified-id before numeric constant
 #define left 90
              ^
C:\Users\Utente\Documents\Arduino\libraries\SdFat/utility/ios.h:67:25: note: in expansion of macro 'left'
   static const fmtflags left       = 0x0001;
                         ^
C:\Users\Utente\Documents\Arduino\libraries\TFT_ExtensionV2/TFT_ExtensionV2.h:35:15: error: expected unqualified-id before numeric constant
 #define right 270
               ^
C:\Users\Utente\Documents\Arduino\libraries\SdFat/utility/ios.h:69:25: note: in expansion of macro 'right'
   static const fmtflags right      = 0x0002;
                         ^
C:\Users\Utente\Documents\Arduino\libraries\TFT_ExtensionV2/TFT_ExtensionV2.h:34:14: error: expected unqualified-id before numeric constant
 #define left 90
              ^
C:\Users\Utente\Documents\Arduino\libraries\SdFat/utility/ios.h:248:18: note: in expansion of macro 'left'
 inline ios_base& left(ios_base& str) {
                  ^
C:\Users\Utente\Documents\Arduino\libraries\TFT_ExtensionV2/TFT_ExtensionV2.h:34:14: error: expected initializer before numeric constant
 #define left 90
              ^
C:\Users\Utente\Documents\Arduino\libraries\SdFat/utility/ios.h:248:18: note: in expansion of macro 'left'
 inline ios_base& left(ios_base& str) {
                  ^
C:\Users\Utente\Documents\Arduino\libraries\TFT_ExtensionV2/TFT_ExtensionV2.h:35:15: error: expected unqualified-id before numeric constant
 #define right 270
               ^
C:\Users\Utente\Documents\Arduino\libraries\SdFat/utility/ios.h:312:18: note: in expansion of macro 'right'
 inline ios_base& right(ios_base& str) {
                  ^
C:\Users\Utente\Documents\Arduino\libraries\TFT_ExtensionV2/TFT_ExtensionV2.h:35:15: error: expected initializer before numeric constant
 #define right 270
               ^
C:\Users\Utente\Documents\Arduino\libraries\SdFat/utility/ios.h:312:18: note: in expansion of macro 'right'
 inline ios_base& right(ios_base& str) {

I suppose there are two constant with the same name, what should I do?

The ones in my library, you can put an under score in front of them ( _ ) try that

HazardsMind:
The ones in my library, you can put an under score in front of them ( _ ) try that

ok I'll try in some minutes. Does putting this underscore disable some essential function?

No, it just makes it different from the other libraries that also have left , right etc.

I'll make that change in my library when I release the new version.

Added:
Ok I just changed it to Tri_up, Tri_down, Tri_left, Tri_right. I wanted something simple, but then again you can't please everyone.

Ok thank you I'll start working on my display in a matter of minutes and try everything.
I'll post the results asap

edit: it seems that the "nofill" option actually doesn't make the button "nonfilled", but it simply makes it black. the images are just under the button, so I'm getting pretty much the same result that I had with the utftbutton lib, am I doing something wrong?

#include <UTFT.h>
#include <UTouch.h>
#include <TFT_ExtensionV2.h>
#include <SPI.h>
#include <SdFat.h>
#include <UTFT_SdRaw.h>
#define SD_CHIP_SELECT  42
SdFat sd;

UTFT    myGLCD(TFT01_50,22,23,31,33);
UTouch  myTouch(25,26,27,29,30);
UTFT_SdRaw myFiles(&myGLCD);

Base B(&myGLCD, &myTouch);
Box button(&B);

void setup()
{
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();
  myTouch.InitTouch(LANDSCAPE); 
  myTouch.setPrecision(PREC_EXTREME);
  myGLCD.fillScr(BLACK);
  
  Serial.begin(9600);
   while (!Serial) {
    ;
  }
  bool mysd = 0;
  while (!mysd)
  {
    if (!sd.begin(SD_CHIP_SELECT, SPI_HALF_SPEED)) {
    }
    else
    {
      mysd = 1;
    }
  }
  
  draw_Main();
  
  button.Coords(10, 10, 250, 110);
  button.Colors(NOFILL, NOFILL, NOFILL, ROUNDED);
  button.Draw();
}

void loop()
{
  button.Toggle();
}

void draw_Main()
{
  myFiles.load(10,10,240,145, "BUTTON.RAW", 32);
}

button.Colors(NOFILL, NOFILL, NOFILL, ROUNDED);

I have not seen anyone do that yet, but did it work for you?

No, unfortunately it doesn't work. It doesn't go transparent...it just goes black. I tryied to fill the screen with a color and then set the button color to transparent, but the button still remain black.

That's because it's supposed to be an on screen button. There is no transparency. You can modify the library if you want, all you need is a simple IF statement that goes above where it says "_Disp->setColor( x )"

Just add this. (Replace the x with the color variable that is in the function then save

if( x > 0)

~~ _Disp->setColor( x );~~

Edit: Actually don't touch the library. Instead of using .Touch() in your code, just use .getTouchState() and as long as you don't use .Draw() anywhere, you should have an invisible button.

Ok, I'll give it a go in a matter of hours, thank you again very much, you really have a lot of patience!

you really have a lot of patience!

I used to work in tech support, so patience actually is a virtue.

I have another question that could seem stupid but...how am I supposed to use the toggle? I mean, the objective is to "do something" for example turn a pin high or low when the button is toggled on or off. should I use switch case? thank you again very much

no just use the basic toggle method.

static byte lastState = 0, tog = 0;
byte buttonState = myTFT.getTouchState();

if( buttonState != lastState )
{
  if(buttonState == HIGH)
  {
    tog = !tog;
  }
  lastState = buttonState;
}

if(tog == true)
{
  // do something here
}
else {
 // do nothing
}