/********************************************************************* Programme de gestion d'un ecran monochrome OLEDs sur une base SSD1306 drivers pour l'affichage de la gare d'Aurillac. Ce programme utilise une version personnalisee de la bibliotheque adafruit_SSD1306, adaptee pour des ecrans 128x64 Cette bibliothque est renommee SSD1306 La modification est la suivante : 1) Changement du nom de la bibliotheque pour utilisation sans modification par le sketch "Affichage_Gare_Aurillac" 2) #define SSD1306_128_64 Adaptation jpb 01/2021 1 seul écran DEP/ARR mais avec boucle info en + Lecture horloge temps réel et commutation relais J/N *********************************************************************/ // Ce qui suit sert a initialiser le compilateur et qui defini les applications a utiliser #include #include #include #include #include #include #include "RTClib.h" #define OLED_RESET 4 RTC_DS3231 rtc; // LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display // creation de deux afficheurs SSD1306 display1(OLED_RESET); //SSD1306 display2(OLED_RESET); char daysOfTheWeek[7][10] = { "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" }; // pour le calcul de l'heure au 1/87ème unsigned long timer; int minute=0; boolean NUIT=false; unsigned int H87, M87; const byte Broche = 13; // défini sur quelle broche va être le relai J/N // verification que nous sommes bien configure en 128X64 #if (SSD1306_LCDHEIGHT != 64) #error("Height incorrect, please fix Adafruit_SSD1306.h!"); #endif const int MaxLigne=12; /* 34 init défini le nb de lignes */ const int MaxInfo=11; const char info_0[]PROGMEM= " ** INFORMATIONS ** "; const char info_1[]PROGMEM= " TRAVAUX "; const char info_2[]PROGMEM= " "; const char info_3[]PROGMEM= "TRAM du 16/3 au 16/4 "; const char info_4[]PROGMEM= "travaux sur les quais"; const char info_5[]PROGMEM= "en gare de Moulins. "; const char info_6[]PROGMEM= " "; const char info_7[]PROGMEM= " Attention a la "; const char info_8[]PROGMEM= " circulation des "; const char info_9[]PROGMEM= " trains et a la "; const char info_10[]PROGMEM= " sortie de la gare. "; const char info_11[]PROGMEM= " "; const char info_12[]PROGMEM= " Attention a la "; const char info_13[]PROGMEM= " circulation des "; const char info_14[]PROGMEM= " trains et a la "; const char info_15[]PROGMEM= " sortie de la gare. "; // Initialisation de la table info même remarque const char*const info_table[]PROGMEM={info_0,info_1,info_2,info_3,info_4,info_5,info_6,info_7,info_8,info_9,info_10}; // generation des tables de variables (c'est ici que vous devrez modifier vos ecrans // tables des departs const char depart_0[]PROGMEM= "HEURE DEPART V---------------------O6h15 MOULINS 1"; const char depart_1[]PROGMEM= "HEURE DEPART V---------------------O6h15 MOULINS 107h17 GIVORS 2"; const char depart_2[]PROGMEM= "HEURE DEPART V---------------------O6h15 MOULINS 1O7h17 GIVORS 212h12 MONTCHANIN 1"; const char depart_3[]PROGMEM= "HEURE DEPART V---------------------O6h15 MOULINS 1O7h17 GIVORS 212h12 MONTCHANIN 116h02 ROANNE 2"; const char depart_4[]PROGMEM= "HEURE DEPART V---------------------O6h15 MOULINS 1O7h17 GIVORS 212h12 MONTCHANIN 116h02 ROANNE 219h01 CHAROLLES 1"; const char depart_5[]PROGMEM= "HEURE DEPART V---------------------O6h15 MOULINS 1O7h17 GIVORS 212h12 MONTCHANIN 116h02 ROANNE 219h01 CHAROLLES 119h30 MOULINS 2"; const char depart_6[]PROGMEM= "HEURE ARRIVEE V---------------------O7h55 DIJON 2"; const char depart_7[]PROGMEM= "HEURE ARRIVEE V---------------------O7h55 DIJON 2O8h46 MOULINS 1"; const char depart_8[]PROGMEM= "HEURE ARRIVEE V---------------------O7h55 DIJON 2O8h46 MOULINS 1O9h13 CHAROLLES 2"; const char depart_9[]PROGMEM= "HEURE ARRIVEE V---------------------O7h55 DIJON 2O8h46 MOULINS 1O9h13 CHAROLLES 213h07 GIVORS 2"; const char depart_10[]PROGMEM= "HEURE ARRIVEE V---------------------O7h55 DIJON 2O8h46 MOULINS 1O9h13 CHAROLLES 213h07 GIVORS 214h19 MONTCHANIN 1"; const char depart_11[]PROGMEM= "HEURE ARRIVEE V---------------------O7h55 DIJON 2O8h46 MOULINS 1O9h13 CHAROLLES 213h07 GIVORS 214h19 MONTCHANIN 119h22 MOULINS 2"; /* const char depart_12[]PROGMEM= "HEURE DEPART V---------------------1Oh27 CLERMONT FD 2"; const char depart_13[]PROGMEM= "HEURE DEPART V---------------------1Oh27 CLERMONT FD 21Oh49 DIJON 3"; const char depart_14[]PROGMEM= "HEURE DEPART V---------------------1Oh27 CLERMONT FD 21Oh49 DIJON 311h22 PARIS BERCY 4"; const char depart_15[]PROGMEM= "HEURE DEPART V---------------------1Oh27 CLERMONT FD 21Oh49 DIJON 311h22 PARIS BERCY 512h55 LYON PERRACH 1"; const char depart_16[]PROGMEM= "HEURE DEPART V---------------------1Oh27 CLERMONT FD 21Oh49 DIJON 311h22 PARIS BERCY 512h55 LYON PERRACH 113h28 NEVERS 3"; const char depart_17[]PROGMEM= "HEURE DEPART V---------------------1Oh27 CLERMONT FD 21Oh49 DIJON 311h22 PARIS BERCY 512h55 LYON PERRACH 113h28 NEVERS 316h39 CLERMONT FD 2"; const char depart_18[]PROGMEM= "HEURE DEPART V---------------------12h55 LYON PERRACH 1"; const char depart_19[]PROGMEM= "HEURE DEPART V---------------------12h55 LYON PERRACH 113h28 NEVERS 3"; const char depart_20[]PROGMEM= "HEURE DEPART V---------------------12h55 LYON PERRACH 113h28 NEVERS 316h39 CLERMONT FD 2"; const char depart_21[]PROGMEM= "HEURE DEPART V---------------------12h55 LYON PERRACH 113h28 NEVERS 316h39 CLERMONT FD 216h53 LYON PERRACH 1"; const char depart_22[]PROGMEM= "HEURE DEPART V---------------------12h55 LYON PERRACH 113h28 NEVERS 316h39 CLERMONT FD 216h53 LYON PERRACH 117h1O DIJON 3"; const char depart_23[]PROGMEM= "HEURE DEPART V---------------------12h55 LYON PERRACH 113h28 NEVERS 316h39 CLERMONT FD 216h53 LYON PERRACH 117h1O DIJON 317h44 CLERMONT FD 2"; const char depart_24[]PROGMEM= "HEURE DEPART V---------------------16h53 LYON PERRACH 1"; const char depart_25[]PROGMEM= "HEURE DEPART V---------------------16h53 LYON PERRACH 117h1O DIJON 3"; const char depart_26[]PROGMEM= "HEURE DEPART V---------------------16h53 LYON PERRACH 117h1O DIJON 317h44 CLERMONT FD 2"; const char depart_27[]PROGMEM= "HEURE DEPART V---------------------16h53 LYON PERRACH 117h1O DIJON 317h44 CLERMONT FD 218h32 NANTES 3"; const char depart_28[]PROGMEM= "HEURE DEPART V---------------------16h53 LYON PERRACH 117h1O DIJON 317h44 CLERMONT FD 218h32 NANTES 319h18 NEVERS 2"; const char depart_29[]PROGMEM= "HEURE DEPART V---------------------16h53 LYON PERRACH 117h1O DIJON 317h44 CLERMONT FD 218h32 NANTES 319h18 NEVERS 221h17 NANTES 3"; const char depart_30[]PROGMEM= "HEURE DEPART V---------------------18h32 NANTES 3"; const char depart_31[]PROGMEM= "HEURE DEPART V---------------------18h32 NANTES 319h18 NEVERS 2"; const char depart_32[]PROGMEM= "HEURE DEPART V---------------------18h32 NANTES 319h18 NEVERS 221h17 NANTES 3"; const char depart_33[]PROGMEM= "HEURE DEPART V---------------------18h32 NANTES 319h18 NEVERS 221h17 NANTES 321h46 DIJON 1"; */ // Initialisation de la table (attention il doit y avoir le meme nombre de depart que dans les lignes au-dessus en faisant bien attention a la syntaxe) const char*const depart_table[]PROGMEM={depart_0,depart_1,depart_2,depart_3,depart_4,depart_5,depart_6,depart_7,depart_8,depart_9,depart_10,depart_11/*,depart_12\ ,depart_13,depart_14,depart_15,depart_16,depart_17,depart_18,depart_19,depart_20,depart_21,depart_22,depart_23,depart_24,depart_25,depart_26,depart_27,depart_28\ ,depart_29,depart_30,depart_31,depart_32,depart_33*/}; // table des arrivees const char arrivee_0[]PROGMEM= "HEURE ARRIVEE V---------------------O5h45 LYON PERRACH 2"; const char arrivee_1[]PROGMEM= "HEURE ARRIVEE V---------------------O5h45 LYON PERRACH 2O6h15 PARIS BERCY 4"; const char arrivee_2[]PROGMEM= "HEURE ARRIVEE V---------------------O5h45 LYON PERRACH 2O6h15 PARIS BERCY 5O6h45 DIJON 3"; const char arrivee_3[]PROGMEM= "HEURE ARRIVEE V---------------------O5h45 LYON PERRACH 2O6h15 PARIS BERCY 5O6h45 DIJON 3O7h26 PARAY 2"; const char arrivee_4[]PROGMEM= "HEURE ARRIVEE V---------------------O5h45 LYON PERRACH 2O6h15 PARIS BERCY 5O6h45 DIJON 3O7h26 PARAY 2O8h23 CLERMONT FD 1"; const char arrivee_5[]PROGMEM= "HEURE ARRIVEE V---------------------O5h45 LYON PERRACH 2O6h15 PARIS BERCY 5O6h45 DIJON 3O7h26 PARAY 2O8h23 CLERMONT FD 1O9h47 NANTES 3"; /* const char arrivee_6[]PROGMEM= "HEURE ARRIVEE V---------------------O7h26 PARAY 2"; const char arrivee_7[]PROGMEM= "HEURE ARRIVEE V---------------------O7h26 PARAY 2O8h23 CLERMONT FD 1"; const char arrivee_8[]PROGMEM= "HEURE ARRIVEE V---------------------O7h26 PARAY 2O8h23 CLERMONT FD 1O9h47 NANTES 3"; const char arrivee_9[]PROGMEM= "HEURE ARRIVEE V---------------------O7h26 PARAY 2O8h23 CLERMONT FD 1O9h47 NANTES 31Oh32 NEVERS 2"; const char arrivee_10[]PROGMEM= "HEURE ARRIVEE V---------------------O7h26 PARAY 2O8h23 CLERMONT FD 1O9h47 NANTES 31Oh32 NEVERS 21Oh45 DIJON 3"; const char arrivee_11[]PROGMEM= "HEURE ARRIVEE V---------------------O7h26 PARAY 2O8h23 CLERMONT FD 1O9h47 NANTES 31Oh32 NEVERS 21Oh45 DIJON 311h55 CLERMONT FD 1"; const char arrivee_12[]PROGMEM= "HEURE ARRIVEE V---------------------1Oh32 BRIOUDE 2"; const char arrivee_13[]PROGMEM= "HEURE ARRIVEE V---------------------1Oh32 BRIOUDE 21Oh45 DIJON 3"; const char arrivee_14[]PROGMEM= "HEURE ARRIVEE V---------------------1Oh32 BRIOUDE 21Oh45 DIJON 311h55 CLERMONT FER 1"; const char arrivee_15[]PROGMEM= "HEURE ARRIVEE V---------------------1Oh32 BRIOUDE 21Oh45 DIJON 311h55 CLERMONT FER 112h29 LYON PERRACH 2"; const char arrivee_16[]PROGMEM= "HEURE ARRIVEE V---------------------1Oh32 BRIOUDE 21Oh45 DIJON 311h55 CLERMONT FER 112h29 LYON PERRACH 214hO6 DIJON 3"; const char arrivee_17[]PROGMEM= "HEURE ARRIVEE V---------------------1Oh32 BRIOUDE 21Oh45 DIJON 311h55 CLERMONT FER 112h29 LYON PERRACH 214hO6 DIJON 315h28 NEVERS 2"; const char arrivee_18[]PROGMEM= "HEURE ARRIVEE V---------------------12h29 LYON PERRACH 2"; const char arrivee_19[]PROGMEM= "HEURE ARRIVEE V---------------------12h29 LYON PERRACH 214hO6 BRIVE 3"; const char arrivee_20[]PROGMEM= "HEURE ARRIVEE V---------------------12h29 LYON PERRACH 214hO6 BRIVE 315h28 BRIOUDE 2"; const char arrivee_21[]PROGMEM= "HEURE ARRIVEE V---------------------12h29 LYON PERRACH 214hO6 BRIVE 315h28 BRIOUDE 215h33 DIJON 3"; const char arrivee_22[]PROGMEM= "HEURE ARRIVEE V---------------------12h29 LYON PERRACH 214hO6 BRIVE 315h28 BRIOUDE 215h33 DIJON 316h32 LYON PERRACH 2"; const char arrivee_23[]PROGMEM= "HEURE ARRIVEE V---------------------12h29 LYON PERRACH 214hO6 BRIVE 315h28 BRIOUDE 215h33 DIJON 316h32 LYON PERRACH 217hO7 NEVERS 1"; const char arrivee_24[]PROGMEM= "HEURE ARRIVEE V---------------------15h33 DIJON 3"; const char arrivee_25[]PROGMEM= "HEURE ARRIVEE V---------------------15h33 DIJON 316h32 LYON PERRACH 2"; const char arrivee_26[]PROGMEM= "HEURE ARRIVEE V---------------------15h33 DIJON 316h32 LYON PERRACH 217hO7 NEVERS 1"; const char arrivee_27[]PROGMEM= "HEURE ARRIVEE V---------------------15h33 DIJON 316h32 LYON PERRACH 217hO7 NEVERS 118h32 NANTES 3"; const char arrivee_28[]PROGMEM= "HEURE ARRIVEE V---------------------15h33 DIJON 316h32 LYON PERRACH 217hO7 NEVERS 118h32 NANTES 319hO8 CLERMONT FD 2"; const char arrivee_29[]PROGMEM= "HEURE ARRIVEE V---------------------15h33 DIJON 316h32 LYON PERRACH 217hO7 NEVERS 118h32 NANTES 319hO8 CLERMONT FD 22OhO1 DIJON 3"; const char arrivee_30[]PROGMEM= "HEURE ARRIVEE V---------------------19hO8 CLERMONT FD 2"; const char arrivee_31[]PROGMEM= "HEURE ARRIVEE V---------------------19hO8 CLERMONT FD 22OhO1 DIJON 3"; const char arrivee_32[]PROGMEM= "HEURE ARRIVEE V---------------------19hO8 CLERMONT FD 22OhO1 DIJON 321h17 NANTES 3"; const char arrivee_33[]PROGMEM= "HEURE ARRIVEE V---------------------19hO8 CLERMONT FD 22OhO1 DIJON 321h17 NANTES 321h4O LYON PERRACH 1"; */ // Initialisation de la table (attention il doit y avoir le meme nombre d'arrivees que dans les lignes au-dessus en faisant bien attention a la syntaxe) const char*const arrivee_table[]PROGMEM={arrivee_0,arrivee_1,arrivee_2,arrivee_3,arrivee_4,arrivee_5/*,arrivee_6,arrivee_7,arrivee_8,arrivee_9,arrivee_10,arrivee_11,arrivee_12\ ,arrivee_13,arrivee_14,arrivee_15,arrivee_16,arrivee_17,arrivee_18,arrivee_19,arrivee_20,arrivee_21,arrivee_22,arrivee_23,arrivee_24,arrivee_25,arrivee_26,arrivee_27,arrivee_28\ ,arrivee_29,arrivee_30,arrivee_31,arrivee_32,arrivee_33*/}; const char msg_0[]PROGMEM="Bienvenue en gare de"; const char msg_1[]PROGMEM="Bonne et heureuse"; const char msg_2[]PROGMEM=" annee 2021"; const char msg_3[]PROGMEM="(c) pouble 2021"; const char msg_4[]PROGMEM="Nous sommes le "; const char msg_5[]PROGMEM=" PARAY "; const char*const msgdetail[]PROGMEM={msg_0, msg_1, msg_2, msg_3, msg_4, msg_5}; //Definition du buffer char buffer[100]; //Creation d'un sous-programme d'initialisation des afficheurs void initaffichage() { // Initialisation de l'afficheur 1 // Vider le buffer. display1.clearDisplay(); // choix de la taille display1.setTextSize(1); // choix de la couleur display1.setTextColor(WHITE); // initialisation du debut d'affichage display1.setCursor(0,0); } //fin du sous-programme d'initialisation des afficheurs void bienvenues() { initaffichage(); display1.println(""); // "=====================" pour alignement des caractères strcpy_P(buffer,(char*)pgm_read_word(&(msgdetail[0]))); display1.println(buffer); //"Bienvenue en gare de"); display1.println(""); display1.setTextSize(2); strcpy_P(buffer,(char*)pgm_read_word(&(msgdetail[5]))); display1.println(buffer); //" PARAY "); display1.display(); delay(3000); display1.setTextSize(1); display1.println(""); // insertion du case pour faire des variations en fonction du mois ou trimestre strcpy_P(buffer,(char*)pgm_read_word(&(msgdetail[1]))); display1.println(buffer); strcpy_P(buffer,(char*)pgm_read_word(&(msgdetail[2]))); display1.println(buffer); /* display1.println("Bonne et heureuse" ); display1.println(" annee 2021"); */ display1.display(); delay(4000); } void copyright() { display1.clearDisplay(); display1.setCursor(20,20); strcpy_P(buffer,(char*)pgm_read_word(&(msgdetail[3]))); display1.println(buffer); // display1.println("(c) pouble 2021"); display1.display(); Heure87aff(); delay(2000); } void Heure(int H, int M) { display1.print(" il est "); if (H < 10) { display1.print("0"); display1.print(H); } else { display1.print(H, DEC); } display1.print(':'); if (M < 10) { display1.print("0"); display1.print(M); } else { display1.print(M, DEC); } display1.println(""); display1.display(); delay(1000); } void DateHeure() { DateTime now = rtc.now(); display1.clearDisplay(); display1.setCursor(0, 2); strcpy_P(buffer,(char*)pgm_read_word(&(msgdetail[4]))); display1.println(buffer); // display1.println("Nous sommes le "); display1.println(""); //Day of the week display1.print(daysOfTheWeek[now.dayOfTheWeek()]); display1.print(" "); if (now.day() < 10) { display1.print("0"); display1.print(now.day()); } else display1.print(now.day(), DEC); display1.print("/"); if (now.month() < 10) { display1.print("0"); display1.print(now.month()); } else { display1.print(now.month(), DEC); } display1.print('/'); display1.println(now.year(), DEC); //display1.println(""); Heure(now.hour(), now.minute()); display1.display(); delay(1500); //Temperature: display1.println(""); display1.println(""); //La temperature est "); display1.print("Il fait : "); display1.print(rtc.getTemperature()); display1.println(" C"); display1.display(); delay(4000); } void setup() { // initialisation de la vitesse de la liaison serie Serial.begin(9600); timer=millis(); // par defaut nous allons generer une tension de 3.3v // initialisation de la liaison ID2C avec l'adresse 0x3D display1.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialisation de la liaison ID2C avec l'adresse 0x3C /* display2.begin(SSD1306_SWITCHCAPVCC, 0x3D); */ // fin de l'initialisation rtc.begin(); // rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // si connecté à un ordi, raz de la date DateTime now = rtc.now(); H87=now.hour(); M87=now.minute(); pinMode (Broche, OUTPUT) ; digitalWrite (Broche, LOW) ; // mode jour activé delay(2000); } void heure87(long temps) { if (temps-timer>=666) { for(int i=0;i= 60) { H87++; M87=M87-60; if (H87 == 24){ H87=0; } } /* Serial.print(H87); Serial.print(" - "); Serial.println(M87); */ if (minute>=1440) { // Remet à 0 après 24h*60=1440, soit une journée complète. minute=0; } } } void Heure87Relai() { int TestSoir=20; if ((H87 >= 20 || H87 <= 6)) { if (NUIT==false) { //Serial.println("Passage horaire nuit"); digitalWrite (Broche, HIGH) ; NUIT=true; } } else { if (NUIT==true) { //Serial.println("Passage horaire jour"); digitalWrite (Broche, LOW) ; NUIT=false; } } } void Heure87aff() { display1.setCursor(10,40); display1.print(">87eme : "); /* int x=minute/60*100; //globale // On divise par 60 pour avoir le nombre d'heure display1.print(x/100); display1.print("h "); int y=minute%60; display1.print(y); display1.println("mns"); */ display1.print(H87, DEC); display1.print("h "); display1.print(M87, DEC); display1.println("mns"); display1.display(); // maintenant commutation relais J/N Heure87Relai(); delay(2000); } void loop() { unsigned long temps=millis(); heure87(temps); Heure87Relai(); int tempo; //creation d'une variable tempo // creation d'une boucle for // heure87(); bienvenues(); DateHeure(); for(int i=0;i