Arduino Forum

Using Arduino => Displays => Topic started by: -__- on Feb 25, 2013, 10:48 pm

Title: SeeedStudio TFT V2.0 text direction added
Post by: -__- on Feb 25, 2013, 10:48 pm
Hello all,
I have added code to allow for text direction on the V2.0 LCD shield from SeeedStudios.
I tried to upload the code at Seeed's forum but although the progress box indicated the files were uploaded, I have no idea where, so I'm putting them here.

The modified .cpp and .h files were tested on one of my sketches and also with the V1.0 example, text4Directions.  Both sketches work fine. For the example, change the #include statement from <TFT.h> to <TFTv2.h>, and add #include <SPI.h>.  I also commented out the TouchScreen  #include as it isn't used in this sketch. Finally, in void setup(), change from Tft.init; to Tft.TFTinit();.

I've also made a change to the color definitions, changing BRIGHT_RED to PINK, and adding DARK_GREEN and MAGENTA.

Regards,
-__-

Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: xrail on Mar 27, 2013, 04:22 pm
Great improvement.. Thank you... be able to rotate the text is a "must have"..

Just one more question...

How can I generate the color "Orange" ????

I have tried to use HEX codes for orange from the net, like the html ones but none is working..
The color has to be created in the library?

Thank you

Regards
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: -__- on Mar 27, 2013, 04:38 pm
New color definitions are defined in the header file, TFTv2.h.  Unless you have a utility to convert a color from a chart, for example, to a HEX value, you'll have to try various values until you get what you want.

Add your new color to the KEYWORDS text file if you want the name of your new color highlighted in the IDE.  The color will still be recognized by the compiler if you don't add it to the KEYWORDS file though. If you decide to add your new color to KEYWORDS, make sure you have the name of the color tabbed correctly else the IDE will not highlight it in your code.

-__-
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: xrail on Mar 27, 2013, 05:29 pm
Understood!!

Last thing...  do you have an exemple code on how to use the new text rotation function?

Tft.setOrientation(???????);


Cheers
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: -__- on Mar 27, 2013, 06:04 pm
Download the Version 1.0 files from: http://www.seeedstudio.com/wiki/File:TFT_Touch_Shield_libraries.zip (http://www.seeedstudio.com/wiki/File:TFT_Touch_Shield_libraries.zip).

Open the examples folder and open text4Directions.ino. You'll have to change the #include statements as indicated in the first post in this thread.

The text4Directions.ino sketch will show the directions syntax.

-__-
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: AffordableTechnology on Apr 21, 2013, 01:22 am

Hello all,
I have added code to allow for text direction on the V2.0 LCD shield from SeeedStudios.
I tried to upload the code at Seeed's forum but although the progress box indicated the files were uploaded, I have no idea where, so I'm putting them here.


Hi,

My thanks to John Martin for posting these mods - You saved my bacon!

For the record: I have found SeeedStudio to be excellent, but releasing a "new, greatly improved version" of their TFT display which is in fact a backward step, was very disappointing!  I had purchased two Ver1 displays for prototypes and testing, then decided to go with the "better" Ver 2 display in the finished project.  To my horror it could not run my software and I am due to deliver in a couple days.

:0At the very least, SeeedStudio should point out clearly in their product info that the "new improved" version lacks significant features found in the older product. - Shame on you SeeedStudio!

Regards,

Paul
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: -__- on Apr 21, 2013, 03:45 am



For the record: I have found SeeedStudio to be excellent, but releasing a "new, greatly improved version" of their TFT display which is in fact a backward step, was very disappointing!  I had purchased two Ver1 displays for prototypes and testing, then decided to go with the "better" Ver 2 display in the finished project.  To my horror it could not run my software and I am due to deliver in a couple days.

:0At the very least, SeeedStudio should point out clearly in their product info that the "new improved" version lacks significant features found in the older product. - Shame on you SeeedStudio!

Regards,

Paul



Paul,
Glad you were able to use my updates to Seeed's V2 TFT display.  I too was exceedingly disappointed at finding the libraries to be lacking text rotation. Not being a software guy, I figured I'd bug Seeed about it but after no urgency on their part I decided to have a go at it.  It actually turned out to be reasonably easy as the different controller apparently used the same address/data format as the V1 device.
Best regards, John

-__-
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: vocho on Aug 21, 2013, 08:42 pm
Tft.setOrientation(1);        ????
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: -__- on Aug 22, 2013, 04:12 pm

Tft.setOrientation(1);        ????


Please elaborate.

