Hello,
I spend the last few days on making a GUI with a Homescreen and some under menus.
This is my first Project where I try to avoid to use the delay function and do all the timings with
millis. For a better overview I just post the Setup. On the UNO (Original) everything works perfect.
But due to the lack of unused pins a need a Mega to get all the Hardware connected. And thats my Problem:
Connected to the Mega( Not Original, link at the End) I only get a white Screen. I´ve got some Serial Print for debugging on each button on the Screen and it seems that the Touch is working properly.
The diagnose Sketches from MCUfriend are working correctly. The Chip is a 9341. So I think it need something to do with my Sketch..
#include <Adafruit_TFTLCD.h>
#include <Adafruit_GFX.h>
#include <TouchScreen.h>
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define TS_MINX 898 // TS_LEFT 75
#define TS_MINY 915 // TS_TOP 901
#define TS_MAXX 75 // TS_RIGHT 918
#define TS_MAXY 105 // TS_BOTTOM 98
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define GRAY 0x94B2
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
const int XP = 8;
const int XM = A2;
const int YP = A3;
const int YM = 9;
int pixel_x, pixel_y;
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); // Resistance between D8 and A2
byte Homepage = true;
byte SettingsAll = false;
byte SettingsDuration = false;
byte SettingsIntensity = false;
byte TouchDebounce = false; // false= inaktiv , true= aktiv
byte RemainTimeUpdate = false; // Restdauer Zähler Nur Anzeige?
byte MainProgrammReady = true;
byte MainProgrammRunning = false;
byte MainProgrammPaused = false;
byte MainProgrammContinued = false;
byte MainProgrammFinished = false;
byte MainProgrammColorUpdate = true;
byte WasherYReferenz = false;
byte WasherYPosUP; // false = unten im Glas , true = Oben für Referenz
byte WasherXReferenz = false;
byte WasherXPos1;
byte WasherXPos2;
int RPMPos1 = 200;
int DurationPos1 = 30;
int DurationInsgesamt;
// Timings
unsigned long currentTime;
unsigned long previousTimeTouchDebounce = 0; // Start Millis, wird geupdatet
unsigned long IntervalTouchDebounce = 1000; // Debounce Time
unsigned long previousTimeRemainTime = 0;
unsigned long IntervalRemainTime = 1000; // Remain Time Update Interval
unsigned long MainProgrammRemainTime = 0;
unsigned long MainProgrammStartTime = 0;
//-----------------------------------------------------------------SETUP-----------------------
void setup() {
Serial.begin(9600);
Serial.println("Starting...");
tft.reset();
tft.begin(0x9341);
tft.setRotation(1);
Homepage = true;
DrawHomepage(); // declared later, draws all the Button etc
}
Is there a point I´m missing where I need to say the TFT that it is mounted to an Mega?
Arduino:
https://www.amazon.de/gp/product/B01MCX1CIN/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&th=1
Display:
https://www.amazon.de/gp/product/B01EUVJYME/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1