Ciao ho bisogno del vostro aiuto, ho fatto un circuito che mi rileva dei dati e me li fa vedere su un display ST7789 e anche sulla seriale, il mio problema è che sulla seriale vedo i dati ma sul display no, mi aiutate grazie
/*
#include <SPI.h>
#include <Adafruit_GFX.h>
#if (__STM32F1__) // bluepill
#define TFT_DC PA1
#define TFT_RST PA0
//#include <Arduino_ST7789_STM.h>
#else
#define TFT_CS 10 // define chip select pin ST7789 TFT module
#define TFT_DC 9 // define data/command pin ST7789 TFT module
#define TFT_RST 8 // define reset pin, or set to -1 and connect to Arduino RESET pin
#include <Arduino_ST7789_Fast.h>
#endif
#define SCR_WD 240
#define SCR_HT 240
Arduino_ST7789 lcd = Arduino_ST7789(TFT_DC, TFT_RST);
#include "PropFont.h"
#include "bold13x20digtop_font.h"
#include "term9x14_font.h"
PropFont font;
void customPixel(int x, int y, int c) { lcd.drawPixel(x, y, c); }
void customRect(int x, int y, int w, int h, int c) { lcd.fillRect(x, y, w, h, c); }
#include <Wire.h>
#include<ADS1115_WE.h>
#include<Wire.h>
#define I2C_ADDRESS 0x48
ADS1115_WE adc(I2C_ADDRESS);
unsigned long ms = 0;
#define buton2 4
boolean isAcquisire = false, isStopped = false;
unsigned long oldmillis = 0;
bool avviato, s, spenta;
unsigned long intervallo = 0;
boolean picco = false;
unsigned long prevmillis2 = 0;
unsigned int sample; // , Vmin = 614;// Vmin del pacco 3S
float voltage = 0.0;
float Power = 0.0;
float Current = 0.0;
float ampsH = 0.0; // ampere ora
float t;
void setup() {
Wire.begin();
Serial.begin(9600); //start serial connection
Serial.println("CLEARDATA");
Serial.println("LABEL,Time,Timer,t (ore),ADC,Volt,Ampere,Watt,Capacità Ah");
delay(5000);
Wire.begin();
Wire.setClock(400000); // faster
lcd.init(SCR_WD, SCR_HT);
font.init(customPixel, customRect, SCR_WD, SCR_HT); // funzione drawPixel e fillRect personalizzati e valori di larghezza e altezza dello schermo
font.setFont(Term9x14);
font.setScale(1);
pinMode(buton2, INPUT_PULLUP); // pin di ricezione segnale torcia spenta era (INPUT)
// pinMode (PinBatt, INPUT);
/* Set the voltage range of the ADC to adjust the gain
* Please note that you must not apply more than VDD + 0.3V to the input pins!
*
* ADS1115_RANGE_6144 -> +/- 6144 mV
* ADS1115_RANGE_4096 -> +/- 4096 mV
* ADS1115_RANGE_2048 -> +/- 2048 mV (default)
* ADS1115_RANGE_1024 -> +/- 1024 mV
* ADS1115_RANGE_0512 -> +/- 512 mV
* ADS1115_RANGE_0256 -> +/- 256 mV
*/
//adc.setVoltageRange_mV(ADS1115_RANGE_1024); //uncomment line / change parameter to change range
/* Set the inputs to be compared
*
* ADS1115_COMP_0_1 -> compares 0 with 1 (default)
* ADS1115_COMP_0_3 -> compares 0 with 3
* ADS1115_COMP_1_3 -> compares 1 with 3
* ADS1115_COMP_2_3 -> compares 2 with 3
* ADS1115_COMP_0_GND -> compares 0 with GND
* ADS1115_COMP_1_GND -> compares 1 with GND
* ADS1115_COMP_2_GND -> compares 2 with GND
* ADS1115_COMP_3_GND -> compares 3 with GND
*/
//adc.setCompareChannels(ADS1115_COMP_0_1); // uncomment line / change parameter to change channels
}
const uint16_t lnCol = RGBto565(255,150,255);
const uint16_t ln2Col = RGBto565(180,180,180);
const uint16_t labCol = RGBto565(250,250,250);
const uint16_t v1Col = RGBto565(100,250,100);
const uint16_t v2Col = RGBto565(255,250,100);
const uint16_t v3Col = RGBto565(120,255,255);
const uint16_t v4Col = RGBto565(255,120,120);
const uint16_t v5Col = RGBto565(150,150,255);
const uint16_t v1aCol = RGBto565(150,150,255);
const uint16_t v2aCol = RGBto565(250,150,250);
int xe=0,mode=1,lastMode=-1;
void drawField(int x, int y, int w, int h, char *label, uint16_t col=lnCol)
{
lcd.drawRect(x,y+7,w,h-7,col);
font.setFont(Term9x14);
font.setScale(1);
font.setColor(labCol,BLACK);
int wl = font.strWidth(label);
font.printStr(x+(w-wl)/2,y,label);
}
void showVal(float v, int x, int y, int w, byte numdec, char *unit, uint16_t col) //dichiarazione della funzione che mostra i valori
{
font.setFont(Bold13x20);
font.setSpacing(3);
font.setScale(1,2);
font.setDigitMinWd(font.charWidth('0'));
font.setColor(col,BLACK);
char txt[10];
dtostrf(v,w,numdec,txt);
xe = font.printStr(x,y,txt);
font.printStr(xe+2,y,unit);
}
void constData()
{
drawField( 0, 0,120-5,120-2," Ah ");
drawField(120+5, 0,120-5,120-2," Ampere ");
drawField( 0,120+2,120-5,120-2," Power ");
drawField(120+5,120+2,120-5,120-2," ADC ");
font.setColor(v3Col,BLACK);
font.printStr(48,240-27,"hPa");
}
/*
void varData()
{
/*showVal(sensor219.getBusVoltage_V(), 18,43, 4,"V",v1Col);
showVal((sensor219.getCurrent_mA())/1000., 30+120,43, 4, 3, "A",v2Col);
showVal(watt, 14,122+43, 6,"W",v3Col);
showVal(Vbatt, 21+120,122+43, 5,"V",v4Col);
float v1=sensor219.getBusVoltage_V();
if(v1<=0) v1=0;
float v2=(sensor219.getCurrent_mA())/1000;
if(v2<=0) v2=0;
float v3=watt;
if(v3<=0) v3=0;
float v4=Vbatt;
if(v4<=0) v4=0;
float v5=vin;
if(v5<=0) v5=0;
showVal(v1, 10, 0+24, 4, "Ah", v1Col);
showVal(v2, 10+120, 0+24, 4, "A", v2Col);
showVal(v3, 10, 82+24, 4, "W", v3Col);
showVal(v4, 10+120, 82+24, 4, "V", v4Col);
showVal(v5, 10, 160+24, 4, "V", v5Col);
font.setFont(Term9x14);
//font.printStr(xe+2,120+44+12,"m");
}*/
void constBoth()
{
drawField( 0, 0, 120-5, 80-2, " Ah ");
drawField(120+5, 0, 120-5, 80-2, " Ampere ");
drawField( 0, 80+2, 120-5, 80-2, " Power ");
drawField(120+5, 80+2, 120-5, 80-2, " ADC ");
drawField( 0, 160, 240, 80-2, " Battery Voltage ", ln2Col);
font.setFont(Term9x14);
int wv=font.strWidth("88.8");
//font.setColor(v1Col); font.printStr(18+wv,0+24,"'$");
wv=font.strWidth("999999.999");
//font.setColor(v5Col); font.printStr(22+wv,162+25+14,"VOLT");
wv=font.strWidth("888.8");
int wv2=font.strWidth("888.88");
// setInfoFont();
font.setScale(1,2);
font.setColor(v1Col); font.printStr(28+8+wv+14,24+12,"Ah");
font.setColor(v2Col); font.printStr(32+127+wv+14,24+12,"A");
font.setColor(v3Col); font.printStr(28+10+wv+10,105+12,"W");
font.setColor(v5Col); font.printStr(21+wv+100,158+20+14,"volt");
}
float v1, v2, v3, v4, v5;
void varBoth()
{
v1=ampsH;
if(v1<=0) v1=0;
v2=Current;
if(v2<=0) v2=0;
v3=Power;
if(v3<=0) v3=0;
v4=sample;
if(v4<=0) v4=0;
v5=voltage;
if(v5<=0.55) v5=0;
showVal(v1, 5, 0+24, 3,3, "Ah", v1Col);
showVal(v2, 10+135, 0+24, 3,2, "A", v2Col);
showVal(v3, 5, 82+24, 3,2, "W", v3Col);
showVal(v4, 15+150, 82+24, 3,0, "ADC", v4Col);
showVal(v5, 50, 160+24, 6,2, "V", v5Col);
font.setFont(Term9x14);
//font.printStr(xe+2,82+22+14,"m");
}