You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Play/my719/saveminmax.ino

314 lines
6.2 KiB

void saveminmax()
{
char* strd[] = {"01.txt","02.txt","03.txt","04.txt","05.txt","06.txt","07.txt","08.txt","09.txt","10.txt","11.txt","12.txt","13.txt","14.txt","15.txt","16.txt","17.txt","18.txt","19.txt","20.txt","21.txt","22.txt","23.txt","24.txt","25.txt","26.txt","27.txt","28.txt","29.txt","30.txt","31.txt"};
char* strm[] = {"JAN","FEBR","MARCH","APRIL","MAY","JUNE","JULY","AUG","SEPT","OCT","NOV","DEC"};
char* stry[] = {"2014","2015","2016","2017","2018","2019","2020","2021","2022","2023","2024","2025","2026","2027","2028","2029","2030","2031","2032","2033","2034","2035"};
//*******************************************
//вычисление минимального и масимального значеия массива work2[n]
//************************************************
word Tmax;
word Tmin;
int Tcr=500;// значение нуля для средней темп
word td=0;
boolean znmin;//0-+ 1-- min max Знак начальной мин и макс температуры для сравнение
boolean znmax;//0-+ 1-- min max Знак начальной мин и макс температуры для сравнение
boolean zn;//0-+ 1-- tsr знак средней температуры
byte i;
if (temul[0]>999)
{Tmax=temul[0]-1000;
Tmin=Tmax;
znmin=1;//-
znmax=1;//-
}
else
{Tmax=temul[0];
Tmin=Tmax;
znmin=0;//+
znmax=0;//+
}
for ( byte i=0; i<24; i++)//Tu
{
if (temul[i]>999)
{ td=temul[i]-1000;
zn=1;//-
}
else
{td=temul[i];
zn=0;//+
}
if (zn==0)
{Tcr=Tcr+td;
}
else
{Tcr=Tcr-td;
}
//****************** + + ****************
if((zn==0)&&(znmax==0))
{ if (td>Tmax)
{Tmax=td;
znmax=0;
}
}
//****************** + - ******
if((zn==0)&&(znmax==1))
{
Tmax=td;
znmax=0;
}
//****************** - - ******
if((zn==1)&&(znmax==1))
{ if (td<Tmax)
{Tmax=td;
znmax=1;
}
}
//****************** - + ******
if((zn==1)&&(znmax==0))
{
//Tmax=Tmax;
znmax=0;
}
//****************** + + ****************
if((zn==0)&&(znmin==0))
{ if (td<Tmin)
{Tmin=td;
znmin=0;
}
}
//****************** - - ****************
if((zn==1)&&(znmin==1))
{ if (td>Tmin)
{Tmin=td;
znmin=1;
}
}
//****************** - + ****************
if((zn==1)&&(znmin==0))
{
Tmin=td;
znmin=1;
}
//****************** + - ****************
if((zn==0)&&(znmin==1))
{
//Tmin=Tmin;
znmin=1;
}
}
//******************************
if (Tcr<500)
{ Tcr=(500-Tcr)/24;
zn=1;
}
else
{Tcr=(Tcr-500)/24;
zn=0;
}
//**********************************************
int Hcr=0;
for ( byte i=0; i<24; i++)//Tu
{
Hcr=Hcr+hug[i];
}
Hcr=Hcr/24;
//***************************************************
word Pcr=0;
for ( byte i=0; i<24; i++)//Tu
{
Pcr=Pcr+pres[i]-700;
}
Pcr=700+Pcr/24;
//**************************************************
word Thcr=0;
for ( byte i=0; i<24; i++)//Tu
{
Thcr=Thcr+temdom[i];
}
Thcr=Thcr/24;
//**************************************************
t = rtc.getTime();
char* name;
sd.chdir("/");
delay (100);
sd.chdir("tempul");
delay (100);
name= stry[t.year-2014];
if (!sd.chdir(name))
{sd.mkdir(name);
}
sd.chdir(name);//установка раб директории
delay (100);
name= strm[t.mon-1];
if (!sd.chdir(name))
{sd.mkdir(name);
}
sd.chdir(name);//установка раб директории
delay (100);
byte m=t.mon;// месяц
word yea=t.year;
byte d=t.date;
delay (100);
if(dd==1)
{if (t.date>1)
{ d=t.date-1;
}
else
{m=t.mon-1;
d=31;//****************************
}
}
else
{d=t.date;
}
myFile.open("minmax.txt", O_RDWR | O_CREAT | O_AT_END);
delay (50);
//****запись данных в файл в формате: 01.09.14 Tmax=30.4C Tmin=15.5C Tucr=22,5C Hucr=62,8% Pmm=756 Thcr=26,2C
if (d<10)
{myFile.print("0");
myFile.print(d);
}
else
{ myFile.print(d);
}
myFile.print(".");
if (m<10)
{myFile.print("0");
myFile.print(m);
}
else
{ myFile.print(m);
}
myFile.print(".");
myFile.print(yea-2000);
if (znmax==0)
{ myFile.print(" Tma=+");
}
else
{ myFile.print(" Tma=-");
}
if ((Tmax<100)&&(Tmax>9))
{myFile.print("0");
myFile.print(Tmax/10);
myFile.print(",");
myFile.print(Tmax%10);
}
if (Tmax<10)
{myFile.print("00,");
myFile.print(Tmax);
}
if (Tmax>99)
{ myFile.print(Tmax/10);
myFile.print(",");
myFile.print(Tmax%10);
}
myFile.print(" Tmi=");
if (znmin==1)
{ myFile.print("-");
}
else
{myFile.print("+");
}
if ((Tmin<100)&&(Tmin>9))
{myFile.print("0");
myFile.print(Tmin/10);
myFile.print(",");
myFile.print(Tmin%10);
}
if (Tmin<10)
{myFile.print("00,");
myFile.print(Tmin);
}
if (Tmin>99)
{ myFile.print(Tmin/10);
myFile.print(",");
myFile.print(Tmin%10);
}
myFile.print(" Tsr=");
if (zn==1)
{ myFile.print("-");
}
else
{myFile.print("+");
}
if ((Tcr<100)&&(Tcr>9))
{myFile.print("0");
myFile.print(Tcr/10);
myFile.print(",");
myFile.print(Tcr%10);
}
if (Tcr<10)
{myFile.print("00,");
myFile.print(Tcr);
}
if (Tcr>99)
{ myFile.print(Tcr/10);
myFile.print(",");
myFile.print(Tcr%10);
}
myFile.print("C Hcr=");
if (Hcr/10<10)
{myFile.print("0");
myFile.print(Hcr/10);
myFile.print(",");
myFile.print(Hcr%10);
}
else
{
myFile.print(Hcr/10);
myFile.print(",");
myFile.print(Hcr%10);
}
myFile.print("% Pcr=");
myFile.print (Pcr);
myFile.print(" Thcr=");
myFile.print(Thcr/10);
myFile.print(",");
myFile.println(Thcr%10);
//myFile.println("%");
myFile.close();
delay (100);
sd.chdir("/");
delay (100);
//********************
}