Je penses avoir localisé le problème, et ça vient d'un autre problème que je rencontre je penses :
Mon arduino démarre sur une page d'attente pour régler les paramètres. Lorsque c'est fait j'appui sur un bouton qui me change de page. Chaque fois que je veux modifier l'affichage de la première page je suis obligé de faire un :
myGLCD.Init() car sinon l'écran reste figé..... Or le blanc sur l'écran apparait justement avec la pile RTC lorsque j'effectue un myGLCD.Init(). Je penses qu'en résolvant ce bug je résoudrais celui de la pile RTC. Voici mon code (ps désolé pour le bordel j'ai bidouillé a mort pour essayer de trouver le bug et le code est en foutoir).
#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(0x7781, A2, A1, A3, A3, A0);
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
int dispx, dispy;
bool state = true;
int refresh=0;
int a;
int b = 0;
long lsh = 17;
long lsm = 0;
long csh = 22;
long csm = 0;
long llh = 0;
long llm = 0;
long clh = 2;
long clm = 30;
int h, m, s;
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
#define TOUCH_ORIENTATION LANDSCAPE
TouchScreen myTouch(XP, YP, XM, YM, 300);
TSPoint tp;
void Boutons(int x, int y)
{
myGLCD.setColor(0, 255, 0);
myGLCD.drawRect(x, y + 20, x + 40, y - 20);
myGLCD.drawRect(x + 60, y + 20, x + 100, y - 20);
myGLCD.drawLine(x + 10, y, x + 30, y);
myGLCD.drawLine(x + 70, y, x + 90, y);
myGLCD.drawLine(x + 20, y + 10, x + 20, y - 10);
}
void get_heure(int h, int m, int s)
{
DateTime now = rtc.now();
m = int(now.minute());
h = int(now.hour());
s = int(now.second());
Serial.print(h);
Serial.print("\n");
Serial.print(m);
Serial.print("\n");
}
bool menu_parametres()
{
tp = myTouch.getPoint();
if (tp.x <= 680 && tp.x >= 400 && tp.y <= 900 && tp.y >= 820 && tp.z >= 50 && state == false)
{
return true;
}
else
{
return false;
}
}
void detection_boutons()
{
tp = myTouch.getPoint();
if (tp.x <= 720 && tp.x >= 630 && tp.y <= 315 && tp.y >= 210 && tp.z > 50)
{
if (lsm == 59) {
if (lsh == 23)
{ lsh = 0;
lsm = 0;
}
else {
lsh = lsh + 1;
}
}
else {
lsm = lsm + 1;
}
refresh=1;
}
if (tp.x <= 720 && tp.x >= 630 && tp.y <= 475 && tp.y >= 370 && tp.z > 50)
{
if (csm == 59) {
if (csh == 23)
{ csh = 0;
csm = 0;
}
else {
csh = csh + 1;
}
}
else {
csm = csm + 1;
}
refresh=1;
}
if (tp.x <= 720 && tp.x >= 630 && tp.y <= 630 && tp.y >= 510 && tp.z > 50)
{
if (llm == 59) {
if (llh == 23)
{ llh = 0;
llm = 0;
}
else {
llh = llh + 1;
}
}
else {
llm = llm + 1;
}
refresh=1;
}
if (tp.x <= 720 && tp.x >= 630 && tp.y <= 790 && tp.y >= 680 && tp.z > 50)
{
if (clm == 59) {
if (clh == 23)
{ clh = 0;
clm = 0;
}
else {
clh = clh + 1;
}
}
else {
clm = clm + 1;
}
refresh=1;
}
if (tp.x <= 860 && tp.x >= 770 && tp.y <= 315 && tp.y >= 210 && tp.z > 50)
{
if (lsm == 0) {
if (lsh == 0)
{ lsh = 23;
lsm = 59;
}
else {
lsh = lsh - 1;
lsm = 59;
}
}
else {
lsm = lsm - 1;
}
refresh=1;
}
if (tp.x <= 860 && tp.x >= 770 && tp.y <= 475 && tp.y >= 370 && tp.z > 50)
{
if (csm == 0) {
if (csh == 0)
{ csh = 23;
csm = 59;
}
else {
csh = csh - 1;
csm = 59;
}
}
else {
csm = csm - 1;
}
refresh=1;
}
if (tp.x <= 860 && tp.x >= 770 && tp.y <= 630 && tp.y >= 510 && tp.z > 50)
{
if (llm == 0) {
if (llh == 0)
{ llh = 23;
llm = 59;
}
else {
llh = llh - 1;
llm = 59;
}
}
else {
llm = llm - 1;
}
refresh=1;
}
if (tp.x <= 860 && tp.x >= 770 && tp.y <= 790 && tp.y >= 680 && tp.z > 50)
{
if (clm == 0) {
if (clh == 0)
{ clh = 23;
clm = 59;
}
else {
clh = clh - 1;
clm = 59;
}
}
else {
clm = clm - 1;
}
refresh=1;
};
if (tp.x <= 680 && tp.x >= 400 && tp.y <= 900 && tp.y >= 820 && tp.z > 20)
{
Serial.print("We Made It !! \n");
a = 0;
};
}
void ecran_home()
{
int c = 17;
int d = 00;
//get_heure(h,m,s);
if (b == 1) //Si on vient de passer à l'écran home depuis l'écran paramètres
{
myGLCD.fillScr(0, 0, 0);
myGLCD.setColor(0, 250, 0);
myGLCD.setColor(150, 0, 175);
myGLCD.fillRect(100, 200, 220, 240);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(150, 0, 175);
myGLCD.print("PARAMETRES", 130, 215);
myGLCD.setBackColor(0, 0, 0);
};
myGLCD.setColor(255, 255, 255);
myGLCD.printNumI(c, 140, 120, 2, "0");
myGLCD.print(":", 160, 120);
myGLCD.printNumI(d, 180, 120, 2, "0");
}
void ecran_parametres()
{
refresh=1;
a = 1;
do
{
if (refresh==1)
{
myGLCD.InitLCD(TOUCH_ORIENTATION);
myGLCD.fillScr(0, 0, 0);
Boutons(200, 30);
Boutons(200, 80);
Boutons(200, 130);
Boutons(200, 180);
myGLCD.setColor(150, 0, 175);
myGLCD.fillRect(100, 200, 220, 240);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(150, 0, 175);
myGLCD.print("HOME", 148, 215);
myGLCD.setBackColor(0, 0, 0);
myGLCD.print("Leve Soleil : ", 20, 30);
myGLCD.print(":", 155, 30);
myGLCD.print("Couche Soleil : ", 20, 80);
myGLCD.print(":", 155, 80);
myGLCD.print("Leve Lune : ", 20, 130);
myGLCD.print(":", 155, 130);
myGLCD.print("Couche Lune : ", 20, 180);
myGLCD.print(":", 155, 180);
myGLCD.printNumI(lsh, 140, 30, 2, '0');
myGLCD.printNumI(lsm, 170, 30, 2, '0');
myGLCD.printNumI(csh, 140, 80, 2, '0');
myGLCD.printNumI(csm, 170, 80, 2, '0');
myGLCD.printNumI(llh, 140, 130, 2, '0');
myGLCD.printNumI(llm, 170, 130, 2, '0');
myGLCD.printNumI(clh, 140, 180, 2, '0');
myGLCD.printNumI(clm, 170, 180, 2, '0');
refresh=0;
};
detection_boutons();
} while (a == 1);
}
void setup() {
Serial.begin(9600);
digitalWrite(A0, HIGH);
pinMode(A0, OUTPUT);
dispx = myGLCD.getDisplayXSize();
dispy = myGLCD.getDisplayYSize();
myGLCD.InitLCD(TOUCH_ORIENTATION);
myGLCD.clrScr();
/* rtc.begin();
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
DateTime now = rtc.now();
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() {
b = 0;
Serial.print("depart");
if (state == true)
{
Serial.print("boucle parametres");
ecran_parametres();
myGLCD.InitLCD(TOUCH_ORIENTATION);
myGLCD.clrScr();
b = 1;
};
Serial.print("boucle home");
ecran_home();
state = menu_parametres();
Serial.print(state);
}
D'ailleur au passage si quelqu'un peut m'expliquer comment sortir mes fonctions auxiliaires de mon code principal malgré qu'il y ai des variables globales et des librairies dans tous les sens, je suis preneur.