-__-
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: vocho on Aug 23, 2013, 12:08 am
Sorry, I try to put only Tft.setOrientation (1), in my arduino code but nothing happened to me, I'm new to this and hope you can help me. Nose as properly be put, I am using an arduino mega. regards
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: -__- on Aug 23, 2013, 03:16 am
Vocho,
1. Post your code.
2. Are you using the V1 LCD shield or the V2 shield?
3. Tft.setOrientation is not a sketch command; it is a library command. The sketch command for directions is: Tft.setDisplayDirect(Down2Up) for example.
The version 1 example sketch, text4Directions.ino, shows the syntax to be used for direction.

-__-
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: vocho on Aug 27, 2013, 05:17 pm
I am new to C, I hope I can help, good with regard to this I have taken another major problem that the rotation of the screen, I try to make a clock using DS1307 RTC with TINY, however does not show me the right way numbers, ie 1,2,3 but prints all over the account if done right of 0-59 but not let me see the numbers because they never clean the previous issue, I attached a picture, hoping you can help me I thank you in advance for the attention paid,

Code: [Select]
#include <stdint.h>
#include <SeeedTouchScreen.h>
#include <TFTv2.h>
#include <SPI.h>
#include <Wire.h> // specify use of Wire.h library.

// De Decimal a BCD
byte decToBcd(byte val){
  return ( (val/10*16) + (val%10) );
};

// De BCD a Decimal
byte bcdToDec(byte val){
  return ( (val/16*10) + (val%16) );
};
/*************************************/

/********** Variables Reloj **********/

byte seconds = 0;
byte minutes = 0;
byte hours = 0;
byte day = 0;
byte date = 0; //dia
byte month = 0;
byte year = 0;

int fecha=0;
char buufer[12];


unsigned long tiempo_s1, tiempo_s2=0, retardo_s1=50;

TouchScreen ts = TouchScreen(XP, YP, XM, YM); //init TouchScreen port pins

void setup()
{


   TFT_BL_ON;                                          //turn on the background light
   Tft.TFTinit();
   Wire.begin();
   
   
   Tft.fillCircle(40, 160, 30,BLUE); // (x,y, radio, color) BOTON 1
   Tft.drawString("AA", 18, 145, 3, WHITE);     //  'S', (X, Y), Tamño: 1, color: RED 

   Tft.fillCircle(120, 160, 30, BLUE); // (x,y, radio, color) BOTON 2
   Tft.drawString("B", 110, 145, 3, WHITE);     //  'S', (X, Y), Tamño: 1, color: RED 
   
   Tft.fillCircle(200, 160, 30, BLUE); // (x,y, radio, color) BOTON 3
   Tft.drawString("CC", 180, 145, 3, WHITE);     //  'S', (X, Y), Tamño: 1, color: RED 
   
   //Tft.setOrientation(1) // ==> If I modify this parameter 1-2 should rotate the screen to landscape mode?.
                            // Try to do a small clock, setDisplayDirect command only rotating characters?
 
}
void loop()
{
   

  Wire.beginTransmission(0x68);
  Wire.write(0x00);
  Wire.endTransmission();
  Wire.requestFrom(0x68, 7);
  seconds = bcdToDec( Wire.read());
  minutes = bcdToDec( Wire.read());
  hours = bcdToDec( Wire.read());
  day = bcdToDec( Wire.read());
  date = bcdToDec( Wire.read());
  month = bcdToDec( Wire.read());
  year = bcdToDec( Wire.read());

 

Tft.drawNumber(seconds, 157, 45,  4, WHITE);

Tft.drawNumber(minutes, 105,  45,  3, WHITE);
Tft.drawString(";"    , 141, 42,  3, WHITE);

Tft.drawString("/"    , 71,  82,  3, WHITE);
Tft.drawNumber(month  , 88,  85,  3, WHITE); //(x,y)

Tft.drawNumber(date  , 33,  85,  3, WHITE); //(x,y)
Tft.drawString("/"    , 126,  82,  3, WHITE);

fecha=year+2000;
Tft.drawNumber(fecha  , 144,  85,  3, WHITE); //(x,y)
     
     
}


Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: JohnPijnappel on Oct 25, 2013, 06:34 pm
Hello,
About the setOrientation() command.
I installed the new libraries and the new commands for triangle and magenta worked fine (commands turned red). Congratulations !
So the files are installed well and are implemented well. The code compiles well and uploads well.
But setOrientation doesn't function. (The word is still black, doesn't turn red: so, not recognized.)
The orientation of the display doesn't change either (not for (0), (1) or (2).
The text stays in  the same portrait orientation.
The comment about text4directions only flips characters vertical or horizontal. It doesn't rotate the text nor the entire
orientation 90 degrees.
Do you know what's wrong.
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: -__- on Oct 26, 2013, 04:30 am

