Graph sinusoidal on 1.8" tft display using lookup table

hello ,
In the following code, using the lookup table, I have been able to graph or hide a sinusoidal wave on the serial plotter, I would like to be able to see it graphed on a tft display, any suggestions on how to do it, thanks.

#include <SoftwareSerial.h>
#include <TFT.h>  // Arduino LCD library
#include <SPI.h>

#define cs   10
#define dc   8
#define rst -1
TFT screen = TFT(cs, dc, rst);
int            i;


//Lookup Tables o Tablas de Consulta
//Número de Puntos 512
//Amplitud Máxima  255
//Números por Fila 8
//Formato          Decimal

byte            Seno[512] =
{
  128, 129, 131, 132, 134, 135, 137, 138,
  140, 142, 143, 145, 146, 148, 149, 151,
  152, 154, 155, 157, 158, 160, 162, 163,
  165, 166, 167, 169, 170, 172, 173, 175,
  176, 178, 179, 181, 182, 183, 185, 186,
  188, 189, 190, 192, 193, 194, 196, 197,
  198, 200, 201, 202, 203, 205, 206, 207,
  208, 210, 211, 212, 213, 214, 215, 217,
  218, 219, 220, 221, 222, 223, 224, 225,
  226, 227, 228, 229, 230, 231, 232, 233,
  234, 234, 235, 236, 237, 238, 238, 239,
  240, 241, 241, 242, 243, 243, 244, 245,
  245, 246, 246, 247, 248, 248, 249, 249,
  250, 250, 250, 251, 251, 252, 252, 252,
  253, 253, 253, 253, 254, 254, 254, 254,
  254, 255, 255, 255, 255, 255, 255, 255,
  255, 255, 255, 255, 255, 255, 255, 255,
  254, 254, 254, 254, 254, 253, 253, 253,
  253, 252, 252, 252, 251, 251, 250, 250,
  250, 249, 249, 248, 248, 247, 246, 246,
  245, 245, 244, 243, 243, 242, 241, 241,
  240, 239, 238, 238, 237, 236, 235, 234,
  234, 233, 232, 231, 230, 229, 228, 227,
  226, 225, 224, 223, 222, 221, 220, 219,
  218, 217, 215, 214, 213, 212, 211, 210,
  208, 207, 206, 205, 203, 202, 201, 200,
  198, 197, 196, 194, 193, 192, 190, 189,
  188, 186, 185, 183, 182, 181, 179, 178,
  176, 175, 173, 172, 170, 169, 167, 166,
  165, 163, 162, 160, 158, 157, 155, 154,
  152, 151, 149, 148, 146, 145, 143, 142,
  140, 138, 137, 135, 134, 132, 131, 129,
  128, 126, 124, 123, 121, 120, 118, 117,
  115, 113, 112, 110, 109, 107, 106, 104,
  103, 101, 100, 98, 97, 95, 93, 92,
  90, 89, 88, 86, 85, 83, 82, 80,
  79, 77, 76, 74, 73, 72, 70, 69,
  67, 66, 65, 63, 62, 61, 59, 58,
  57, 55, 54, 53, 52, 50, 49, 48,
  47, 45, 44, 43, 42, 41, 40, 38,
  37, 36, 35, 34, 33, 32, 31, 30,
  29, 28, 27, 26, 25, 24, 23, 22,
  21, 21, 20, 19, 18, 17, 17, 16,
  15, 14, 14, 13, 12, 12, 11, 10,
  10, 9, 9, 8, 7, 7, 6, 6,
  5, 5, 5, 4, 4, 3, 3, 3,
  2, 2, 2, 2, 1, 1, 1, 1,
  1, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0,
  1, 1, 1, 1, 1, 2, 2, 2,
  2, 3, 3, 3, 4, 4, 5, 5,
  5, 6, 6, 7, 7, 8, 9, 9,
  10, 10, 11, 12, 12, 13, 14, 14,
  15, 16, 17, 17, 18, 19, 20, 21,
  21, 22, 23, 24, 25, 26, 27, 28,
  29, 30, 31, 32, 33, 34, 35, 36,
  37, 38, 40, 41, 42, 43, 44, 45,
  47, 48, 49, 50, 52, 53, 54, 55,
  57, 58, 59, 61, 62, 63, 65, 66,
  67, 69, 70, 72, 73, 74, 76, 77,
  79, 80, 82, 83, 85, 86, 88, 89,
  90, 92, 93, 95, 97, 98, 100, 101,
  103, 104, 106, 107, 109, 110, 112, 113,
  115, 117, 118, 120, 121, 123, 124, 126,
};

