Scroll Down TFT 2'8 inch LCD Arduino

Hello,

I'm working on a project in which I'm getting readings from a sensor and all this data is display on an Adafruit TFT LCD. I manage to process the data and display it. But, because there are many samples (data) displayed on a vertical column, once they reach the bottom of the screen, they cant be printed anymore. So, I'm wondering if there is any function or library I can use to scroll down the LCD screen to be able to see all the remaining data. The libraries I'm currently using are:

#include <Adafruit_GFX.h>
#include <LMP91000.h>
#include <Wire.h>
#include <Adafruit_ILI9341.h>
#include <Adafruit_FT6206.h>

In case there isn't any function or library, is there any suggestion on how to do it? I try using arrays, but the number of samples is too high to be stored in an array.

Even if there was a function to scroll the display, all that data would have to be stored somewhere and you admit it is too much to store.

So store it on an SD card as fixed length records and use random read to get the data to scroll.

Paul

When you describe the scrolling list, what capability were you looking for?

a) Only seeing the latest results (eg. the last 10 lines). New entries are written at the bottom and the rest are scrolled upwards automatically. You won't be able to see results once they disappear off the top of the screen. This is the least demanding on your memory needs and also the simplest to implement.

b) Seeing a portion of the latest results (eg. the last 40 lines). New entries are written at the bottom and the rest are scrolled upwards automatically. You want some means of manually scrolling back in a "buffer" to see recent results. This would be a compromise on memory but enable you to review more than a "screen" of data.

c) Seeing all of the results. New entries are written at the bottom and the rest are scrolled upwards automatically. You need a means of manually scrolling back through the entire buffer to see all results. From your posting, it sounds like this option wouldn't be viable due to insufficient memory to retain all data points.

As Paul states, using external storage for your data points might address your memory concerns but could also potentially introduce considerations on performance.

What MCU are you using?

Do you want to be able to scroll back up or just in one direction? Meaning as new data comes in, pan the data in he display so you can see previous as new data is drawn? If up/down scrolling I seriously doubt 32K will be enough. Adding SD support will consume tons of memory.

Do you want to scroll by dragging a finger in the screen and have display update? Even if you had sufficient memory, not sure the Ardino can draw fast enough to make scrolling

I use TFT's in almost all projects, but I use Teensy 3.2 where it has 256K memory--not sure that will be enough.

Kris -- the Teensy is certainly an excellent device (I have a few of them now after recently coming across them). However, it is worth mentioning that it is definitely possible to implement a scrolling TFT buffer on an Arduino.

For reference, I have attached a quick example of a scrollback buffer I created with touchscreen slider controls. It runs on an Arduino UNO (2KB RAM, 32KB Flash), though naturally tight on resources.

As Kris points out, a more capable MCU would allow for more buffer capacity and performance.

GUIslice-textbox-ex10.png

Back to the OP question: if option (b) is acceptable, then I recommend taking a look at a “circular buffer” implementation. It is an array that you can continuously write to, but the array length is constrained to a finite range (eg. 100 entries), less than the total number of data points. Once the buffer is “full”, new entries continue to be written, but they start overwriting the oldest entries. You can then read from the last 100 entries of this buffer. The key is that your write and read pointers into this array will “wrap”.

GUIslice-textbox-ex10.png

Thanks for your help,

For now, I only need the scroll to move one direction "Down", so new entries are written at the bottom and the rest is scrolled upwards automatically. Meaning option a), later I plan to store the data on an SD, but for now just to see new entries will be fine. Any Ideas how can I do this?

If all you need to handle is case (a), then one solution may be to use a circular (or ring) buffer library that holds your last N data points, where N is the number of entries that you can show on your display. Generally, your sensor capture would push new data points to one end of the circular buffer and set a flag that the data buffer has changed. In your main loop, you could periodically check this new-data flag and update the list on your TFT. Since you aren't going to "scroll back" through your list (ie. option b), the circular buffer is somewhat overkill: you could also just write into your normal array until full, at which point you manually shift all the elements along by one position to make room for each of the latest entries.

The simplest redraw approach here might be to blank the screen and render all N lines from your circular buffer (this may result in some flicker). As you have an ILI9341 display, you might also be able to take advantage of a higher performance option using the "hardware scrolling" feature of the TFT. For an example, please see TFT_Terminal.ino

You can find an example of a circular buffer implementation here: RingBufExample.ino (from the ArduinoRingBuffer library)

Good luck!