tft screen sine wave connecting pixels

I have a program that will plot a pixel for each column in the x axis however how do i connect these points or a vertically? I cannot seem to find an algorithm that works to complete the wave.

#include <Elegoo_GFX.h>    // Core graphics library
#include <Elegoo_TFTLCD.h> // Hardware-specific library
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
#define BLACK   0x0000
#define YELLOW  0xFFE0

const int b1 = 36;
const int b2 = 50;
const int b3 = 38;
const int f1 = 34;
const int f2 = 30;

Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

uint8_t  sine_wave[256] = {
0x80, 0x83, 0x86, 0x89, 0x8C, 0x90, 0x93, 0x96,
0x99, 0x9C, 0x9F, 0xA2, 0xA5, 0xA8, 0xAB, 0xAE,
0xB1, 0xB3, 0xB6, 0xB9, 0xBC, 0xBF, 0xC1, 0xC4,
0xC7, 0xC9, 0xCC, 0xCE, 0xD1, 0xD3, 0xD5, 0xD8,
0xDA, 0xDC, 0xDE, 0xE0, 0xE2, 0xE4, 0xE6, 0xE8,
0xEA, 0xEB, 0xED, 0xEF, 0xF0, 0xF1, 0xF3, 0xF4,
0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFA, 0xFB, 0xFC,
0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFD,
0xFD, 0xFC, 0xFB, 0xFA, 0xFA, 0xF9, 0xF8, 0xF6,
0xF5, 0xF4, 0xF3, 0xF1, 0xF0, 0xEF, 0xED, 0xEB,
0xEA, 0xE8, 0xE6, 0xE4, 0xE2, 0xE0, 0xDE, 0xDC,
0xDA, 0xD8, 0xD5, 0xD3, 0xD1, 0xCE, 0xCC, 0xC9,
0xC7, 0xC4, 0xC1, 0xBF, 0xBC, 0xB9, 0xB6, 0xB3,
0xB1, 0xAE, 0xAB, 0xA8, 0xA5, 0xA2, 0x9F, 0x9C,
0x99, 0x96, 0x93, 0x90, 0x8C, 0x89, 0x86, 0x83,
0x80, 0x7D, 0x7A, 0x77, 0x74, 0x70, 0x6D, 0x6A,
0x67, 0x64, 0x61, 0x5E, 0x5B, 0x58, 0x55, 0x52,
0x4F, 0x4D, 0x4A, 0x47, 0x44, 0x41, 0x3F, 0x3C,
0x39, 0x37, 0x34, 0x32, 0x2F, 0x2D, 0x2B, 0x28,
0x26, 0x24, 0x22, 0x20, 0x1E, 0x1C, 0x1A, 0x18,
0x16, 0x15, 0x13, 0x11, 0x10, 0x0F, 0x0D, 0x0C,
0x0B, 0x0A, 0x08, 0x07, 0x06, 0x06, 0x05, 0x04,
0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03,
0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0A,
0x0B, 0x0C, 0x0D, 0x0F, 0x10, 0x11, 0x13, 0x15,
0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24,
0x26, 0x28, 0x2B, 0x2D, 0x2F, 0x32, 0x34, 0x37,
0x39, 0x3C, 0x3F, 0x41, 0x44, 0x47, 0x4A, 0x4D,
0x4F, 0x52, 0x55, 0x58, 0x5B, 0x5E, 0x61, 0x64,
0x67, 0x6A, 0x6D, 0x70, 0x74, 0x77, 0x7A, 0x7D
};
uint8_t pixel_buffer[256][2];

void setup() {
  tft.reset();
  tft.begin(37697);
  tft.setRotation(1);
  for(int j= 0; j<256; j++){
    pixel_buffer[j][2]=sine_wave[j];
  }

}


void loop() {
    int i=1;
    while(i<256){
      tft.drawFastVLine(i, 240-pixel_buffer[i][1]*0.9, 1, BLACK);
      tft.drawFastVLine(i, 240-pixel_buffer[i][2]*0.9, 1, YELLOW);
      pixel_buffer[i][1] = pixel_buffer[i][2];
      i++;
    }
    i = 0;
}

Draw lines between pixels.

how would the algorithm go for achieving that? keep in mind lines are always drawn from top to bottem. therefor not half of your that need to be connected upwards will need their own case than from the generic downwards. and generally maping the pixel locations is somthing i am finding very confusing.

I don't know the particular details of your graphics package. I've never seen one that could only draw "up". Go confirm that in your documentation. Generally if you are plotting you go from one 'x' position to the next. So instead of just plotting a point x,y you plot a line from (last x, last y) to (this x, this y). Begin with the first x (it could be left or rightmost), and iterate over all the x values plotting the lines. You have to save the last position in order to have two points to draw the line.

Using the TFT routine?
Or you need to draw your own lines in the pixel_buffer array?

If you are drawing your own lines you can use Breshnam’s Line Algorithm.

pcbbc:
Using the TFT routine?
Or you need to draw your own lines in the pixel_buffer array?

If you are drawing your own lines you can use Breshnam’s Line Algorithm.

I have a feeling that simpler options like the GFX library are better in this case.

You should take a look at the documentation for the Elegoo_GFX library, which was just copied from Adafruit.

Cleverly, the Elegoo people replaced all instances of "Adafruit" by "Elegoo" using a text editor, so no one would guess.

To draw a line, use this call:

// Bresenham's algorithm - thx wikpedia
void Elegoo_GFX::drawLine(int16_t x0, int16_t y0,
    int16_t x1, int16_t y1,
    uint16_t color)