void setup()
{
  Serial.begin(115200);
  screen.begin();
  screen.background(0, 0, 0);
  screen.setRotation(3);
}

void loop()
{
  for (i = 0; i < 512; i++)
  {
    Serial.println(Seno[i]);
    delay(5);
    //screen.stroke(0, 155, 255);
    // screen.point(Seno[i]);
  }
}

Have you run any TFT library example sketches to test the hardware, and consulted the TFT library documentation for an understanding of graphics commands?

Also, there are more than one TFT library, so please link to the one you used. More information about your Arduino and display would also be helpful.

Please read:

First, make sure your TFT display is working properly, by running one or more of the TFT library examples. Then study the example code and graphics library documentation to learn how to plot data on the screen.

Your program will need to scale the sine wave values to fit the display screen.

hi there,
I made sure that with the examples of the library the screen works
This library is compatible with most of the TFT display based on the ST7735 chipset

Hardware:
Arduino Duemilanove
TFT 1.8" SPI 128x160 V1.1
library

I'm sure I could find the graphics functions in that library in about a minute, but then you can too. So please have a look.

You never said anything about these lines, I asked you to explain what is wrong, that would include anything like this that you tried. So what happened?

    //screen.stroke(0, 155, 255);
    // screen.point(Seno[i]);

If you don't tell us what your specific problem is, how could we possibly help?

One glaringly obvious problem, you are trying to specify a 2 dimensional coordinate, with only one value. That violates not only the principles of programming, but of linear mathematics too.

Well, Serial Plotter achieves just that in a way that I guess @gtechve is reasonably happy with...

The truth is that Serial Plotter is quite a clever piece of code that it's developer probably doesn't get enough credit for. Serial Plotter does what it does in a way that makes it look easy. But it isn't as easy as it looks, and would be a serious challenge for a beginner.

I doubt that. To plot the X coordinate, all you need is a simple counter variable.

The problem is that to graph the wave in 2 dimensions I would need x,y and I only have one axis, try graphing, another problem would be the size of the wave to be able to visualize it on the screen taking into account the height and width of the screen..

//screen.stroke(0, 155, 255);
// screen.point(Seno[i]);

TFT Reference funtions

A screen has two axes.

another problem would be the size of the wave to be able to visualize it on the screen taking into account the height and width of the screen

Simple arithmetic.

Doubt what exactly?

For you or I this would not be child's play, but certainly achievable in a few hours or at worst days, but for a beginner... they would need a lot of our help.

Only if they skipped a lot of lessons.

Also it would be easy to make a non-perfect display which for example might not have perfect scaling, that could pave the way to improvement.

:grinning:
You are right it looks so simple, but it seems that it is not because the serial plotter makes it look like that..
try and make mistakes in order to learn..

Just think about what the serial plotter does... increments X for each sample... duplicate that in your code.

try and make mistakes in order to learn..

That is a bad way to learn. Sure, we learn from our mistakes. But in programming the non-solutions outnumber the solutions by a factor of billions to one. So flinging dirt at the wall to see what sticks isn't very educational.

The X coordinate is part of the mathematical definition of a sine wave (except that it is usually 't', represents time).

One possibility is to use the Arduino map() function, which uses very simple arithmetic.

Scaling isn't a problem for a program that can't plot points. If the OP is really a beginner, they can't solve two problem at the same time. Even though, it looks like they are trying.

If the purpose of the sketch is to learn or demonstrate mathematics, it seems counterproductive to avoid it.

However.

The values in the table, are already in a range where some part of the wave would appear correctly on the screen if the X coordinate was handled correctly.

Seeing that on the screen would certainly be helpful in figuring out how to scale it to fit...

So use the Adafruit library if it works for you...

Honestly, your response seems more like a change of subject, than a response to the suggestions that have been offered...

Is the problem that you are not writing the code, someone else is (for example, a boilerplate sketch that is handed out as an assignment to modify)?

Is this a school assignment? At what grade level?

Are "they" that you mention, your professors, teaching assistants or fellow students?

It was easier to use the integrated library that comes with the ide to do the example, without leaving the main idea is to use the lookup table method as you can see that the serial plotter plots what is inside the table..

There is no TFT library in the IDE distribution, that I am aware of.

It's becoming hard to understand what you are here for. You should make an attempt at using the Adafruit code (since you know it works), but modifying it to use the LUT.

Are you stuck because you don't understand the working example code?

To keep the thread going I will delete post#16, the idea is to continue with the topic to use the lookup table method to graph the wave on the tft display from the beginning.

I'll be honest with you. That will not keep it going, it will probably make it die.

Problem is, the conversation is apparently one-way. You don't really respond to suggestions.