Optimized ILI9341 TFT Library

Status
Not open for further replies.
Sorry, I am not sure about all of the things that are in or not in the GFX library. But I do see functions in adafruit GFX library like:
drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[], int16_t w, int16_t h);

But again this is nothing special, that is the code just does:
Code:
void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
  const uint16_t bitmap[], int16_t w, int16_t h) {
    startWrite();
    for(int16_t j=0; j<h; j++, y++) {
        for(int16_t i=0; i<w; i++ ) {
            writePixel(x+i, y, pgm_read_word(&bitmap[j * w + i]));
        }
    }
    endWrite();
}
So it writes out one pixel at a time. So again it assumes you have the right size and it only updates that portion of the display that you specify.

Sort of like writeRect.

As for writeRect leaving stuff on screen? It all depends on how you use it. Obviously if your image that you are using is the size of the screen, you can then simply setup to have the whole image directly in an array of 16 bit values, which you go directly to the screen...

writeRect(0,0, tft.width(), tft.height, bmpColors);

Which again does something similar:
Code:
void ST7735_t3::writeRect(int16_t x, int16_t y, int16_t w, int16_t h, const uint16_t *pcolors)
{
  beginSPITransaction();
  setAddr(x, y, x + w - 1, y + h - 1);
  writecommand(ST7735_RAMWR);
  for (y = h; y > 0; y--) {
    for (x = w; x > 1; x--) {
      writedata16(*pcolors++);
    }
    writedata16_last(*pcolors++);
  }
  endSPITransaction();
}
The main difference is how fast. That is the drawRGB... will output something like:
(1+2+2+1+2+2+1+2) = 13 bytes per pixel

The writeRect: will write the first part out (1+2+2+1+2+2+1) = 11 bytes for the start of rectangle and then 2 bytes for each pixel.

As for what is shown on screen like white or the like. That you need to take care either way. They only touch the portion of the screen you tell it to do.
 
I will try this tomorrow. Also, what file is the writeRect function in, and what line? I can't seem to find it in the files anywhere.
 
Update: I tried it out and the text changes to orange when I use writeRect, but the program claims that the writeRect function is not in the ST7789_t3 library. If this is the best way to quickly draw my bitmap, then I want to use it. It would just appear that this particular function in not in the ST7789_t3 library.
 
I hate to be a bother, but is there any kind of update on the situation. I do apologize if I am causing you any trouble.
 
It is hard to say when @PaulStoffregen may pull in the Pull request into the released branch. Hopefully by the time of the next release.

However in the mean time you can always download my branch off of Github and work with it.
https://github.com/KurtE/ST7735_t3/tree/writeRect_reset_delay

You can simply clone it (or download a zip file), and put it into the folder: <Where your Arduino sketches go>/libraries/ST7735_t3

And then Arduino should use that version instead of the one installed by Teensyduino...
 
I did that, and everything works as it should except for the writeRect function. I'm finding some trouble with the format of the embedded bitmap file. I am seeing many different formats online, but I am not sure which is that one I'm looking for.
i.e. const unsigned long, const long, const short, or const unsigned short

Other than that I believe it comes down to the converter I am using to create my bitmap array.
 
I am unsure, what you are saying, with except writeRect...

Are you saying writeRect does not exist or are you saying, you're data is not displaying properly?

If does not exist, than you probably did not choose the correct branch of my fork.
 
I apologize for not being clear. I am saying that I do have the writeRect function in your fork of the library. As you know, it has the x coord, the y coord, the width, the height, and the actual bitmap file for the function arguments. I want to make sure I know how to properly enter the bitmap as the 5th argument. In other words, I am not exactly sure which type of data the bitmap array must be, other than an array type. You see, the code compiles correctly, but the image displayed on the screen is not my bitmap at all. I hope this helps clarify what I am looking for.
 
When I say "which type of data", I am referring to the const, long, short, and unsigned definitions of the array. It would be best if you has some type of example code of how you yourself would actually use this function.
 
The color array is setup to take the colors in the 16 bit color format: Each pixel has a 16 bit color associated with it, which I believe is the RGB: 5x6x5 bit format...
 
So after a lot of testing, I got the writeRect function wot work. However, I am getting a white background for the rest of the bitmap. Is there any way that I can get it to work with a transparent background? I could simply change all of the 16-bit white color values to the background color, but I would like to avoid that if possible. Any ideas? I have a picture linked so you can see my issue.

https://drive.google.com/file/d/0BzH-QlCu7hs4SWhfdGZJOExNemo5dF91WWs1UkZaclp4Yy1z/view?usp=sharing
 
Hello once again.
I was wondering if it is possible to draw rectangles from right to left. I know that the arguments are (x, y, width, height, color), and I am not sure if the width can be drawn in a negative direction. I saw some code in the source files that imply that I should only be positive width values, but I want to be positive, as I need to draw rectangle in that direction. I could probably find a way to do it without a negative width, but that would be easier and is desirable.
 
Status
Not open for further replies.
Back
Top