Scroll Large Bitmap on TFT LCD

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello.  Those of you with Arduino and TFT display are probably well acquainted with the example that comes with most libraries that loads a bmp from sd card and displays it.  I decided to ad touchscreen functionality to this sketch.  Once the first image is loaded and displayed, the program waits for the user to tap the screen to load the next image.  After learning how to accept input from the touch screen, I decided to try something more exciting.  I wanted to load a full size image (one larger than the 320 by 240 display and tap the screen in the appropriate region to scroll in that direction.  I am working on scrolling to the left in portrait mode.  The program scrolls one screen width (240 pixels) to the left and displays the next section of the image.  But if I go beyond one screen width (if I tap again) the scan lines are jumbled and out of order and misplaced on the screen.  As if it has lost its place in the bmp file.  I just can't figure it out.  I have attached the code of the entire program.  If you put a large image on a sd card in a directory called "fullsize," you can try it out.  The code comes from the library MCUFRIEND_kbv for ili9341 2.4 lcd examples.  I am using a touch shield version with arduino uno.  A small edit will allow you to have the touchscreen enabled slide show for normal sized (240x320) images.  I already have that working.  I think the function showBMP is losing its place in the row/ column bits of the bmp file.  But I can't fix it.

Attachment(s): 

This topic has a solution.
Last Edited: Wed. Nov 29, 2017 - 06:03 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your ILI9341 is 240x320.  i.e. vertical scrolling is always in the 320 direction.

 

As you have seen from the demo sketch hardware scrolling is top to bottom in Portrait mode.

And left to right in Landscape mode.

 

Most TFT controllers can do vertical scrolling.   Very few can scroll in both directions like the RA8875.

 

If you have a large bitmap on SD,   I suggest that you change to Landscape mode if you want to scroll left to right.

It should be possible to move the image smoothly with the hardware scroll.

 

If you have smooth scroll left to right,  you can't have it top to bottom or vice versa.    If you are determined to scroll an any direction,  buy a Raio RA8875.

 

If scroll speed is not important,  it should be easy to modify the showBMP(bmp, destX, destY) to showBMP(bmp, bmp_X, bmp_Y, destX, destY) i.e. read the BMP from a different start point.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the information.  If only these cheap TFTs on Ebay came with documentation.  The Raio RA8875 probably comes on larger, more expensive displays, as I haven't seen the small screens with this controller.  I'm still puzzled as to why I could scroll horizontally in portrait mode until x < -240.  I will probably upgrade to a larger display at some point.  Thank you for answering.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

 

If scroll speed is not important,  it should be easy to modify the showBMP(bmp, destX, destY) to showBMP(bmp, bmp_X, bmp_Y, destX, destY) i.e. read the BMP from a different start point.

 

David.

 

Thanks for the tip.  I have it working the way I want it to now.  You can tap the screen on the left, right, top, and bottom to "scroll" the image in the desired direction.  It just loads the portion of the image to be displayed on the screen each time through the loop.  I am now able to use 1280 by 1024 or larger images that are greater than 4 megs in size.  Scrolling to the bottom of the image and then scrolling back up will cause garbage scan lines, but if you tap the bottom of the screen it will jump back to the top of the image.  Horizontally, it will automatically wrap the screen.  Also, If an image is more suitable for landscape mode (width > height), it will display incorrectly or as garbage scan lines.  If you simply rotate it 90 degrees when saving it to the memory card, this will fix the problem and it will display correctly. Code is attached.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

barrage_97 wrote:
If only these cheap TFTs on Ebay came with documentation

Why do you think they are cheap??!

 

This is always the case with cheap stuff on places like ebay, ali-express, etc

 

If you want documentation & support, you'll have to cough-up and go to one of the "mainstream" distributors.

 

https://www.avrfreaks.net/comment...

 

https://www.avrfreaks.net/comment...

 

#CheapStuff

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

barrage_97 wrote:
If only these cheap TFTs on Ebay came with documentation

Why do you think they are cheap??!

 

This is always the case with cheap stuff on places like ebay, ali-express, etc

 

If you want documentation & support, you'll have to cough-up and go to one of the "mainstream" distributors.

 

https://www.avrfreaks.net/comment...

 

https://www.avrfreaks.net/comment...

 

#CheapStuff

 

 

True.  Although the 9341 data sheet is available online.  I was having more of a programming problem.  Instead of changing the x, y position (as I would on the PC), I should have been changing the offset where I start reading data from the bmp file instead.  That was the key.  David's point gave me that idea.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

If you have a programming problem, pencil, paper and a cup of tea generally solves it.
.
With a scrolling window problem, cut out a small rectangle of paper. Then move it around your large sheet of paper.
This will show you how to manipulate your BMP and display. Scribble notes on the big sheet with your pencil.
.
Seriously, human brains work better with something you can see.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the help, David.  I still wish the screen had about 8 megs of GRAM so I could load the entire image in at once!