Hello forum,
I am a bit of a newbie to Arduino, but have some experience programming. I am baffled by the issue I am having with my current project: a Mega 2650, with 2.8" TFT, and thermocouple amplifiers to sense and display cylinder head and exhaust gas temps on an air-cooled Volkswagen.
I am using an mcufriend 2.8" TFT touchscreen with the fine library available at MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields - Displays - Arduino Forum
I am using one MAX 6675 thermocouple amplifier board currently, with the fine library available at GitHub - adafruit/MAX6675-library: Arduino library for interfacing with MAX6675 thermocouple amplifier
This is running on a Mega 2650, which I realize is not ideal for this screen, but I needed the end of the board open for four total thermocouple amps. It is still much faster than I need for what is essentially a multi-gauge.
The issue I have is that the code executes, and displays the correct temperature, but print() and printNumI() will not overwrite the initial thermocouple reading unless I use clrScr(), which allows it to update the proper temp. Mind you, I added a cycle counter using the same call (printNumI[]), and it works correctly, counting up main loop executions while the thermocouple temp remains static. Here is my code, which I cobbled together from two known working sketches (one for the thermocouple and one for the screen):
#define TOUCH_ORIENTATION LANDSCAPE
#include <Adafruit_GFX.h>
#include <UTFTGLUE.h> //we are using UTFT display methods
UTFTGLUE myGLCD(0x9341, A2, A1, A3, A4, A0);
#include <max6675.h>
// ThermoCouple
int thermo_gnd_pin = 45;
int thermo_vcc_pin = 47;
int thermo_so_pin = 53;
int thermo_cs_pin = 51;
int thermo_sck_pin = 49;
int count = 0;
MAX6675 thermocouple(thermo_sck_pin, thermo_cs_pin, thermo_so_pin);
extern uint8_t SmallFont[];
uint32_t cx, cy;
uint32_t rx[8], ry[8];
int32_t clx, crx, cty, cby;
float px, py;
int dispx, dispy, text_y_center, swapxy;
uint32_t calx, caly, cals;
char buf[13];
void setup()
{
Serial.begin(9600);
pinMode(thermo_vcc_pin, OUTPUT);
pinMode(thermo_gnd_pin, OUTPUT);
digitalWrite(thermo_vcc_pin, HIGH);
digitalWrite(thermo_gnd_pin, LOW);
digitalWrite(A0, HIGH);
pinMode(A0, OUTPUT);
myGLCD.InitLCD(TOUCH_ORIENTATION);
myGLCD.clrScr();
myGLCD.setFont(SmallFont);
dispx = myGLCD.getDisplayXSize();
dispy = myGLCD.getDisplayYSize();
text_y_center = (dispy / 2) - 6;
myGLCD.print("Temp:", CENTER, text_y_center - 12);
}
void loop()
{
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(0, 0, 0);
//myGLCD.clrScr();
myGLCD.printNumI(int(thermocouple.readFahrenheit()), CENTER, text_y_center);
myGLCD.printNumI(count, CENTER, text_y_center + 12);
count++;
}
TFT_Thermocouple_Test_no_touch.ino (1.52 KB)