Hello,
About the setOrientation() command.
I installed the new libraries and the new commands for triangle and magenta worked fine (commands turned red). Congratulations !
So the files are installed well and are implemented well. The code compiles well and uploads well.
But setOrientation doesn't function. (The word is still black, doesn't turn red: so, not recognized.)
The orientation of the display doesn't change either (not for (0), (1) or (2).
The text stays in  the same portrait orientation.
The comment about text4directions only flips characters vertical or horizontal. It doesn't rotate the text nor the entire
orientation 90 degrees.
Do you know what's wrong.


setOrientation is NOT a sketch command. It will NOT be recognized when you compile your code.

I'm not sure what text4directions comments you refer to (it's late, here), but to change screen orientation, and thus text direction, you must use:
Tft.setDisplayDirect(XXXXXX); where XXXXXX is LEFT2RIGHT, RIGHT2LEFT, DOWN2UP, or UP2DOWN, in your code (sketch).

Regards,
-__-
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: JohnPijnappel on Oct 26, 2013, 12:02 pm
The comments you make with setDysplayDirect:  the words left2right and right2left and down2up or up2down suggests that it flips in a vertical or horizontal way, and that's not the same as rotating from portrait to landscape.
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: arduinodlb on Oct 26, 2013, 12:15 pm
Vocho,

You could try using UTFT by Henning Karlsen. It has text rotation and portrait/landscape mode built in. I haven't tried it with the Seeedstudio TFT however.
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: -__- on Oct 26, 2013, 03:39 pm

The comments you make with setDysplayDirect:  the words left2right and right2left and down2up or up2down suggests that it flips in a vertical or horizontal way, and that's not the same as rotating from portrait to landscape.


Did you actually try it?

-__-
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: -__- on Oct 26, 2013, 04:22 pm

I am new to C, I hope I can help, good with regard to this I have taken another major problem that the rotation of the screen, I try to make a clock using DS1307 RTC with TINY, however does not show me the right way numbers, ie 1,2,3 but prints all over the account if done right of 0-59 but not let me see the numbers because they never clean the previous issue, I attached a picture, hoping you can help me I thank you in advance for the attention paid,



Vocho,

I didn't see any picture of your problem.  Your code, which has no text direction commands,  compiles when I remove Wire.write(0x00);, and when run, displays some text and three circles with text within. 

I don't have the RTC hardware, so I won't receive any data.

I think the problem you have with "but prints all over the account if done right of 0-59 but not let me see the numbers because they never clean the previous issue" is that the you aren't clearing a displayed number before the next number is drawn.

That's just a guess as your picture you say you attached isn't here.

-__-

Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: slushbilly on Nov 16, 2014, 03:26 am
I was wondering what the difference is between the new and old library as far as the font style goes? It seems a lot larger now and more space is between the text. As far as the changes for the text direction.... Thanks a lot. Works great and was exactly what I was looking for.
Title: Re: SeeedStudio TFT V2.0 text direction added
Post by: odelay17 on Oct 23, 2015, 12:24 am
FOR THOSE EXPERIENCING ISSUES WITH NUMBER ORIENTATION

In addition to the OP's orientation code, another issue will exist when dealing with number printouts in different orientations.  Hopefully I save some time for others having this this issue.  If you do not change the logic when writing a number larger than a single integer, the number will appear to stack on top of itself.

In my example my orientation is changed to "Tft.setDisplayDirect(UP2DOWN);"

In this landscape configuration, in order to get the numbers to display correctly you must edit the TFTV2.CPP file.  Note the changes I needed to make to the poX variable.  I needed to change the font space to move with respect to poY instead of poX.  Hope this helps.

Code: [Select]
INT8U TFT::drawNumber(long long_num,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor)
{
    INT8U char_buffer[10] = "";
    INT8U i = 0;
    INT8U f = 0;

    if (long_num < 0)
    {
        f=1;
        drawChar('-',poX, poY, size, fgcolor);
        long_num = -long_num;
        if(poX < MAX_X)
        {
            poY += FONT_SPACE*size; /* Move cursor right            */
        }
    }
    else if (long_num == 0)
    {
        f=1;
        drawChar('0',poX, poY, size, fgcolor);
        return f;
        if(poX < MAX_X)
        {
            poY += FONT_SPACE*size;/* Move cursor right            */
        }
    }

    while (long_num > 0)
    {
        char_buffer[i++] = long_num % 10;
        long_num /= 10;
    }

    f = f+i;
    for(; i > 0; i--)
    {
        drawChar('0'+ char_buffer[i - 1],poX, poY, size, fgcolor);
        if(poX < MAX_X)
        {
            poY+=FONT_SPACE*size;  /* Move cursor right            */
        }
    }
    return f;
}