Hey guys
My project is to have a TDS(total dissolved matter) value on a TFT display.
I manage to spaguetti code my way till its time to display the values on screen,
on serial monitor it displays the correct(after verification)values on liquids, but i cant seem to point it to screen, doesnt matter where in screen, just that values being displayed correctly.
#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
#include "TouchScreen.h"
#include <EEPROM.h>
#include "GravityTDS.h"
#define BLACK 0x0000
#define PURPLE 0x780F
#define BLUE 0x001F
#define GREEN 0x07E0
#define CYAN 0x07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define TdsSensorPin A0
GravityTDS gravityTds;
#define YP A1
#define XM A2
#define YM 7
#define XP 6
#define MINPRESSURE 10
#define MAXPRESSURE 1000
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 250);
TSPoint p;
MCUFRIEND_kbv tft;
float temperature = 25,tdsValue = 0;
uint16_t g_identifier;
uint8_t rotation=3;
uint32_t when = millis();
uint8_t size = 4;
uint8_t cor = 0;
uint32_t tdsSensorPin =0;
void setup()
{
tft.begin(9600);
tft.reset();
Serial.begin(9600);
g_identifier = tft.readID(); // get id
tft.begin(0x7793); // to enable ST7793 driver code
tft.setRotation(rotation); // sets text direction
tft.fillScreen(BLACK); // clear screen
gravityTds.setPin(TdsSensorPin);
gravityTds.setAref(3.3); //reference voltage on ADC, default 5.0V on Arduino UNO
gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC
gravityTds.begin(); //initialization
}
void loop()
{
//temperature = readTemperature(); //add your temperature sensor and read it
gravityTds.setTemperature(temperature); // set the temperature and execute temperature compensation
gravityTds.update(); //sample and calculate
tdsValue = gravityTds.getTdsValue(); // then get the value
tft.setTextColor(WHITE,BLACK);
tft.print(tdsValue);
Serial.print(tdsValue-35,0);
Serial.println("ppm");
delay(1000);
}
thanks for the help.