Hi I had a problem with my code that have the temperature of two different nanoshields the internal and external , but now I have a new problem, I wanna clear just the old data of both nanoshields because they are overlaping the old ones. I can't take a picture now, but I used tft.fillscreen and the temperature is renovated correctly, but with the background blue. .
This is the code:
#include <TouchScreen.h>
#include <Adafruit_GFX.h>
#include "Nanoshield_Termopar.h"
#include <SPI.h>
#include "Nanoshield_LCD.h"
Nanoshield_Termopar termopar(52 , TC_TYPE_K, TC_AVG_OFF );
Nanoshield_Termopar termopar2(50 , TC_TYPE_K, TC_AVG_OFF );
Nanoshield_LCD lcd;
#define YP A3
#define XM A2
#define YM 9
#define XP 8
#define TS_MINX 90
#define TS_MINY 92
#define TS_MAXX 906
#define TS_MAXY 951
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
#define LCD_RESET A4
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define PRETO 0x0000
#define BRANCO 0xFFFF
#define AMARELO 0x0ff00
MCUFRIEND_kbv tft;
#define MINPRESSURE 10
#define MAXPRESSURE 1000
bool error = false;
bool valor_botao1 = false;
bool valor_botao2 = false;
void telaInicial();
void setup() {
Serial.begin(9600);
termopar.begin();
termopar2.begin();
uint16_t ID = tft.readID();
tft.begin(ID);
tft.setRotation(1);
tft.fillScreen(BRANCO);
lcd.begin();
telaInicial();
}
void loop() {
delay (1500);
termopar.read();
tft.setTextColor(BRANCO);
tft.setCursor (200, 60);
tft.print(termopar.getInternal());
Serial.println (termopar.getExternal());
Serial.println ("");
tft.setCursor (200, 180);
tft.print (termopar.getExternal());
Serial.println (termopar.getExternal());
Serial.println ("");
termopar2.read();
tft.setTextColor(BRANCO);
tft.setCursor (200, 30);
tft.print(termopar2.getInternal());
tft.fillScreen(termopar2.getInternal());
Serial.println (termopar2.getInternal());
Serial.println ("");
tft.setCursor (200, 150);
tft.print (termopar2.getExternal());
Serial.println (termopar2.getExternal());
delay (1000);
Serial.println ("");
Serial.println ("");
Serial.println ("");
Serial.println ("");
Serial.println ("");
Serial.println ("");
Serial.println ("");
Serial.println ("");
Serial.println ("");
Serial.println ("");
Serial.println ("");
Serial.println ("");
Serial.println ("");
}
void telaInicial() {
tft.setRotation(3);
tft.fillScreen(BRANCO);
criarBotao(186, 130, 105, 95, "", PRETO);
criarBotao(186, 10, 105, 95, "", PRETO);
criarBotao(20, 10, 105, 95, "", PRETO);
criarBotao(20, 130, 105, 95, "", PRETO);
escreveEstado(32, 50, "Temp_1", BRANCO);
escreveEstado(32, 170, "Temp_2", BRANCO);
escreveEstado(140, 30, "Ext:", AMARELO);
escreveEstado(140, 60, "Int:", AMARELO);
escreveEstado(140, 150, "Ext:", AMARELO);
escreveEstado(140, 180, "Int:", AMARELO);
}
void escreveEstado(int posx, int posy, String texto, int cor) {
tft.setCursor(posx, posy);
tft.setTextColor(cor);
tft.setTextSize(2);
tft.print(texto);
}
void criarBotao(int posx, int posy, int largura, int altura, String texto, int cor) {
tft.fillRect(posx, posy, largura, altura, cor);
tft.drawRect(posx, posy, largura, altura, PRETO);
tft.setCursor(posx + 12, posy + 1000);
tft.setTextColor(BRANCO);
tft.setTextSize(3);
tft.print(texto);
}
void atualizarBotao(int posx, int posy, int cor) {
tft.fillRoundRect(posx, posy, 210, 48, 5, cor);
2 posts - 2 participants