Merci pour ta réponse,
Oui, j'avais oublié une partie des variables...
#include <Wire.h>
#include <Adafruit_BME280.h>
#include <RTClib.h>
//#include <DFRobot_AS3935_I2C.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "Icone.h"
#include <Accents.h>
#include <RunningAverage.h>
#include <temperature.h>
#define BUTTON_PIN 2
bool page1 = 0;
bool play1 = 0;
unsigned long tpage;
float pdr;
float hmd;
float ht;
float wc1;
float wc2;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Variables globales
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool Start = 1;
unsigned long delayTime = 6000; // refresh rate for the readings
unsigned long Time;
unsigned long lastTime;
int tendance = 45;
String directionVent = "S/SO";
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// variables et fonctions RunningAverage
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
RunningAverage RATI(10);
RunningAverage RAHI(10);
RunningAverage RATE(10);
RunningAverage RAHE(10);
int samples = 0;
float tempIntAvg = 0;
float tempExtAvg = 0;
int tempIntTend = 45;
int tempExtTend = 45;
float humIntAvg = 0;
float humExtAvg = 0;
int humIntTend = 45;
int humExtTend = 45;
int ventTend = 17;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// sentencecutter
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const size_t pageWidth = 20; // number of characters
const size_t maxWords = 100; // number of characters
char* wordPointers[maxWords];
char ligne1[50];
char ligne2[50];
size_t wordCount(char* buffer, const char* separators = " ")
{
size_t count = 0;
char* ptr = strtok(buffer, separators);
while (ptr) {
if (count < maxWords) wordPointers[count] = ptr;
count++;
ptr = strtok(NULL, separators);
}
return count;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DS1307
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = {"Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"};
char monthsOfTheYear[13][13] = {"___", "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Décembre"};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OLED SSD1306
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BME280 et forecast
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // initialise the BME280 sensor
int seapressure;
int pressureArray[10] = {0}; // here we store the pressure readings
byte counter = 0;
byte delta_time = 0;
int Z = 0;
int boot = 1;
int ZT = 0;
int lastZT = -1;
int indice = 45;
int icone;
bool night = 0;
char tStr[21];
char pStr[22];
char hStr[20];
char pseaStr[26];
char timeStr[6];
char dateStr[12];
char zambretti[10] = "N/A";
char pressureHistory[57];
float tempInt;
float tempExt;
float humInt;
float humExt;
int pressure;
int altitude = 641; // Ici, on met l'altitude RÉELLE
const char *weather[] = {"Acquisition des données ...", "Beau temps installé", "Beau temps", "Amélioration de la météo", "Beau temps, deviens changeant", "Beau temps, Possibilité d'averses",
"Assez bon, en amélioration", "Assez bon, averses précoces possibles", "Assez bon, averses plus tard", "Pluie précoce, amélioration",
"Changeant s'améliore", "Assez bon, averses probables", "Plutôt variable, éclaircies plus tard", "Instable, sûrement en amélioration",
"Pluie avec éclaircissement", "Pluvieux, devient instable", "Variable avec peu d'averses", "Instable, avec intervalles de beau",
"Instable, averses plus tard", "Instable, averses occasionnelles", "Très Instable, parfois plus beau", "Averses, plus mauvais plus tard",
"Averses, devient très instable", "Averses à intervalles fréquents", "Très instable, Pluie", "Orageux, possible amélioration",
"Orageux, beaucoup de pluie"
};
//acquisition_bmp, soleil_bmp, lune1_bmp, lune2_bmp, soleilnuage_bmp, lunenuage_bmp, soleilnuagepluie_bmp, lunenuagepluie_bmp, nuage1_bmp, nuage2_bmp, nuagepluie_bmp;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AS3935
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*volatile int8_t AS3935IsrTrig = 0;
#if defined(ESP32) || defined(ESP8266)
#define IRQ_PIN 0
#else
#define IRQ_PIN 2
#endif
#define AS3935_CAPACITANCE 96 // Antenna tuning capcitance (must be integer multiple of 8, 8 - 120 pf)
// I2C address
#define AS3935_I2C_ADDR AS3935_ADD1
//AS3935_ADD1 0x01 ///< A0=high, A1=low
//AS3935_ADD3 0x03 ///< A0=high, A1=high
//AS3935_ADD2 0x02 ///< A0=low, A1=high
void AS3935_ISR();
DFRobot_AS3935_I2C lightning0((uint8_t)IRQ_PIN);
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SETUP
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(115200); // default settings
// initialize the pushbutton pin as an input:
pinMode(BUTTON_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), interrupt, FALLING);
// explicitly start clean
RATI.clear();
RAHI.clear();
RATE.clear();
RAHE.clear();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SETUP RTC 1307
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
while (1) delay(10);
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SETUP OLED SSD1306
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
}
// Clear the buffer
display.clearDisplay();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SETUP AS3935
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* lightning0.setI2CAddress(AS3935_ADD1);
while (lightning0.begin() != 0) {
Serial.print(".");
}
lightning0.defInit();
// Configure sensor
lightning0.powerUp();
//set indoors or outdoors models
lightning0.setIndoors();
//lightning0.setOutdoors();
//disturber detection
lightning0.disturberEn();
//lightning0.disturberDis();
lightning0.setIRQOutputSource(0);
delay(500);
//set capacitance
lightning0.setTuningCaps(AS3935_CAPACITANCE);
Serial.println("AS3935 manual cal complete");
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SETUP BME280
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool status;
status = bme.begin(0x76, &Wire);
if (!status) {
while (1);
}
bme.setSampling(Adafruit_BME280::MODE_FORCED,
Adafruit_BME280::SAMPLING_X1, // temperature
Adafruit_BME280::SAMPLING_X1, // pression
Adafruit_BME280::SAMPLING_X1, // humidite
Adafruit_BME280::FILTER_OFF );
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// LOOP
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
Time = millis();
//AS3935();
if ((Time > lastTime + delayTime || Start == 1) && page1 == 0) {
Data();
forecast();
average();
sentencecutter();
accueil();
lastTime = Time;
Start = 0;
}
if (page1 == 1) {
pageinfo();
}
if (Time >= tpage + 10000) {
page1 = 0;
play1 = 0;
accueil();
}
}
void Data() {
bme.takeForcedMeasurement();
tempInt = (float)bme.readTemperature();
humInt = (int)bme.readHumidity();
pressure = (int)(bme.readPressure() / 100.0F);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Average
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//calcul de la moyenne glissante de la temperature et de l'humidité
void average() {
Serial.println("Average température et humidité:");
samples++;
RATI.addValue(tempInt);
RAHI.addValue(humInt);
RATE.addValue(tempExt);
RAHE.addValue(humExt);
// print a header every 10 lines
if (samples >= 10) {
Serial.println(" ");
Serial.print("Tendance température: ");
tempIntAvg = RATI.getAverage();
humIntAvg = RAHI.getAverage();
tempExtAvg = RATE.getAverage();
humExtAvg = RAHE.getAverage();
//Intérieur
if (tempIntAvg >= (tempInt + 0.3)) { //0.3°c de difference
Serial.println("En baisse");
tempIntTend = 31; //baisse
}
else if (tempIntAvg <= (tempInt - 0.3)) { //caracteres speciaux:
Serial.println("En hausse"); // fleche vers le haut 30
tempIntTend = 30; //hausse fleche vers le bas 31
} // fleche vers la droite 16
else { // fleche vers la gauche 17
Serial.println("Stable");
tempIntTend = 16; //stable
}
Serial.print("Tendance humidité: ");
if (humIntAvg >= (humInt + 0.8)) { //0.8% de difference
Serial.println("En baisse");
humIntTend = 31; //baisse
}
else if (humIntAvg <= (humInt - 0.8)) {
Serial.println("En hausse");
humIntTend = 30; //hausse
}
else {
Serial.println("Stable");
humIntTend = 16; //stable
}
//Extérieur
if (tempExtAvg >= (tempExt + 0.6)) { //0.6°c de difference
Serial.println("En baisse");
tempExtTend = 31; //baisse
}
else if (tempExtAvg <= (tempExt - 0.6)) {
Serial.println("En hausse");
tempExtTend = 30; //hausse
}
else {
Serial.println("Stable");
tempExtTend = 16; //stable
}
Serial.print("Tendance humidité: ");
if (humExtAvg >= (humExt + 1)) { //1% de difference
Serial.println("En baisse");
humExtTend = 31; //baisse
}
else if (humExtAvg <= (humExt - 0.8)) {
Serial.println("En hausse");
humExtTend = 30; //hausse
}
else {
Serial.println("Stable");
humExtTend = 16; //stable
}
samples = 0;
}
Serial.println("\nCNT\tTi.avg\tHi.avg\tTe.avg\tHe.avg");
Serial.print(samples);
Serial.print('\t');
Serial.print(RATI.getAverage(), 1);
Serial.print('\t');
Serial.print(RAHI.getAverage(), 1);
Serial.print('\t');
Serial.print(RATE.getAverage(), 1);
Serial.print('\t');
Serial.print(RAHE.getAverage(), 1);
Serial.println();
Serial.println("__________________________________________________________________________");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Accueil
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void accueil() {
int16_t x1;
int16_t y1;
uint16_t width;
uint16_t height;
DateTime now = rtc.now();
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
//affichage prévision
//Ligne 1
display.getTextBounds(ligne1, 0, 0, &x1, &y1, &width, &height);
display.setCursor((SCREEN_WIDTH - width) / 2, 0); //on centre la phrase sur la ligne
display.print(Accents.Transcoder_ASCII(ligne1)); //et on affiche les accents sur l'OLED
//Ligne 2
display.getTextBounds(ligne2, 0, 0, &x1, &y1, &width, &height);
display.setCursor((SCREEN_WIDTH - width) / 2, 7); //on centre la phrase sur la ligne
display.print(Accents.Transcoder_ASCII(ligne2)); //et on affiche les accents sur l'OLED
//affiche texte
display.setCursor(10, 16);
display.print("Int.");
display.drawLine(0, 24, 47, 24, SSD1306_WHITE); //trait
display.setCursor(94, 16);//82
display.print("Ext.");
display.drawLine(82, 24, 128, 24, SSD1306_WHITE); //trait
//affichage température intérieure
display.setCursor(0, 28);//92,9
display.print((char)tempIntTend ); //signe pour la tendance (flèche haut, bas, droite)
display.print(tempInt, 1);
display.print((char)247);
display.print("C ");
//affichage température extérieure
display.setCursor(88, 28);
display.print((char)tempExtTend ); //signe pour la tendance (flèche haut, bas, droite)
display.print(tempExt, 1);
display.print((char)247);
display.print("C ");
//affichage humidité intérieure
display.setCursor(0, 37);//0,9
display.print((char)humIntTend ); //signe pour la tendance (flèche haut, bas, droite)
display.print(humInt, 0);
display.print("% ");
//affichage humidité extérieure
display.setCursor(88, 37);
display.print((char)humExtTend ); //signe pour la tendance (flèche haut, bas, droite)
display.print(humExt, 0);
display.print("% ");
//affichage pression
display.setCursor(0, 46);//0,55
display.print((char)tendance); //signe pour la tendance (flèche haut, bas, droite)
display.print(seapressure);
display.print("hPa");
//direction du vent
display.setCursor(88, 46);
display.print((char)ventTend);
display.print(" ");
display.print(directionVent);
//affichage de la date
//display.setCursor(0, 57);
char Date[40];
sprintf(Date, "%s %d %s", daysOfTheWeek[now.dayOfTheWeek()], now.day(), monthsOfTheYear[now.month()]);
// affichage centré horizontalement de la date
display.getTextBounds(Date, 0, 0, &x1, &y1, &width, &height);
display.setCursor((SCREEN_WIDTH - width) / 2, 57);
display.print(Accents.Transcoder_ASCII(Date)); //on affiche les accents sur l'OLED
//affichage icone en fonction de l'algorihtme
switch (icone) {
case 0:
display.drawBitmap(47, 16, acquisition_bmp, 24, 24, WHITE);
break;
case 1:
display.drawBitmap(47, 16, soleil_bmp, 35, 35, WHITE);
break;
case 2:
display.drawBitmap(47, 16, lune1_bmp, 35, 35, WHITE);
break;
case 3:
display.drawBitmap(47, 16, lune2_bmp, 35, 35, WHITE);
break;
case 4:
display.drawBitmap(47, 16, soleilnuage_bmp, 35, 35, WHITE);
break;
case 5:
display.drawBitmap(47, 16, lunenuage_bmp, 35, 35, WHITE);
break;
case 6:
display.drawBitmap(47, 16, soleilnuagepluie_bmp, 35, 35, WHITE);
break;
case 7:
display.drawBitmap(47, 16, lunenuagepluie_bmp, 35, 35, WHITE);
break;
case 8:
display.drawBitmap(47, 16, nuage1_bmp, 35, 35, WHITE);
break;
case 9:
display.drawBitmap(47, 16, nuage2_bmp, 35, 35, WHITE);
break;
case 10:
display.drawBitmap(47, 16, nuagepluie_bmp, 35, 35, WHITE);
break;
}
//display.drawBitmap(47, 16, icone, 35, 35, WHITE); //(position horizontale, position verticale, image, hauteur image, largeur image, couleur pixel)
//affichage carrée autour icone
display.drawRoundRect(47, 16, 35, 35, 4, SSD1306_WHITE);
display.display(); // affichage à l'écran
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// forecast
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void forecast() {
DateTime now = rtc.now();
seapressure = station2sealevel(pressure, altitude, tempInt);
delta_time++;
if (delta_time > 1) { // toutes les minutes on incrémente delta_time, puis toutes les 10 minutes
delta_time = 0; //on stocke la valeur dans le tableau
if (counter == 10) // si on lit 10 valeurs et que le tableau est rempli, on décale le contenu
{
for (int i = 0; i < 9; i++) { // on décale le tableau d'une position vers la gauche
pressureArray[i] = pressureArray[i + 1];
}
pressureArray[counter - 1] = seapressure;
boot = 0;
}
else { // ce code remplit le tableau des valeurs de pression jusqu'à ce qu'il soit pleins
pressureArray[counter] = seapressure;
counter++;
}
}
Z = calc_zambretti((pressureArray[9] + pressureArray[8] + pressureArray[7]) / 3, (pressureArray[0] + pressureArray[1] + pressureArray[2]) / 3, now.month());
if (boot == 1) {
ZT = 0;
}
else {
ZT = Z;
}
// Debbug
sprintf(pressureHistory, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", pressureArray[0], pressureArray[1], pressureArray[2],
pressureArray[3], pressureArray[4], pressureArray[5], pressureArray[6], pressureArray[7], pressureArray[8], pressureArray[9]);
Serial.println("\nZT\tT\tH\tP\tP.mer\tDate/Heure");
Serial.print(ZT); //numeros prévision
Serial.print('\t');
Serial.print(tempInt, 1); //température
Serial.print('\t');
Serial.print(humInt, 1); //humidité
Serial.print('\t');
Serial.print(pressure); //pression au niveau de la mer
Serial.print('\t');
Serial.print(seapressure); //pression réelle
Serial.print('\t');
Serial.print(now.day()); //date
Serial.print("/");
Serial.print(now.month());
Serial.print("/");
Serial.print(now.year());
Serial.print(" ");
Serial.print(now.hour()); //heure
Serial.print(":");
Serial.println(now.minute());
Serial.println("");
Serial.print("Historique pression: ");
Serial.println(pressureHistory); //10 valeurs chaque 10mn
Serial.println("");
Serial.println("Prévision en texte");
/*Serial.print("Ligne 1: ");
Serial.println(ligne1); //prévision texte
Serial.print("Ligne 2: ");
Serial.println(ligne2);*/
Serial.println(weather[ZT]);
Serial.println("");
//pour passer les icone en mode nuit
if (now.hour() < 20 && now.hour() > 6) {
night = 0;
}
else {
night = 1;
}
Serial.println("Tendances et Prévisions: ");
if (pressureArray[9] > 0 and pressureArray[0] > 0) {
if (pressureArray[9] + pressureArray[8] + pressureArray[7] - pressureArray[0] - pressureArray[1] - pressureArray[2] >= 3) {
//RAISING
Serial.println("en hausse");
tendance = 30;
if (Z < 3) {
Serial.println("Ensoleillée");
if (night == 1) {
icone = random(2, 3);
}
else {
icone = 1;
}
}
else if (Z >= 3 and Z <= 9) {
Serial.println("Ensoleillée, nuageux");
if (night == 1) {
icone = 5;
}
else {
icone = 4;
}
}
else if (Z > 9 and Z <= 17) {
Serial.println("Nuageux");
icone = random(8, 9);
}
else if (Z > 17) {
Serial.println("Pluvieux");
icone = 10;
}
}
else if (pressureArray[0] + pressureArray[1] + pressureArray[2] - pressureArray[9] - pressureArray[8] - pressureArray[7] >= 3) {
//FALLING
Serial.println("en baisse");
tendance = 31;
if (Z < 4) {
Serial.println("Ensoleillée");
if (night == 1) {
icone = random(2, 3);
}
else {
icone = 1;
}
}
else if (Z >= 4 and Z < 14) {
Serial.println("Ensoleillée, nuageux");
if (night == 1) {
icone = 5;
}
else {
icone = 4;
}
}
else if (Z >= 14 and Z < 19) {
Serial.println("Détérioration");
if (night == 1) {
icone = 7;
}
else {
icone = 6;
}
}
else if (Z >= 19 and Z < 21) {
Serial.println("Nuageux");
icone = random(2, 3);
}
else if (Z >= 21) {
Serial.println("Pluvieux");
icone = 10;
}
}
else {
//STEADY
Serial.println("Stable");
tendance = 16;
if (Z < 5) {
Serial.println("Ensoleillée");
if (night == 1) {
icone = random(2, 3);
}
else {
icone = 1;
}
}
else if (Z >= 5 and Z <= 11) {
Serial.println("Ensoleillée, nuageux");
if (night == 1) {
icone = 5;
}
else {
icone = 4;
}
}
else if (Z > 11 and Z < 14) {
Serial.println("Nuageux");
icone = random(2, 3);
}
else if (Z >= 14 and Z < 19) {
Serial.println("Détérioration");
if (night == 1) {
icone = 7;
}
else {
icone = 6;
}
}
else if (Z >= 19) {
Serial.println("Pluvieux");
icone = 10;
}
}
}
else {
if (seapressure < 1005) {
Serial.println("Pluvieux");
icone = 10;
}
else if (seapressure >= 1005 and seapressure <= 1015) {
Serial.println("Nuageux");
icone = random(2, 3);
}
else if (seapressure > 1015 and seapressure < 1025) {
Serial.println("Ensoleillée, nuageux");
if (night == 1) {
icone = 5;
}
else {
icone = 4;
}
}
else {
Serial.println("Pluvieux");
icone = 10;
}
}
//pour forcer l'affichage de l'icone acquisition
if (Z == 26 && weather[ZT] == "Acquisition des données ...") {
icone = 0;
}
Serial.println("");
}
int calc_zambretti(int curr_pressure, int prev_pressure, int mon) {
if (curr_pressure < prev_pressure) {
//FALLING
if (mon >= 4 and mon <= 9)
//summer
{
if (curr_pressure >= 1030)
return 2;
else if (curr_pressure >= 1020 and curr_pressure < 1030)
return 8;
else if (curr_pressure >= 1010 and curr_pressure < 1020)
return 18;
else if (curr_pressure >= 1000 and curr_pressure < 1010)
return 21;
else if (curr_pressure >= 990 and curr_pressure < 1000)
return 24;
else if (curr_pressure >= 980 and curr_pressure < 990)
return 24;
else if (curr_pressure >= 970 and curr_pressure < 980)
return 26;
else if (curr_pressure < 970)
return 26;
}
else {
//winter
if (curr_pressure >= 1030)
return 2;
else if (curr_pressure >= 1020 and curr_pressure < 1030)
return 8;
else if (curr_pressure >= 1010 and curr_pressure < 1020)
return 15;
else if (curr_pressure >= 1000 and curr_pressure < 1010)
return 21;
else if (curr_pressure >= 990 and curr_pressure < 1000)
return 22;
else if (curr_pressure >= 980 and curr_pressure < 990)
return 24;
else if (curr_pressure >= 970 and curr_pressure < 980)
return 26;
else if (curr_pressure < 970)
return 26;
}
}
else if (curr_pressure > prev_pressure) {
//RAISING
if (mon >= 4 and mon <= 9) {
//summer
if (curr_pressure >= 1030)
return 1;
else if (curr_pressure >= 1020 and curr_pressure < 1030)
return 2;
else if (curr_pressure >= 1010 and curr_pressure < 1020)
return 3;
else if (curr_pressure >= 1000 and curr_pressure < 1010)
return 7;
else if (curr_pressure >= 990 and curr_pressure < 1000)
return 9;
else if (curr_pressure >= 980 and curr_pressure < 990)
return 12;
else if (curr_pressure >= 970 and curr_pressure < 980)
return 17;
else if (curr_pressure < 970)
return 17;
}
else
//winter
{
if (curr_pressure >= 1030)
return 1;
else if (curr_pressure >= 1020 and curr_pressure < 1030)
return 2;
else if (curr_pressure >= 1010 and curr_pressure < 1020)
return 6;
else if (curr_pressure >= 1000 and curr_pressure < 1010)
return 7;
else if (curr_pressure >= 990 and curr_pressure < 1000)
return 10;
else if (curr_pressure >= 980 and curr_pressure < 990)
return 13;
else if (curr_pressure >= 970 and curr_pressure < 980)
return 17;
else if (curr_pressure < 970)
return 17;
}
}
else {
if (curr_pressure >= 1030)
return 1;
else if (curr_pressure >= 1020 and curr_pressure < 1030)
return 2;
else if (curr_pressure >= 1010 and curr_pressure < 1020)
return 11;
else if (curr_pressure >= 1000 and curr_pressure < 1010)
return 14;
else if (curr_pressure >= 990 and curr_pressure < 1000)
return 19;
else if (curr_pressure >= 980 and curr_pressure < 990)
return 23;
else if (curr_pressure >= 970 and curr_pressure < 980)
return 24;
else if (curr_pressure < 970)
return 26;
}
}
int station2sealevel(int p, int height, int t) { // from pressure at our height to sea level
return (double) p * pow(1 - 0.0065 * (double)height / (t + 0.0065 * (double)height + 273.15), -5.275);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pour ajouter un zéro lorsque c'est des unités
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void print2digits(int number) {
if (number >= 0 && number < 10) {
display.write('0');
}
display.print(number);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pour couper la phrase en 2 sans couper de mots
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void sentencecutter() {
if (ZT != lastZT) {
int lettresTotal = 0;
int lettresLigne1 = 0;
int lettresLigne2 = 0;
String L1 = "";
String L2 = "";
size_t numberOfWords = wordCount(weather[ZT]);
if (numberOfWords >= maxWords) {
Serial.println(F("Erreur: trop de mots"));
while (true); // on arrête là
}
for (size_t i = 0; i < numberOfWords; i++) {
Serial.print(i + 1); //incremente
Serial.print(F("\t L = "));
Serial.print(strlen(wordPointers[i])); //pour connaitre la longueur de la chaine
Serial.print(F("\t\t["));
Serial.print(wordPointers[i]);
Serial.println(F("]"));
Serial.println("");
lettresTotal = strlen(wordPointers[i]) + lettresTotal + 1;
if (lettresTotal <= 22)
{
L1.concat(wordPointers[i]); //on rempli la ligne 1 avec les mots sans dépasser les 21 caractères
L1.concat(" ");
lettresLigne1 = lettresTotal;
}
else if (lettresTotal <= 42) {
L2.concat(wordPointers[i]);
L2.concat(" ");
lettresLigne2 = lettresTotal - lettresLigne1;
}
else {
}
}
Serial.print("Ligne 1: ");
Serial.println(L1);
Serial.print("Ligne 2: ");
Serial.println(L2);
L1.toCharArray(ligne1, 50);
L2.toCharArray(ligne2, 50);
lastZT = ZT;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pour changer de page sur l'afficheur
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void interrupt() {
if (page1 == 0) {
page1 = 1;
}
else {
}
}
void pageinfo() {
if (play1 == 0) {
display.clearDisplay();
pdr = dewPoint(tempExt, humExt), 2; //calcul point de rosée
hmd = humidex(tempExt, pdr), 2; //calcul de Humidex
ht = heatIndexC(tempExt, humExt), 2; //calcul de l'indice de chaleur
Serial.println("\nPdr\tHmd\tHt");
Serial.print(pdr); //point de rosée
Serial.print('\t');
Serial.print(hmd); //humidex
Serial.print('\t');
Serial.print(ht); //indice de chaleur
DateTime now = rtc.now();
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
//affichage prévision
//Ligne 1
display.setCursor(0, 0);
print2digits(now.day());
display.print("/");
print2digits(now.month());
display.print("/");
display.print(now.year());
display.setCursor(95, 0);
print2digits(now.hour());
display.print(":");
print2digits(now.minute());
display.drawLine(0, 12, 128, 12, WHITE); //ligne
//affichage point de rosée
display.setCursor(0, 16);//92,9
//display.print((char)tempIntTend ); //signe pour la tendance (flèche haut, bas, droite)
display.print("Point Ros");
display.print((char)130);
display.print("e: ");
display.print(pdr, 1);
display.print((char)247);
//affichage humidex //moins de 30, aucun inconfort
// //30 à 39, un certain inconfort
display.setCursor(0, 24); //au-dessus de 40, beaucoup d'inconfort
display.print("Humidex: "); //au-dessus de 45, il y a danger : un coup de chaleur est probable
display.print(hmd, 0); //au-dessus de 54, un coup de chaleur est imminent
//affichage indice chaleur
display.setCursor(0, 32);
display.print("Indice Chaleur: ");
display.print(ht, 1);
display.print((char)247);
//affichage indice UV
display.setCursor(0, 40);
display.print("Indice UV: ");
display.print("");
//affichage vitesse du vent
display.setCursor(0, 48);
display.print("Vent: ");
display.print("56");
display.print("Km/h");
display.display(); // affichage à l'écran
tpage = Time;
play1 = 1;
}
}