Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

TFT, move graphic image
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

TFT, move graphic image

by BeckerBoards on Mon Nov 23, 2020 2:59 pm

I’m using the 3.5" TFT 320x480 + Touchscreen Breakout Board w/MicroSD Socket - HXD8357D in a project with a spectrum waterfall display on part of the screen. I’m creating bit mapped graphics and sending to the display via SPI. I'd like to shift the image down by one pixel when updating it (after which I will fill in the first pixel line above with new).

Is there a way to get the display to do this directly in its on board display memory without erase and rewriting all the pixels of this image over again? Obviously rewriting is redundant here as well as time consuming (even worse, using SPI) which would limit the update rate significantly. I’ve been through your tutorials and didn’t see any command that might be appropriate for this. Thanks for your help!

BeckerBoards
 
Posts: 4
Joined: Sun Sep 29, 2019 6:06 pm

Re: TFT, move graphic image

by mikeysklar on Tue Nov 24, 2020 6:27 pm

CircuitPython or Arduino?

mikeysklar
 
Posts: 6231
Joined: Mon Aug 01, 2016 8:10 pm

Re: TFT, move graphic image

by BeckerBoards on Wed Nov 25, 2020 3:54 pm

Arduino on a Teensy 4.1. I have tested it with the graphics test example and it’s all working as expected. I’m working on integrating it with my own code now. Thanks for the reply.

BeckerBoards
 
Posts: 4
Joined: Sun Sep 29, 2019 6:06 pm

Re: TFT, move graphic image

by BryonMiller on Thu Nov 26, 2020 10:29 am

I'd like to shift the image down by one pixel
Depends on what you mean by "down". The HX8357D controller has a "vertical scrolling" function. Vertical is defined when you are looking at the display in portrait orientation as opposed to landscape orientation. The Adafruit HX8357 library does not offer support for this function so you have to roll your own.

You are welcome to try mine. Add the following in your setup after the display is initialized.

Code: Select all | TOGGLE FULL SIZE
#define HX8357_VSCRDEF 0x33   //(Vertical Scrolling Definition)   
#define HX8357_VSCRSADD 0x37  //(Vertical Scrolling Start Address)   
void setupScroll()
{
tft.setAddrWindow(0,0,320,480);
uint16_t TFA = 0x00;     // Top Fixed Area
uint16_t VSA = 480; // Vertical Scrolling Area
uint16_t BFA = 0x00;     // Bottom Fixed Area

tft.startWrite();
digitalWrite(TFT_CS, LOW);
digitalWrite(TFT_DC, LOW);
SPI.transfer(HX8357_VSCRDEF);
digitalWrite(TFT_DC, HIGH);
SPI.transfer(TFA >> 8);
SPI.transfer(TFA & 0xFF);
SPI.transfer(VSA >> 8);
SPI.transfer(VSA & 0xFF);
SPI.transfer(BFA >> 8);
SPI.transfer(BFA & 0xFF);
delay(1);
digitalWrite(TFT_CS , HIGH);
tft.endWrite();
               
}

Then call the following when you want to scroll the display by 'i' pixels
Code: Select all | TOGGLE FULL SIZE
void scroll(uint16_t i)
{
uint16_t VSP = 0x01;     //  Vertical scrolling start address
VSP = i;  //  Vertical scrolling start address

tft.startWrite();
digitalWrite(TFT_CS, LOW);
digitalWrite(TFT_DC, LOW);
SPI.transfer(HX8357_VSCRSADD);
digitalWrite(TFT_DC, HIGH);
SPI.transfer(VSP >> 8);
SPI.transfer(VSP & 0xFF);
delay(1);
digitalWrite(TFT_CS , HIGH);
tft.endWrite();
}


I pulled these snippets out of my working program and I think they are all you need. If this does not work, let me know.

BryonMiller
 
Posts: 214
Joined: Fri Mar 04, 2016 10:34 am

Re: TFT, move graphic image

by BeckerBoards on Thu Nov 26, 2020 11:02 pm

Hi Bryon, thanks for the reply. I am using the display in landscape mode. In fact, I send a rotate by 270 to it right after the begin(). It has to be in landscape for what I’m doing.

I looked over and understood what you sent. Clearly from what you said this command set would only work for portrait mode. I see that you’re directly commanding the controller. I hadn’t gone that far just yet so I’ll have to go find the data sheet for the controller.

So, I’ve got some investigation work to go do. When I’ve looked into it a little more I’ll post here again what I’ve found. Your example set me on the right path and hopefully there’ll be a similar command that I can use for scrolling down by a single graphic line in landscape mode.

BTW, the code you sent also exposes the byte order for transfer and shows a working model for wiggling the control bits. That in itself is useful just to know how the controller expects things to be sequenced. Thanks again for that.

BeckerBoards
 
Posts: 4
Joined: Sun Sep 29, 2019 6:06 pm

Re: TFT, move graphic image

by BryonMiller on Thu Nov 26, 2020 11:26 pm

Here is controller data sheet https://cdn-shop.adafruit.com/datasheets/HX8357-D_DS_April2012.pdf. I only found what they call vertical scrolling. There is only one place I see mention of horizontal scrolling but they say it is not applicable.

If you do find anything please let me know.

Bryon

BryonMiller
 
Posts: 214
Joined: Fri Mar 04, 2016 10:34 am

Re: TFT, move graphic image

by BeckerBoards on Sat Nov 28, 2020 1:59 am

I combed through the data sheet as well and found all the things that you just mentioned. I’m afraid that vertical scrolling in landscape is not a possibility. It also mentions that TFA + VSA + BFA = 480 is required thereby reinforcing that vertical scrolling will only work in portrait mode.

I’ve stared at the ceiling for a bit and figured out a different way to present the information for my waterfall display that does not require scrolling. Scrolling would be best but I’ll have to settle for something a little less. Unfortunately these are usually things that we only find out after getting fairly committed to using a specific piece.

I have to say that other than this issue, the display looks great and is easy to use with the libraries Adafruit has provided. I found that using a horizontal line (448 pixels) created using drawPixel() in a loop took only 7mS and filling the area I’m using (80 lines) took just a little over half a second using SPI. At this point I’m going to close this thread as I think this is probably a dead issue unless i trip across something unexpected as I work with this further. Thanks for your help with this!

BeckerBoards
 
Posts: 4
Joined: Sun Sep 29, 2019 6:06 pm

Please be positive and constructive with your questions and comments.