Hello dear forumers,
I'm creating a new post about a component conflict. Indeed For one of my projects i'm using :
- Arduino UNO R3
- MCUFriend TFT touch screen 2,4" in kit with arduino : Aliexpress Kit
- Tiny RTC I2C modules
My RTC is wired on SCL/SDA/+5V/GND
Touch screen shield use A4 as LCD_RST Pin wich is sadly an SDA pin
I have had some trouble to find a correct library and during the research i found that my LCD use a ST7783 Driver wich i can't confirm now.
My problem is that when i use RTC i loose my screen. A simple code i made to test it is :
#include <Adafruit_GFX.h>
#include <UTFTGLUE.h>
#include <SPI.h>
#include <MCUFRIEND_kbv.h>
#include <RTClib.h>
#include <Wire.h>
#include <avr/pgmspace.h>
MCUFRIEND_kbv tft;
RTC_DS1307 rtc;
#include <TouchScreen.h>
#define YP A1
#define YM 7
#define XM A2
#define XP 6
UTFTGLUE myGLCD(0x7783, A2, A1, A3, A4, A0);
#define TOUCH_ORIENTATION LANDSCAPE
TouchScreen myTouch(XP, YP, XM, YM, 300);
TSPoint tp;
//Hour, minutes, seconds RTC
int h, m, s;
void setup() {
//Init serial for diagnostics
Serial.begin(9600);
//Initialising LCD
myGLCD.InitLCD(TOUCH_ORIENTATION);
myGLCD.clrScr();
myGLCD.fillScr(0,0,0);
myGLCD.setColor(150,0,25);
//Init wire and RTC lib .
Wire.begin();
rtc.begin();
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
DateTime now = rtc.now();
//Serial test on RTC
m = int(now.minute());
h = int(now.hour());
s = int(now.second());
Serial.print(h);
Serial.print("\n");
Serial.print(m);
Serial.print("\n");
}
void loop() {
Serial.print("loop is on \n");
DateTime now=rtc.now();
m=int(now.minute());
h=int(now.hour());
s=int(now.second());
myGLCD.printNumI(h,140,120,2,'0');
myGLCD.print(":",150,120);
myGLCD.printNumI(m,160,120,2,'0');
myGLCD.printNumI(s,148,150);
delay(1000);
}
The LCD is Bright white because i guess he is doing some kind of reset again and again.
I have already try to change A4 buy 10 (pin 10 is use for SD Card which i don't use here, or by A3 or any other pins. REsults is the same. Changes were done in :
UTFTGLUE myGLCD(0x7783, A2, A1, A3, A4, A0);
I have on other unsold problem which involve this time only the Touch screen (maybe it's linked with the previous one).
If i use the touch screen function i cannot modify display anymore until i do a myGLCD.Init() again. For exemple look at this code with 2 menus :
#include <Adafruit_GFX.h>
#include <UTFTGLUE.h>
#include <SPI.h>
#include <MCUFRIEND_kbv.h>
#include <RTClib.h>
#include <Wire.h>
#include <avr/pgmspace.h>
MCUFRIEND_kbv tft;
RTC_DS1307 rtc;
#include <TouchScreen.h>
#define YP A1
#define YM 7
#define XM A2
#define XP 6
UTFTGLUE myGLCD(0x7783, A2, A1, A3, A4, A0);
#define TOUCH_ORIENTATION LANDSCAPE
TouchScreen myTouch(XP, YP, XM, YM, 300);
TSPoint tp;
//Hour, minutes, seconds RTC
int h, m, s;
void RGB()
{
delay(1000);
myGLCD.fillScr(255,0,0);
delay(1000);
myGLCD.fillScr(0,255,0);
delay(1000);
myGLCD.fillScr(0,0,255);
}
void PageMenu1()
{
myGLCD.fillScr(0,0,0);
//Ligne 1
myGLCD.setColor(255,255,255);
myGLCD.drawRect(200,50,240,10);
myGLCD.drawRect(260,50,300,10);
//Ligne 2
myGLCD.drawRect(200,100,240,60);
myGLCD.drawRect(260,100,300,60);
//Ligne 3
myGLCD.drawRect(200,150,240,110);
myGLCD.drawRect(260,150,300,110);
//Ligne 4
myGLCD.drawRect(200,200,240,160);
myGLCD.drawRect(260,200,300,160);
//Buton Home
myGLCD.setColor(150, 0, 175);
myGLCD.fillRect(90, 200, 220, 240);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(150, 0, 175);
myGLCD.print("HOME", 148, 215);
myGLCD.setBackColor(0, 0, 0);
delay(1000);
}
void PageMenu2()
{
int minutes, secondes;
int TokenExit=1;
minutes=0;
secondes=0;
myGLCD.fillScr(0,0,0);
myGLCD.setColor(255,255,255);
//Button Menu1()
myGLCD.setColor(0, 250, 0);
myGLCD.setColor(150, 0, 175);
myGLCD.fillRect(90, 200, 220, 240);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(150, 0, 175);
myGLCD.print("PARAMETRES", 125, 215);
myGLCD.setBackColor(0, 0, 0);
myGLCD.print(":",150,120);
do{
myGLCD.setColor(0,0,0);
myGLCD.fillRect(140,130,145,110);
myGLCD.setColor(255,255,255);
myGLCD.printNumI(minutes,140,120,2,"0");
myGLCD.setColor(0,0,0);
myGLCD.fillRect(155,130,175,110);
myGLCD.setColor(255,255,255 );
myGLCD.printNumI(secondes,160,120,2,"0");
Serial.print(secondes);
secondes=secondes+1;
delay(1000);
tp= myTouch.getPoint();
if (tp.x <= 680 && tp.x >= 400 && tp.y <= 900 && tp.y >= 820 && tp.z > 20)
{
TokenExit = 0;
};
}while (TokenExit==1);
Serial.print("we are out");
}
void setup() {
//Init serial for diagnostics
Serial.begin(9600);
//Initialising LCD
pinMode(A0, OUTPUT);
digitalWrite(A0, HIGH);
myGLCD.InitLCD(TOUCH_ORIENTATION);
myGLCD.clrScr();
myGLCD.fillScr(0,0,0);
myGLCD.setColor(150,0,25);
//Init wire and RTC lib .
/*Wire.begin();
rtc.begin();
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
DateTime now = rtc.now();
//Serial test on RTC
m = int(now.minute());
h = int(now.hour());
s = int(now.second());
Serial.print(h);
Serial.print("\n");
Serial.print(m);
Serial.print("\n");*/
}
void loop()
{
RGB();
PageMenu1();
PageMenu2();
}
If i use lines :
tp= myTouch.getPoint();
if (tp.x <= 680 && tp.x >= 400 && tp.y <= 900 && tp.y >= 820 && tp.z > 20)
{
TokenExit = 0;
};
The LCD do not refresh any more (as if i do a ClearScreen or anything else) unitl i do a myGLCD.Init().
Can someone plz help me with my hardware problems ![]()
I have done some research and just to let you know i'm not using any pull up resistors. MAybe it's a bad point i'm not really good in Hardware and I2C