Hi all! I'm new here, so i'll be happy for any help given. Let's get to the chase. The hardware that im using is a generic ESP32 Dev Module(pictures included) and a cheap 2.4" tft module from alliexpres which is supposed to have a ILI9341 controller. Im using the Bodmer's TFT_eSPI library which is configured for ESP32 and ILI9341 driver with the following line "#include <User_Setups/Setup42_ILI9341_ESP32.h> " inside User_Setup_Select.h. I ran the Read_User_Setup.ino and got the following results(picture included). Also i had a chance to run the code on another 3.2" tft screen again with ILI9341 and it works like a charm(picture included).
The problem is as it shows on the pictures the screen is not fully used i dont know whats causing it and how to resolve the issue also the colors seem off even tho nothing has changed in the code since the run on the 3.2". If anyone has any idea as to what is causing this malfunction please shoot because im stuck. Cheers!
"Fonts.h" and "Xbm.h" are just files to hold the custom fonts and xbitmap files for the symbols if needed i can provide them too.
Here's the code:
#include <TFT_eSPI.h>
#include "Fonts.h"
#include "Xbm.h"
//#include <Free_Fonts.h>
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite smaint = TFT_eSprite(&tft); // Sprite object smaint
TFT_eSprite smainp = TFT_eSprite(&tft); // Sprite object smaint
TFT_eSprite smaini = TFT_eSprite(&tft); // Sprite object smaint
TFT_eSprite smainw = TFT_eSprite(&tft); // Sprite object smaint
TFT_eSprite smainpr = TFT_eSprite(&tft); // Sprite object smaint
int power_percent;
String power_string;
int real_temp;
int o = 14;
float input_voltage = 36.4;
int power = 200;
String voltage_str, power_str;
int presset_temp[] = { 300, 350, 400 };
int screen = 0;
int state = 1;
int set_temp = 350;
int state1 = 1;
String state1_str[] = { "OFF", "Heating", "Standby" };
int iron_type = 0;
String iron_type_str[] = { "T245", "T12" };
//==========================================================================================
void setup() {
Serial.begin(115200);
tft.init();
tft.fillScreen(TFT_BLACK);
tft.setRotation(0);
tft.invertDisplay(false);
tft.color
smaint.createSprite(210, 85);
smainp.createSprite(52, 225);
smaini.createSprite(320, 15);
smainw.createSprite(210, 80);
smainpr.createSprite(200, 25);
smaint.fillSprite(TFT_BLACK);
smaint.setTextColor(TFT_CYAN, TFT_BLACK);
smainp.fillSprite(TFT_BLACK);
smainp.setTextColor(TFT_CYAN, TFT_BLACK);
smaini.fillSprite(TFT_BLACK);
smaini.setTextColor(TFT_WHITE, TFT_BLACK);
smainw.fillSprite(TFT_BLACK);
smainw.setTextColor(TFT_WHITE, TFT_BLACK);
smainpr.fillSprite(TFT_BLACK);
smainpr.setTextColor(TFT_WHITE, TFT_BLACK);
Serial.printf("x%d, y%d", tft.height(),tft.width());
}
//==========================================================================================
long prmillis1, prmillis2, prmillis3;
int i;
String data;
void loop() {
if (screen == 0) Mainscreen();
}
void Mainscreen_temp() {
real_temp = 499;//map(analogRead(26), 0, 4096, 0, 500);
smaint.setTextSize(1);
smaint.setFreeFont(&DSEG7_Classic_Mini_Regular_80);
smaint.drawNumber(real_temp, 200, 42);
if (real_temp < 100) smaint.fillRect(0, 0, 60, 85, TFT_BLACK);
if (real_temp < 10) smaint.fillRect(60, 0, 80, 85, TFT_BLACK);
smaint.setFreeFont(&TomThumb);
smaint.setTextDatum(MR_DATUM);
smaint.drawString("o", 198, 3, 2);
smaint.setFreeFont(&FreeMono12pt7b);
smaint.drawString("C", 210, 9);
smaint.pushSprite(o + 48, 110);
}
void Mainscreen_power() {
power_percent = 100; //map(analogRead(26), 0, 4095, 0, 100);
smainp.setTextColor(TFT_WHITE, TFT_BLACK);
smainp.setFreeFont(&Roboto_Light_16);
smainp.setTextDatum(MC_DATUM);
smainp.drawRect(15, 15, 20, 180, 0x195AFF);
smainp.fillRect(0, 200, 50, 25, TFT_BLACK);
power_string = "";
power_string += power_percent;
power_string += "%";
smainp.drawString(power_string, 25, 207);
smainp.fillRectVGradient(16, 16, 18, 178, TFT_RED, TFT_BLUE);
smainp.fillRect(16, 16, 18, map(power_percent, 0, 100, 178, 0), TFT_BLACK);
smainp.pushSprite(0, 16);
}
void Mainscreen_info() {
smaini.setTextDatum(TL_DATUM);
smaini.setFreeFont(&Roboto_14);
voltage_str = "";
voltage_str += input_voltage;
voltage_str += "V";
smaini.drawString(voltage_str, 0, 2);
power_str = "";
power_str += power;
power_str += "W";
smaini.drawString(power_str, 65, 2);
smaini.setTextDatum(TC_DATUM);
smaini.drawString("15:45", 160, 2);
smaini.setTextDatum(TR_DATUM);
smaini.drawString("v2.0", 320, 2);
smaini.pushSprite(0, 0);
}
void Mainscreen_presset() {
tft.drawLine(0, 15, 320, 15, TFT_DARKGREY);
smainpr.drawRect(0, 0, 50, 25, 0x195AFF);
smainpr.drawRect(67, 0, 50, 25, 0x195AFF);
smainpr.drawRect(132, 0, 50, 25, 0x195AFF);
smainpr.setTextColor(TFT_WHITE, TFT_BLACK);
smainpr.setFreeFont(&Roboto_Light_16);
smainpr.setTextDatum(MC_DATUM);
smainpr.drawNumber(presset_temp[0], 25, 12);
smainpr.drawNumber(presset_temp[1], 92, 12);
smainpr.drawNumber(presset_temp[2], 157, 12);
smainpr.pushSprite(72, 215);
}
void Mainscreen_widgets() {
smainw.fillRect(100, 10, 2, 7, TFT_LIGHTGREY);
smainw.fillRect(100, 21, 2, 7, TFT_LIGHTGREY);
smainw.fillRect(100, 32, 2, 7, TFT_LIGHTGREY);
smainw.fillRect(100, 43, 2, 7, TFT_LIGHTGREY);
smainw.fillRect(100, 54, 2, 7, TFT_LIGHTGREY);
smainw.fillRect(100, 65, 2, 7, TFT_LIGHTGREY);
if (state == 1) smainw.drawXBitmap(0, 12, temp_high, temp_high_width, temp_high_height, TFT_BLACK, TFT_RED);
if (state == 0) smainw.drawXBitmap(0, 12, temp_low, temp_low_width, temp_low_height, TFT_BLACK, TFT_BLUE);
smainw.setTextDatum(MC_DATUM);
smainw.setFreeFont(&Monospaced_bold_16);
smainw.drawString("SET", 54, 20);
smainw.drawRect(30, 40, 50, 25, 0x195AFF);
smainw.setFreeFont(&Roboto_Light_16);
smainw.drawNumber(set_temp, 55, 52);
smainw.setTextDatum(MC_DATUM);
smainw.setFreeFont(&Monospaced_bold_16);
if (state1 == 0){smainw.setTextColor(TFT_BLUE); smainw.drawString(state1_str[state1], 160, 20);}
if (state1 == 1){smainw.setTextColor(TFT_RED); smainw.drawString(state1_str[state1], 160, 20);}
if (state1 == 2){smainw.setTextColor(TFT_GREEN); smainw.drawString(state1_str[state1], 160, 20);}
smainw.setFreeFont(&Monospaced_bold_16);smainw.setTextColor(TFT_WHITE);smainw.drawString(iron_type_str[iron_type], 160, 52);
smainw.pushSprite(60, 20);
}
void Mainscreen() {
if (millis() - prmillis2 >= 150) {
prmillis2 = millis();
Mainscreen_info();
}
if (millis() - prmillis1 >= 50) {
prmillis1 = millis();
Mainscreen_power();
Mainscreen_temp();
}
if (millis() - prmillis3 >= 500) {
prmillis3 = millis();
Mainscreen_presset();
Mainscreen_widgets();
}
}