Line instead of dots

Hi Here is the code for Ux Uy display on tft screen, but it is showing the dots, I need in continuous line.
How to fix it ?

#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>

#define TFT_MOSI 23  // Data out
#define TFT_SCLK 18  // Clock out

#define TFT_CS   22// // Chip select pin
#define TFT_DC    21 // Data/Command pin
#define TFT_RST   -1  // pin# 2

// Create an instance of the display driver
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

int DCX1, DCX2, DCY1, DCY2;
byte lastButtonState = LOW;
int botonState = 0;
void setup() {
  Serial.begin(115200);

  pinMode(2, INPUT_PULLUP);    //Sw,  Bst      = botonState

  tft.init(170, 320);
  tft.setRotation(3); // Adjust rotation as needed (0-3),0 = viertical, 1= horyzontal upside down, 2= viertical 180 deg , 3=horyzontal normal,

  // Clear the screen
  //tft.fillScreen(ST77XX_BLACK);//++++++++++++++++++++++++++++++++
  tft.fillScreen(ST77XX_BLUE);
  tft.setTextWrap(false); // Disable text wrapping
  tft.setTextSize(4);     // Set text size
  // tft.setTextColor(ST77XX_WHITE); // Set text color  +++++++++++++++++++
  tft.setTextColor(ST77XX_YELLOW); // Set text color

}

void loop() {

  if (digitalRead(2) == LOW)
  {
    tft.fillScreen(ST77XX_BLUE);
  }
  DCX1 = analogRead(13);
  // DCX1 = analogRead(39);
  DCX1 = map(DCX1, 0, 4096, 0, 3300);
  // DCX1 = DCXp(DCX1, 0, 4096, 0, 500);
  DCX2 = 3299 - DCX1;

  DCY1 = analogRead(15);
  // DCY1 = analogRead(39);
  DCY1 = map(DCY1, 0, 4096, 0, 3300);
  // DCY1 = DCYp(DCY1, 0, 4096, 0, 500);
  DCY2 = 3299 - DCY1;
  if (digitalRead(14) == LOW)
  {
    tft.fillScreen(ST77XX_BLUE);
  }

  tft.setCursor(10, 0);
  tft.setTextColor(ST77XX_YELLOW);
  tft.print("C 6");
  tft.fillRect(150 + (DCX1 / 23), 150 - (DCY1 / 23), 3 , 3, ST77XX_WHITE);

  Serial.print("case 6 =  ");
  Serial.print( "DCY1 =  "); Serial.print( DCX1);
  Serial.print("  DCY1 =  "); Serial.print( DCY1);
  Serial.println( );
}

You need to remember the previous location X and Y coordinates, then once you have them, you can then draw a line. You should have a drawLine() function. X1,Y1 will be the previous coordinates and X2,Y2 will be the new coordinates. You may also want to start somewhere like (0,0) or where ever you want it to start from.

It is drawing a straight lines like on the left, I need a curved lines joining the dots as on the right.

  // tft.fillRect(150 + (DCX1 / 23), 150 - (DCY1 / 23), 3 , 3, ST77XX_WHITE);
  tft.drawLine(150 + (DCX1 / 23), 150 - (DCY1 / 23), 3 , 3, ST77XX_WHITE);

Did you remember to save the last coordinates?

I don't know how to do it.

Refer to the Drawing lines section in the following tutorial:

something like this ?

  DCX1 = analogRead(13);
  // DCX1 = analogRead(39);
  DCX1 = map(DCX1, 0, 4096, 0, 3300);
  // DCX1 = DCXp(DCX1, 0, 4096, 0, 500);
  DCX2 = 3299 - DCX1;

  DCY1 = analogRead(15);
  // DCY1 = analogRead(39);
  DCY1 = map(DCY1, 0, 4096, 0, 3300);
  // DCY1 = DCYp(DCY1, 0, 4096, 0, 500);
  DCY2 = 3299 - DCY1;
  ///////////////////////////
  previousDCX1 = currentDCX1;
  previousDCY1 = currentDCY1;
  currentX2 = DCX1;
  currentY2 = DCY1;
  /////////////////////////

I’m on my phone now so it’s difficult to write it out. If no one else gets to it before me, I’ll write it out tomorrow morning.

Here, try this. I didn’t change anything else in your code, I just added what you needed for the line.

#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>

#define TFT_MOSI 23  // Data out
#define TFT_SCLK 18  // Clock out

#define TFT_CS 22   // // Chip select pin
#define TFT_DC 21   // Data/Command pin
#define TFT_RST -1  // pin# 2

// Create an instance of the display driver
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

int DCX1, DCX2, DCY1, DCY2;
int px = -1, py = -1; // saved coordinates
byte lastButtonState = LOW;
int botonState = 0;

void setup() {
  Serial.begin(115200);

  pinMode(2, INPUT_PULLUP);  //Sw,  Bst      = botonState

  tft.init(170, 320);
  tft.setRotation(3);  // Adjust rotation as needed (0-3),0 = viertical, 1= horyzontal upside down, 2= viertical 180 deg , 3=horyzontal normal,

  // Clear the screen
  //tft.fillScreen(ST77XX_BLACK);//++++++++++++++++++++++++++++++++
  tft.fillScreen(ST77XX_BLUE);
  tft.setTextWrap(false);  // Disable text wrapping
  tft.setTextSize(4);      // Set text size
  // tft.setTextColor(ST77XX_WHITE); // Set text color  +++++++++++++++++++
  tft.setTextColor(ST77XX_YELLOW);  // Set text color
}

void loop() {
  static int cx = 0, cy = 0;

  if (digitalRead(2) == LOW) {
    tft.fillScreen(ST77XX_BLUE);
  }
  DCX1 = analogRead(13);
  // DCX1 = analogRead(39);
  DCX1 = map(DCX1, 0, 4096, 0, 3300);
  // DCX1 = DCXp(DCX1, 0, 4096, 0, 500);
  DCX2 = 3299 - DCX1;

  DCY1 = analogRead(15);
  // DCY1 = analogRead(39);
  DCY1 = map(DCY1, 0, 4096, 0, 3300);
  // DCY1 = DCYp(DCY1, 0, 4096, 0, 500);
  DCY2 = 3299 - DCY1;
  if (digitalRead(14) == LOW) {
    tft.fillScreen(ST77XX_BLUE);
  }

  tft.setCursor(10, 0);
  tft.setTextColor(ST77XX_YELLOW);
  tft.print("C 6");

  // set current coordinates to cx, cy
  cx = 150 + (DCX1 / 23);
  cy = 150 - (DCY1 / 23);

  // Add line if you have the previous points
  if (px != -1 && py != -1) {
    tft.drawLine(px, py, cx, cy, ST77XX_WHITE);
  }

  // Add Dot at the end of the new line, if needed
  // tft.fillRect(cx, cy, 3 , 3, ST77XX_WHITE);

  // if the previous point does not equal the new point, update it
  if (px != cx) { px = cx; }
  if (py != cy) { py = cy; }

  Serial.print("case 6 =  ");
  Serial.print("DCY1 =  ");
  Serial.print(DCX1);
  Serial.print("  DCY1 =  ");
  Serial.print(DCY1);
  Serial.println();
}

Thanks, it is working. Will be nice to increase the resolution, more dots to be joined I think each dot is representing one void loop() cycle.

Looks like you didn't save coordinates properly.