Horloge Analogique

Bonjour
-Arduino mega
-TFT LCD 2.8
voila je viens de monter une Horloge analogique en me basant sur ce lien

et cela marche bien (aucun merite sauf de l'avoir monte :cry: ) ....a chaque on/off je doit relancer le sketch pour qu'elle se met a l'heure du pc
ma question est : y a t'il un moyen pour updater l'heure sans televerser le sketch a chaque allumage (on transmettant le time via usb par exemple ou ajouter des commandes dans le sketch pour pouvoir regler le time via l'ecran tft ou arduino + switch )?

sinon si je devais ajouter un RTC (je pense que c'est la solution idoine pour la portabilite) que dois-je changer dans le scketch? je joint le code a toute fin utile

merci pour tout

#include <SPFD5408_Adafruit_TFTLCD.h>
//TFT  & Arduino pins affectation 
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

// Human Readable color
#define TFT_BLACK   0x0000
#define TFT_BLUE    0x001F
#define TFT_RED     0xF800
#define TFT_GREEN   0x07E0
#define TFT_CYAN    0x07FF
#define TFT_MAGENTA 0xF81F
#define TFT_YELLOW  0xFFE0
#define TFT_WHITE   0xFFFF
#define TFT_GREY    0x5AEB

// Invoke custom library for TFT 
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

float sx = 0, sy = 1, mx = 1, my = 0, hx = -1, hy = 0;    
float sdeg = 0, mdeg = 0, hdeg = 0;
uint16_t osx = 120, osy = 120, omx = 120, omy = 120, ohx = 120, ohy = 120; 
int16_t x0 = 0, x1 = 0, yy0 = 0, yy1 = 0, x00 = 0, yy00 = 0;

// for next 1 second timeout
uint32_t targetTime = 0;                    

uint16_t xpos; 

// Forward declaration needed for IDE 1.6.x
uint8_t conv2d(const char* p) {
  uint8_t v = 0;
  if ('0' <= *p && *p <= '9')
    v = *p - '0';
  return 10 * v + *++p - '0';
}

// Get H, M, S from compile time
uint8_t hh = conv2d(__TIME__), mm = conv2d(__TIME__ + 3), ss = conv2d(__TIME__ + 6); 
boolean initial = 1;
char d;
void setup(void) {
  tft.reset();  
  tft.begin(0x9341); 
  tft.setRotation(1);

  tft.setTextColor(TFT_WHITE);// text color
  tft.fillScreen(TFT_BLACK);// background color

  xpos = tft.width() / 2; 
  tft.drawCircle(xpos, 120, 125, TFT_YELLOW); //1st outer circle 
  tft.fillCircle(xpos, 120, 118, TFT_BLUE);   //2nd circle 
  tft.fillCircle(xpos, 120, 110, TFT_BLACK);  //3th circle in black
  for (int a=95; a<104; a++){
                  tft.drawCircle(xpos, 120, a, TFT_WHITE);} 
 
  for (int i = 0; i < 360; i += 30) {
    sx = cos((i - 90) * 0.0174532925);
    sy = sin((i - 90) * 0.0174532925);
    x0 = sx * 114 + xpos;
    yy0 = sy * 114 + 120;
    x1 = sx * 100 + xpos;
    yy1 = sy * 100 + 120;
    tft.drawLine(x0, yy0, x1, yy1, TFT_YELLOW);
  }

  
  for (int i = 0; i < 360; i += 6) {
    sx = cos((i - 90) * 0.0174532925);
    sy = sin((i - 90) * 0.0174532925);
    x0 = sx * 102 + xpos;
    yy0 = sy * 102 + 120;
    x00 = sx * 92 + xpos;
    yy00 = sy * 92 + 120;
    // Draw minute markers
    tft.drawPixel(x0, yy0, TFT_GREEN); 
    tft.drawLine(x0, yy0, x00, yy00, TFT_BLACK);
    tft.drawLine(x0+1, yy0+1, x00+1, yy00+1, TFT_BLACK);

    // Draw main quadrant dots
    if (i == 0 || i == 180) tft.fillCircle(x0, yy0, 2, TFT_WHITE); 
    if (i == 90 || i == 270) tft.fillCircle(x0, yy0, 2, TFT_WHITE); 
  }

  tft.fillCircle(xpos, 121, 3, TFT_WHITE);
  targetTime = millis() + 1000;
}

void loop() {
  if (targetTime < millis()) {
    targetTime = millis() + 1000;
    ss++;              
    if (ss == 60) {
      ss = 0;
      mm++;            
      if (mm > 59) {
        mm = 0;
        hh++;          
        if (hh > 23) {
          hh = 0;
        }
      }
    }

   
    sdeg = ss * 6;                     // 0-59 -> 0-354
    mdeg = mm * 6 + sdeg * 0.01666667; // 0-59 -> 0-360 - includes seconds, but these increments are not used
    hdeg = hh * 30 + mdeg * 0.0833333; // 0-11 -> 0-360 - includes minutes and seconds, but these increments are not used
    hx = cos((hdeg - 90) * 0.0174532925);
    hy = sin((hdeg - 90) * 0.0174532925);
    mx = cos((mdeg - 90) * 0.0174532925);
    my = sin((mdeg - 90) * 0.0174532925);
    sx = cos((sdeg - 90) * 0.0174532925);
    sy = sin((sdeg - 90) * 0.0174532925);

    if (ss == 0 || initial) {
      initial = 0;
      // Erase hour and minute hand positions every minute
      tft.drawLine(ohx, ohy, xpos, 121, TFT_BLACK);
      ohx = hx * 62 + xpos + 1;
      ohy = hy * 62 + 121;
      tft.drawLine(omx, omy, xpos, 121, TFT_BLACK);
      omx = mx * 84 + xpos;
      omy = my * 84 + 121;
    }

    // Redraw new hand positions, hour and minute hands not erased here to avoid flicker
    tft.drawLine(osx, osy, xpos, 121, TFT_BLACK);
    osx = sx * 90 + xpos + 1;
    osy = sy * 90 + 121;
    tft.drawLine(osx, osy, xpos, 121, TFT_RED);
    tft.drawLine(ohx, ohy, xpos, 121, TFT_CYAN);
    tft.drawLine(omx, omy, xpos, 121, TFT_WHITE);
    tft.drawLine(osx, osy, xpos, 121, TFT_RED);
    tft.fillCircle(xpos, 121, 3, TFT_RED);

  tft.setCursor(xpos-30, 50);
  tft.setTextSize(2);
  tft.print("H-Ah");
 
  // Draw MINI clock face "SECOND"
  tft.drawCircle(xpos, 155, 20, TFT_YELLOW);
  tft.drawCircle(xpos, 155, 18, TFT_BLUE);
  tft.drawCircle(xpos, 155, 17, TFT_CYAN);
  tft.drawCircle(xpos, 155, 16, TFT_CYAN);
  tft.fillRect(xpos-10, 149,22,15,TFT_BLACK); //erase
  if(ss<10){tft.setCursor(xpos-10, 149); tft.setTextSize(2);
  tft.print('0'); tft.setCursor(xpos+2, 149);}
  else{
  tft.setCursor(xpos-10, 149);}
  tft.setTextSize(2);
  tft.print(ss);
  
  // Draw MINI clock face "Minutes"
  tft.drawCircle(xpos+35, 117, 20, TFT_YELLOW);
  tft.drawCircle(xpos+35, 117, 18, TFT_BLUE);
  tft.drawCircle(xpos+35, 117, 17, TFT_CYAN);
  tft.drawCircle(xpos+35, 117, 16, TFT_CYAN);
 tft.fillRect(xpos+25, 111,22,15,TFT_BLACK); //erase
  if(mm<10){tft.setCursor(xpos+25, 111); tft.setTextSize(2);
  tft.print('0'); tft.setCursor(xpos+37, 111);}
  else{
  tft.setCursor(xpos+25, 111);}
  tft.println(mm);
  
  // Draw MINI clock face "Hour"
  tft.drawCircle(xpos-35, 117, 20, TFT_YELLOW);
  tft.drawCircle(xpos-35, 117, 18, TFT_BLUE);
  tft.drawCircle(xpos-35, 117, 17, TFT_CYAN);
  tft.drawCircle(xpos-35, 117, 16, TFT_CYAN);
  tft.fillRect(xpos-45, 111,22,15,TFT_BLACK); //erase
  if(hh<10){tft.setCursor(xpos-45, 111); tft.setTextSize(2);
  tft.print('0'); tft.setCursor(xpos-33, 111);}
  else{
  tft.setCursor(xpos-45, 111);}
  tft.setTextSize(2);
  tft.print(hh);
  //tft.setCursor(xpos-65, 111);
  //tft.println(':');

  if (hh>=0 && hh<12) d='A'; else {d='P';}
  tft.drawRoundRect(xpos-14,72,29,21,5,TFT_CYAN);
  tft.fillRect(xpos-11, 75,23,15,TFT_BLACK); //erase
  tft.setCursor(xpos-11, 75);
  tft.setTextSize(2);
  tft.print(d);
  tft.println('M');
  }
}

On peut tout faire, surtout lorsque l'on dispose d'un écran tactile.

Sinon l'horloge RTC est indispensable, sinon l'heure dérivera fortement.
J'ai déjà constaté une assez importante : 2 minutes sur 48 heures, donc 2.5 secondes par heure.
Pour une minuterie c'est sans conséquence ou presque, pour une horloge ça l'est moins.

Merci
reste a savoir comment transformer le sketch pour un rtc DS 3231 (que j'ai sous la main) sans perdre le canevas de l'horloge. bref je ne sais pas comment le sketch opere pour recueillir le temps du pc je pense que cela vient de cette ligne"uint8_t hh = conv2d(TIME), mm = conv2d(TIME + 3), ss = conv2d(TIME + 6);" mais je ne sait
quoi faire reellement ( au debut je me suis dis qu'il suffisait de stocker les valeurs du rtc dans desvariables
hh , mm , et les transmettre a cette ligne mais ca ne marche pas.
un coup de pouce sera le bien venu
merci

Ca dépend de la bibliothèque que tu as choisie
En général c'est cette ligne qui met la DS3231 à l'heure au moment de la compilation du code :

 RTC.adjust(DateTime(__DATE__, __TIME__));

Bricoleau a fait une bibliothèque pour ces RTC, qui prend en compte l'heure d'été / d'hiver

Merci beaucoup je vais voir ce que je peux faire
je vous tiens au jus

bonne soiree

ben il faut dire que j'ai echoue , je m'explique :

le code que j'ai donne au debut du topic , qui est celui d’une horloge analogique sur ecran tft fonctionne tres bien sauf qu’il faut remettre les pendules a l’heure (par re-upload du script ) apres chaque off

j’ai trouve un DS3231 et je me suis fais la main dessus et il fonctionne aussi (affichage sur tft lcd 2,8 ok )

maintenant ce que j’aimerais faire c’est de faire en sorte que l’horloge analogique affiche l’heure transmise par le DS3231
la ou je coince : je ne sais pas qu’elle(s) ligne(s) du code de l’horloge que je dois viree(s) pour la ou les remplacer par celle(s) du DS 3231 sans toucher au cadran de l’horloge

la library de l’horloge :SPFD5408_Adafruit_TFTLCD.h
le code se trouve dans le premier post du topic
la librery du DS :http://www.rinkydinkelectronics.com/library.php?id=73

pouvez vous m’aider svp

merci

nb 1: je suis tres novice en la matiere
nb 2: j'ai trouve ca sur yt c'est la meme clock avec l'ajout du RTC sauf que le monsieur ne donne pas d'explication utile
https://www.youtube.com/watch?v=mFB5HJ-a60g

Bonjour,
Le lien youtube ne fonctionne pas chez moi.

PS : j'aime bien l'idée de l'horloge analogique.

Gerard68:
Bonjour,
Le lien youtube ne fonctionne pas chez moi.

PS : j'aime bien l'idée de l'horloge analogique.

Il suffit de copier//coller les liens dans le navigateur et ca marche

kidd7471:
Il suffit de copier//coller les liens dans le navigateur et ca marche

C'est super pratique sur un téléphone :smiling_imp:
Est ce qu'il ne serait pas mieux de rectifier l'url pour qu'elle soit correcte?

Bonjour,

Voici le lien dans message #5 de kidd7471 :

http://"https://www.youtube.com/watch?v=mFB5HJ-a60g" !!!!

Voici le lien corrige :

Dans ton code (plus haut) tu as trois variables : ss, mm, hh qui contiennent les secondes, minutes et heure.
Il suffit de remplacer les lignes

    ss++;             
    if (ss == 60) {
      ss = 0;
      mm++;           
      if (mm > 59) {
        mm = 0;
        hh++;         
        if (hh > 23) {
          hh = 0;
        }
      }
    }

par les lignes qui te permettent de connaitre les secondes, minutes et heure fournies par ta RTC.
Ca dépend de la bibliothèque que tu utilises, mais il y a sûrement une structure comme tm de laquelle tu peux extraire ces valeurs :

Member Type Meaning Range
tm_sec int seconds after the minute 0-61*
tm_min int minutes after the hour 0-59
tm_hour int hours since midnight 0-23

voire même des [méthodes ](Arduino Forum GitHub - JChristensen/DS3232RTC: Arduino Library for Maxim Integrated DS3232 and DS3231 Real-Time Clocks)qui te permettent de les obtenir directement :

    Serial.print(hour());
    printDigits(minute());
    printDigits(second());
    Serial.print(' ');
    Serial.print(day());
    Serial.print(' ');
    Serial.print(month());
    Serial.print(' ');
    Serial.print(year());
    Serial.println();

merci lesept

je vais revoir le code selon tes conseils

merci beaucoup

sinon pour avoir une mise à l'heure automatique, tu peux aussi ajouter un petit module GPS (ça vaut quelques euros en chine) qui va permettre de récupérer l'heure sur les données GPS. Ca permet par exemple de recaler automatiquement ta RTC si tu constate une dérive

Bon je viens de reussir mon coup . pour dire vrai je n'ai aucun merite sauf d'avoir eu la patience de visionner la video citee plus haut , voici le code que j'espere va aider qqu'un dans le futur

/************************************************************************************************************************
i used an mcufriend tftlcd 2.8 + arduino mega + ds3231 
here is a link for  the   ds 3231 library  and how to use it                                                   /
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-real-time-clock-module-ds3231-bc90fe                    /
                                                                                                                         /
for the analog clk i use this link for clock without RTC                                                               /
https://basicarduinotutorial.blogspot.com/2017/08/project-v-28-analog-clock-on-tft-lcd-24.html?showComment=1606362619219#/
for the analog clk + rtc i i use this link                                                                                        /
https://www.youtube.com/watch?v=mFB5HJ-a60g                                                                              /

                                                                  / 
                                                                                                                         /
*************************************************************************************************************************/
#include <config.h>
#include <ds3231.h>
#include <Wire.h>
#include <SPFD5408_Adafruit_TFTLCD.h>

//TFT  & Arduino pins affectation 
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

//  color
#define TFT_BLACK   0x0000
#define TFT_BLUE    0x001F
#define TFT_RED     0xF800
#define TFT_GREEN   0x07E0
#define TFT_CYAN    0x07FF
#define TFT_MAGENTA 0xF81F
#define TFT_YELLOW  0xFFE0
#define TFT_WHITE   0xFFFF
#define TFT_GREY    0x5AEB
// TFT object 
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
float sx = 0, sy = 1;int scx ,scy ,mx , my , hx , hy ; //saved s ,m , h x, y    
float sdeg , mdeg, hdeg;
int oscx = 90, oscy = 90, omx = 90, omy = 90, ohx = 90, ohy = 90; //saved s , m , h *********
int16_t x0 = 0, x1 = 0, yy0 = 0, yy1 = 0, x00 = 0, yy00 = 0;                   
uint16_t xpos; // x pos 
boolean initial = 1 ;
char d;
struct ts t; 
unsigned  long prev , interval =1000;
uint8_t hh=t.hour , mm= t.min , ss= t.sec ;


void setup(void) {
  Serial.begin (9600);
  DS3231_init(0x00);
  Wire.begin(); 
  tft.reset();  
  tft.begin(0x9341); 
  tft.setRotation(1);
  tft.setTextColor(TFT_WHITE);// text color
  tft.fillScreen(TFT_BLACK);// background color
  
//face horloge 
  xpos = tft.width() / 2; 
  tft.drawCircle(xpos, 120, 117, TFT_YELLOW);
  tft.fillCircle(xpos, 120, 100, TFT_BLUE); 
  tft.fillCircle(xpos, 120, 92, TFT_BLACK); 
  
 //12 lines
  for (int i = 0; i < 360; i += 30) {
    sx = cos((i - 90) * 0.0174532925);
    sy = sin((i - 90) * 0.0174532925);
    x0 = sx * 90 + xpos;
    yy0 = sy * 90 + 120;
    x1 = sx * 100 + xpos;
    yy1 = sy * 100 + 120;
    tft.drawLine(x0, yy0, x1, yy1, TFT_YELLOW);
  }

//60 dot 
  for (int i = 0; i < 360; i += 6) {
    sx = cos((i - 90) * 0.0174532925);
    sy = sin((i - 90) * 0.0174532925);
    x0 = sx * 102 + xpos;
    yy0 = sy * 102 + 120;
    x00 = sx * 92 + xpos;
    yy00 = sy * 92 + 120;

// Draw minute markers
    tft.drawPixel(x0, yy0, TFT_GREEN); 

// Draw main quadrant dots
    if (i == 0 || i == 180) tft.fillCircle(x0, yy0, 2, TFT_WHITE); 
    if (i == 90 || i == 270) tft.fillCircle(x0, yy0, 2, TFT_WHITE); 
  }
  tft.fillCircle(xpos, 121, 3, TFT_WHITE);
}

void loop() {  
            struct ts t;  //retraving data from rtc 
            DS3231_get(&t);           
            unsigned long now = millis ();//local var set to current value of arduino unternal 

//deaw & update screen evry refresh T=100ms
           if ((now - prev> interval))
              {
//determine wether to start a time & refresh display
//computing hand mvt   
    sdeg = (t.sec   * 6/57.29577951);         // 1 Radian = 57.29577951 degrees         
    mdeg = (t.min   * 6/57.29577951); 
    hdeg = (t.hour  * 30 + int (t.min/12)*6);
    hdeg = (hdeg/57.29577951);

    scx = ( xpos+(sin(sdeg)*(117-33)));//sec
    scy = (120-(cos(sdeg)*(117-33)));
    
    mx  = (xpos+(sin(mdeg)*(117-32)));//min
    my=   (120-(cos (mdeg)*(117-32)));    //min hand pos

    hx=   (xpos+(sin (hdeg)*(117-54)));//hr
    hy=   (120- (cos(hdeg)*(117-54)));  //hr hand pos
    
    if (t.sec == 0 || initial) {
      initial = 0;
      // Erase hour and minute hand positions every minute
      tft.drawLine(xpos, 120,omx,omy, TFT_BLACK);
      omx = mx ;
      omy = my ;
     
      tft.drawLine(xpos, 120,ohx,ohy, TFT_BLACK);
      ohx = hx ;
      ohy = hy ;
    }
    // Redraw new hand positions, hour and minute hands not erased here to avoid flicker
    tft.drawLine(xpos, 120, oscx , oscy, TFT_BLACK);
    oscx = scx;
    oscy = scy;
    
    tft.drawLine(xpos, 120, oscx,oscy, TFT_RED);
    tft.drawLine(xpos, 120, omx,omy, TFT_CYAN);
    tft.drawLine(xpos, 120, ohx,ohy,TFT_CYAN);
    tft.fillCircle(xpos, 120, 3, TFT_RED);
    tft.setCursor(xpos-30, 50);
    tft.setTextSize(2);
    tft.print("H-Ah");
 
  // Draw MINI clock face "SECOND"
  tft.drawCircle(xpos, 155, 20, TFT_YELLOW);
  tft.drawCircle(xpos, 155, 18, TFT_BLUE);
  tft.drawCircle(xpos, 155, 17, TFT_CYAN);
  tft.drawCircle(xpos, 155, 16, TFT_CYAN);
  tft.fillRect(xpos-10, 149,22,15,TFT_BLACK); //erase
  if(t.sec<10){tft.setCursor(xpos-10, 149); tft.setTextSize(2);
  tft.print('0'); tft.setCursor(xpos+2, 149);}
  else{
  tft.setCursor(xpos-10, 149);}
  tft.setTextSize(2);
  tft.print(t.sec);
  
  // Draw MINI clock face "Minutes"
  tft.drawCircle(xpos+35, 117, 20, TFT_YELLOW);
  tft.drawCircle(xpos+35, 117, 18, TFT_BLUE);
  tft.drawCircle(xpos+35, 117, 17, TFT_CYAN);
  tft.drawCircle(xpos+35, 117, 16, TFT_CYAN);
  tft.fillRect(xpos+25, 111,22,15,TFT_BLACK); //erase
  if(t.min<10){tft.setCursor(xpos+25, 111); tft.setTextSize(2);
  tft.print('0'); tft.setCursor(xpos+37, 111);}
  else{
  tft.setCursor(xpos+25, 111);}
  tft.println(t.min);
  
  // Draw MINI clock face "Hour"
  tft.drawCircle(xpos-35, 117, 20, TFT_YELLOW);
  tft.drawCircle(xpos-35, 117, 18, TFT_BLUE);
  tft.drawCircle(xpos-35, 117, 17, TFT_CYAN);
  tft.drawCircle(xpos-35, 117, 16, TFT_CYAN);
  tft.fillRect(xpos-45, 111,22,15,TFT_BLACK); //erase
  if(t.hour<10){tft.setCursor(xpos-45, 111); tft.setTextSize(2);
  tft.print('0'); tft.setCursor(xpos-33, 111);}
  else{
  tft.setCursor(xpos-45, 111);}
  tft.setTextSize(2);
  tft.print(t.hour);
  
  if (t.hour>=0 && t.hour<12) d='A'; else {d='P';}
  tft.drawRoundRect(xpos-14,72,29,21,5,TFT_CYAN);
  tft.fillRect(xpos-11, 75,23,15,TFT_BLACK); //erase
  tft.setCursor(xpos-11, 75);
  tft.setTextSize(2);
  tft.print(d);
  tft.println('M');
  prev = now;
  }
}

merci beaucoup tout le monde pour votre aide
bonne soiree a tous

Bonjour tout le monde
voila je me suis lance dans la conception d'une nouvelle analog Clock a base d'arduino + tft_lcd suivant ce tuto :https://www.instructables.com/Analog-Clock-Using-Math-Arduino-Pro-Mini-DS3231-an/
qui est base sur le nokia 5110 j'ai pu faire le gros du boulot que voici

/*
 ***********************************************************************************
 * RTC library :https://www.elecrow.com/wiki/index.php?title=Tiny_RTC              *
 * MCUFRIEND library & Adafruit_GFX library :arduino library manager               *
 *the code is made from this execellent tutorial :                                 *
 *https://www.instructables.com/Analog-Clock-Using-Math-Arduino-Pro-Mini-DS3231-an/*   
************************************************************************************
 */
#include "RTClib.h"
#include <Wire.h>         //Library for i2c, serial communication
#include <SPI.h>          // f.k. for Arduino-1.5.2
#include "Adafruit_GFX.h" // Hardware-specific library
#include <MCUFRIEND_kbv.h>// Hardware-specific library

RTC_DS1307 RTC;
MCUFRIEND_kbv tft;

// 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
extern uint8_t SmallFont[];

// 320/2 x 240/2 work surface 
float clockCenterX = 160; 
float clockCenterY = 120; 

//
unsigned long previousTime=0;
unsigned long interval = 1000;
bool state=HIGH;


void setup()
          {
          Wire.begin();
          RTC.begin();
          Serial.begin(9600);
          Wire.begin();
          uint16_t ID = tft.readID();
          tft.begin(ID); 
          delay(1000);
          tft.setRotation(3);
          tft.fillScreen(BLACK);

}
void loop(){
drawMinutes();
drawHours();
drawDisplay();

  
  }
void drawMinutes(){
                   DateTime now = RTC.now();
                   unsigned long currentTime = millis ();
                   float x1, y1, x2, y2, x3, y3, x4, y4,Am,As;
                   Am =(now.minute() * 6); //angle = mins  * 360 / 60
                  As = (now.second());      //angle = secs * 360 / 60
                  Serial.print (now.second());
 

  x1=100*sin(Am*0.0175);    //Sin(angle_rad) .r * Converts an angle in to radians
  y1=100*-cos(Am*0.0175);  // 
  x2=12*sin(Am*0.0175);
  y2=12*-cos(Am*0.0175);
  x3=40*sin((Am+8)*0.0175);
  y3=40*-cos((Am+8)*0.0175);
  x4=40*sin((Am-8)*0.0175);
  y4=40*-cos((Am-8)*0.0175);
  tft.drawLine(x1+clockCenterX, y1+clockCenterY, x3+clockCenterX, y3+clockCenterY,TFT_CYAN);
  tft.drawLine(x3+clockCenterX, y3+clockCenterY, x2+clockCenterX, y2+clockCenterY,TFT_CYAN);
  tft.drawLine(x2+clockCenterX, y2+clockCenterY, x4+clockCenterX, y4+clockCenterY,TFT_CYAN);
  tft.drawLine(x4+clockCenterX, y4+clockCenterY, x1+clockCenterX, y1+clockCenterY,TFT_CYAN);
  tft.drawCircle(clockCenterX, clockCenterY,5,TFT_CYAN);
  if (As==0 ){
  
 tft.fillScreen(TFT_BLACK);
    } 



}
void drawHours(){
                  float x1, y1, x2, y2, x3, y3, x4, y4, Ah;             
                 DateTime now = RTC.now();;
                 Ah= (now.hour() * 30) + (now.minute() * 0.5);  //angle = hours * 360 / 12 or angle               
  
  x1=80*sin(Ah*0.0175);
  y1=80*-cos(Ah*0.0175);
  x2=12*sin(Ah*0.0175);
  y2=12*-cos(Ah*0.0175);
  x3=32*sin((Ah+14)*0.0175);
  y3=32*-cos((Ah+14)*0.0175);
  x4=32*sin((Ah-14)*0.0175);
  y4=32*-cos((Ah-14)*0.0175);

  tft.drawLine(x1+clockCenterX, y1+clockCenterY, x3+clockCenterX, y3+clockCenterY,TFT_CYAN);
  tft.drawLine(x3+clockCenterX, y3+clockCenterY, x2+clockCenterX, y2+clockCenterY,TFT_CYAN);
  tft.drawLine(x2+clockCenterX, y2+clockCenterY, x4+clockCenterX, y4+clockCenterY,TFT_CYAN);
  tft.drawLine(x4+clockCenterX, y4+clockCenterY, x1+clockCenterX, y1+clockCenterY,TFT_CYAN);
  
  
  }


void  drawDisplay(){
  for (int i=0; i<12; i++)    //  small mark for every hour
  {
  float x1, y1, x2, y2, Ah;
  Ah = i * 30;                //  360/12
  x1=120*sin(Ah*0.0175);
  y1=120*-cos(Ah*0.0175);
  x2=104*sin(Ah*0.0175);
  y2=104*-cos(Ah*0.0175);
 tft.drawLine(x1+clockCenterX, y1+clockCenterY, x2+clockCenterX, y2+clockCenterY,TFT_YELLOW);
 
  }
  
  }

helas je bute sur un problème de rafraîchissement des aiguilles ... lorsque par exemple l'aiguille minute passe de la première a la deuxième minute l'aiguille se dédouble a la troisieme elle devient triple et ainssi de suite , idem pour l'heure , actuellement pour remedier a ce probleme j'utilise cette commande " tft.fillScreen(TFT_BLACK);"
a chaque passage des seconde a As= 0 ça marche certes mais avec une saute de "l'image" a chaque fois
y 'a t'il possibilite d'y remédier ? comment?
comme toujour merci beaucoup

Bonjour,

c'est facile, tu redessines l'aiguille dont tu n'as plus besoin avec la couleur du fond puis tu dessines l'aiguille suivante avec la "couleur" normale.

Merci beaucoup

j'ai deja tente cette solution a savoir remplacer " tft.fillScreen(TFT_BLACK);" par
x1=80sin(Ah0.0175);
y1=80*-cos(Ah0.0175);
x2=12
sin(Ah0.0175);
y2=12
-cos(Ah0.0175);
x3=32
sin((Ah+14)0.0175);
y3=32
-cos((Ah+14)0.0175);
x4=32
sin((Ah-14)0.0175);
y4=32
-cos((Ah-14)*0.0175);

tft.drawLine(x1+clockCenterX, y1+clockCenterY, x3+clockCenterX, y3+clockCenterY,TFT_BLACK);
tft.drawLine(x3+clockCenterX, y3+clockCenterY, x2+clockCenterX, y2+clockCenterY,TFT_BLACK);
tft.drawLine(x2+clockCenterX, y2+clockCenterY, x4+clockCenterX, y4+clockCenterY,TFT_BLACK);
tft.drawLine(x4+clockCenterX, y4+clockCenterY, x1+clockCenterX, y1+clockCenterY,TFT_BLACK);

ou simplment par

tft.drawLine(x1+clockCenterX, y1+clockCenterY, x3+clockCenterX, y3+clockCenterY,TFT_BLACK);
tft.drawLine(x3+clockCenterX, y3+clockCenterY, x2+clockCenterX, y2+clockCenterY,TFT_BLACK);
tft.drawLine(x2+clockCenterX, y2+clockCenterY, x4+clockCenterX, y4+clockCenterY,TFT_BLACK);
tft.drawLine(x4+clockCenterX, y4+clockCenterY, x1+clockCenterX, y1+clockCenterY,TFT_BLACK);
}
mais rien a faire helas

Je me suis peut-etre mal exprime.
Tu as un fond uniforme blanc.
Tu dessines une ligne noire.
Tu veux deplacer cette ligne.
Tu redessines cette ligne en blanc.
Tu as alors un fond uniforme blanc.
Tu dessines ta nouvelle ligne en noir.
Cqfd

Jacques

Merci beaucoup Jacques je vais tester cette astuce
nb : je suis un debutant