using the LCD. Drawing a line from left to right, and then wrapping around.

As part of a bigger thing I need to do I am drawing a line from left to right.

void loop() {
//int nextx = startx+1;
int nexty = starty+1;
tft.drawLine(startx,starty, startx,nexty,ILI9341_RED);

//startx = nextx;
starty = nexty;

So after about 4 seconds, the line is finished drawing. But I want it to work in such a way that after it is drawn, it is drawn again from left to right, without erasing part of the original.

The bigger thing I need to do is to display a heart signal that goes from left to right and then wraps around. I am just starting with this little example.

I think you simply reset x after you get to the last x coordinate, but you will have to store the entire data set so that you can blank the previous "y" at that coordinate. I thought these things have a fixed "x" and a scrolling scale, whereby all relevant information is always on the screen and always in the same place.