void savemastd()//readmasrab()1038 { int kh=1;//кол- проп часов t = rtc.getTime(); readmasclok();//623 byte hourn=t.hour; if (hourp 0; a = a--) { for (int i =22 ; i >= 0; i = i--) { temdom[i+1]=temdom[i]; } temdom[0]= tdc*10+tdd; for (int i =22 ; i >= 0; i = i--) { pres[i+1]=pres[i]; } pres[0]= pressure; for (int i =22 ; i >= 0; i = i--) { time1[i+1]=time1[i];//запись в массив давления } time1[0]=hourn*100+t.min;//запись в массив времени for (int i =22 ; i >= 0; i = i--) { temul[i+1]=temul[i];//запись в массив температуры уличной } if (zn==2) { temul[0]=tu*10+tud; } else {temul[0]=tu*10+tud+1000; } for (int i =22 ; i >= 0; i = i--) { hug[i+1]=hug[i];//запись в массив влажность улица } if(hu<2){hu=1;} hug[0]= hu*10+hud; for (int i =22 ; i >= 0; i = i--) { h[i+1]=h[i];//запись в массив влажность дом } //h[0]= sensor.humidity; h[0]=hdc; for (int i =22 ; i >= 0; i = i--) { sun[i+1]=sun[i]; } if(osv9>99){osv9=99;} sun[0]= osv9; } } if (hourp>hourn) {kh=23-hourp;//+t.hour; for (int a =kh ; a > 0; a = a--) { for (int i =22 ; i >= 0; i = i--) { temdom[i+1]=temdom[i]; } temdom[0]= tdc*10+tdd; for (int i =22 ; i >= 0; i = i--) { pres[i+1]=pres[i]; } pres[0]= pressure; for (int i =22 ; i >= 0; i = i--) { time1[i+1]=time1[i];//запись в массив давления } time1[0]=hourn*100+t.min;//запись в массив времени for (int i =22 ; i >= 0; i = i--) { temul[i+1]=temul[i];//запись в массив температуры уличной } if (zn==2) { temul[0]=tu*10+tud; } else {temul[0]=tu*10+tud+1000; } for (int i =22 ; i >= 0; i = i--) { sun[i+1]=sun[i]; } if(osv9>99){osv9=99;} sun[0]= osv9; for (int i =22 ; i >= 0; i = i--) { hug[i+1]=hug[i];//запись в массив влажность улица } hug[0]= hu*10+hud; for (int i =22 ; i >= 0; i = i--) { h[i+1]=h[i];//запись в массив влажность дом } //h[0]= sensor.humidity; h[0]=hdc; } //********* if (hourp<23) {dd=1; sdwrite(); saveminmax(); dd=0; } kh=hourn+1;//+t.hour; for (int a =kh ; a > 0; a = a--) { for (int i =22 ; i >= 0; i = i--) { temdom[i+1]=temdom[i]; } temdom[0]= tdc*10+tdd; for (int i =22 ; i >= 0; i = i--) { pres[i+1]=pres[i]; } pres[0]= pressure; for (int i =22 ; i >= 0; i = i--) { time1[i+1]=time1[i];//запись в массив давления } time1[0]=hourn*100+t.min;//запись в массив времени for (int i =22 ; i >= 0; i = i--) { temul[i+1]=temul[i];//запись в массив температуры уличной } if (zn==2) { temul[0]=tu*10+tud; } else {temul[0]=tu*10+tud+1000; } for (int i =22 ; i >= 0; i = i--) { hug[i+1]=hug[i];//запись в массив влажность улица } hug[0]= hu*10+hud; for (int i =22 ; i >= 0; i = i--) { sun[i+1]=sun[i]; } if(osv9>99){osv9=99;} sun[0]= osv9; for (int i =22 ; i >= 0; i = i--) { h[i+1]=h[i];//запись в массив влажность дом } //h[0]= sensor.humidity; h[0]=hdc; } } } //**************************запись данных в файлы по месяцам и дням директориии улица и дом ********************************** void sdwrite() { 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"}; char* name; int temuld; //const char* source=".txt"; sd.chdir("/"); delay (100); sd.chdir("tempdom"); delay (100); name= stry[t.year-2014]; if (!sd.chdir(name)) {sd.mkdir(name); }//установка раб директории // sd.chdir("tempdom");//установка раб директории delay (100); sd.chdir(name); delay (100); //month1=rtc_clock.get_months(); name= strm[t.mon-1]; if (!sd.chdir(name)) {sd.mkdir(name); }//установка раб директории // sd.chdir("tempdom");//установка раб директории delay (100); sd.chdir(name); delay (100); if(dd==1) { name= strd[t.date-2]; } else {name= strd[t.date-1]; } myFile.open(name, O_RDWR | O_CREAT | O_AT_END); for (int i=0; i<24; i++) { if (time1[i]/100<10) {myFile.print("0"); myFile.print(time1[i]/100); } else { myFile.print(time1[i]/100); } myFile.print(":"); if (time1[i]%100<10) {myFile.print("0"); myFile.print(time1[i]%100); } else { myFile.print(time1[i]%100); } myFile.print(" T=+"); myFile.print(temdom[i]/10); myFile.print(","); myFile.print(temdom[i]%10); myFile.print("C Pmm="); myFile.print(pres[i]); myFile.print(" H="); if (h[i]>10) { myFile.print(h[i]); } else {myFile.print("0"); myFile.print(h[i]); } myFile.println("%"); // close the file: } myFile.close(); sd.chdir("/"); //*************запись массива улица ******************************* // sd.chdir("/"); delay (100); sd.chdir("tempul"); delay (100); name= stry[t.year-2014]; if (!sd.chdir(name)) {sd.mkdir(name); }//установка раб директории // sd.chdir("tempdom");//установка раб директории delay (100); sd.chdir(name); delay (100); //month1=rtc_clock.get_months(); name= strm[t.mon-1]; if (!sd.chdir(name)) {sd.mkdir(name); }//установка раб директории // sd.chdir("tempdom");//установка раб директории delay (100); sd.chdir(name); delay (100); if(dd==1) { name= strd[t.date-2]; } else {name= strd[t.date-1]; } myFile.open(name, O_RDWR | O_CREAT | O_AT_END); for (int i=0; i<24; i++) { if (time1[i]/100<10) {myFile.print("0"); myFile.print(time1[i]/100); } else { myFile.print(time1[i]/100); } myFile.print(":"); if (time1[i]%100<10) {myFile.print("0"); myFile.print(time1[i]%100); } else { myFile.print(time1[i]%100); } if (temul[i]<999) { myFile.print(" T=+"); temuld=temul[i]; } else {myFile.print(" T=-"); temuld=temul[i]-1000; } if ((temuld<100)&&(temuld>9)) {myFile.print("0"); myFile.print(temuld/10); myFile.print(","); myFile.print(temuld%10); } if (temuld<10) {myFile.print("00,"); myFile.print(temuld); } //***************************************************************************************** if (temuld>99) { myFile.print(temuld/10); myFile.print(","); myFile.print(temuld%10); } myFile.print("C Hu="); if ((hug[i]<100)&& hug[i]>9) {myFile.print("0"); myFile.print(hug[i]/10); myFile.print(","); myFile.print(hug[i]%10); } if (hug[i]<10) {myFile.print("00,"); myFile.print(hug[i]); } if (hug[i]>99) { myFile.print(hug[i]/10); myFile.print(","); myFile.print(hug[i]%10); } myFile.println("%"); // close the file: } myFile.close(); delay (100); sd.chdir("/"); if (fa==1)// появилась новая макс температура { fa=0; delay (100); myFile.open("yminmax.txt", O_RDWR | O_CREAT | O_AT_END); delay (50); byte hh; byte mm; byte d; byte m; word y; d=time1[24]/1000; m=(time1[24]%1000)/10; y=((time1[24]%1000)%10)*10; hh=time1[25]/1000; mm=(time1[25]%1000)/10; y=y+((time1[25]%1000)%10); 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(y); myFile.print(" "); if(hh<10) { myFile.print("0"); myFile.print(hh); } else { myFile.print(hh); } myFile.print(":"); if(mm<10) { myFile.print("0"); myFile.print(mm); } else { myFile.print(mm); } myFile.print(" Tmax=+"); myFile.print(temul[24]/10); myFile.print(","); myFile.print(temul[24]%10); myFile.println("C"); } if (fi==1)// появилась новая мин температура {fi=0; delay (100); myFile.open("yminmax.txt", O_RDWR | O_CREAT | O_AT_END); delay (50); byte hh; byte mm; byte d; byte m; word y; d=time1[26]/1000; m=(time1[26]%1000)/10; y=((time1[26]%1000)%10)*10; hh=time1[27]/1000; mm=(time1[27]%1000)/10; y=y+((time1[27]%1000)%10); 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(y); myFile.print(" "); if(hh<10) { myFile.print("0"); myFile.print(hh); } else { myFile.print(hh); } myFile.print(":"); if(mm<10) { myFile.print("0"); myFile.print(mm); } else { myFile.print(mm); } myFile.print(" "); int Tm; if (temul[25]>1000) { Tm=temul[25]-1000; myFile.print("Tmin=-"); } else { myFile.print("Tmin=+"); Tm=temul[25]; } myFile.print(Tm/10); myFile.print(","); myFile.print(Tm%10); myFile.println("C"); } myFile.close(); delay (50); sd.chdir("/"); //*************************sun************************************ sd.chdir("/"); delay (100); sd.chdir("sun"); delay (100); name= stry[t.year-2014]; if (!sd.chdir(name)) {sd.mkdir(name); }//установка раб директории // sd.chdir("tempdom");//установка раб директории delay (100); sd.chdir(name); delay (100); //month1=rtc_clock.get_months(); name= strm[t.mon-1]; if (!sd.chdir(name)) {sd.mkdir(name); }//установка раб директории // sd.chdir("tempdom");//установка раб директории delay (100); sd.chdir(name); delay (100); if(dd==1) { name= strd[t.date-2]; } else {name= strd[t.date-1]; } myFile.open(name, O_RDWR | O_CREAT | O_AT_END); for (int i=0; i<24; i++) { if (time1[i]/100<10) {myFile.print("0"); myFile.print(time1[i]/100); } else { myFile.print(time1[i]/100); } myFile.print(":"); if (time1[i]%100<10) {myFile.print("0"); myFile.print(time1[i]%100); } else { myFile.print(time1[i]%100); } myFile.print(" S="); if(sun[i]>9) {myFile.print(sun[i]);//sun[24] } else {myFile.print("0"); myFile.print(sun[i]);//sun[24] } myFile.println("%"); // close the file: } myFile.close(); delay (50); sd.chdir("/"); } //******************************************************************************************************************* void readmasclok() { byte timer[5];//21:25 29/04/14 sd.chdir("/"); delay (100); myFile.open("clok.txt", O_READ); for (int i =0 ; i < 4; i = i++) { byte b= myFile.read()-48; timer[i]=b; } myFile.close(); hourp=timer[0]*10+timer[1]; } //*********************************запись времени на sd 12:56 15/05/14*************************************************************** void savemasclok() { t = rtc.getTime(); date= t.date; mon=t.mon; year1=t.year-2000; min1= t.min; hour1=t.hour; sd.chdir("/"); delay (100); myFile.open("clok.txt", O_RDWR | O_CREAT | O_AT_END); myFile.remove(); delay (50); myFile.open("clok.txt", O_RDWR | O_CREAT | O_AT_END); delay (50); // запись в файл времени if (t.hour<10) {myFile.print("0"); myFile.print(t.hour); } else { myFile.print(t.hour); } myFile.print(":"); if (min1<10) {myFile.print("0"); myFile.print(min1); } else { myFile.print(min1); } myFile.print(" "); // запись в файл даты if (date<10) {myFile.print("0"); myFile.print(date); } else { myFile.print(date); } myFile.print("/"); if (mon<10) {myFile.print("0"); myFile.print(mon); } else { myFile.print(mon); } myFile.print("/"); myFile.print(year1); myFile.close(); savemasrab(); } //*******************************************запись в раб массив***************************** void savemasrab() {int temuld; sd.chdir("/"); delay (100); myFile.open("rab.txt", O_RDWR | O_CREAT | O_AT_END); myFile.remove(); delay (50); myFile.open("rab.txt", O_RDWR | O_CREAT | O_AT_END); delay (50); for (int i=0; i<24; i++) { if (time1[i]/100<10) {myFile.print("0"); myFile.print(time1[i]/100); } else { myFile.print(time1[i]/100); } myFile.print(":"); if (time1[i]%100<10) {myFile.print("0"); myFile.print(time1[i]%100); } else { myFile.print(time1[i]%100); } myFile.print(" T=+"); myFile.print(temdom[i]/10); myFile.print(","); myFile.print(temdom[i]%10); myFile.print("C Pmm="); myFile.print(pres[i]); myFile.print(" H="); if (h[i]<10) { myFile.print("0"); } myFile.print(h[i]); myFile.print("% Tu="); if (temul[i]>999) { myFile.print("-"); temuld=temul[i]-1000;//вынос температуры с учетом знака из массива - } else {myFile.print("+"); temuld=temul[i];//вынос температуры с учетом знака из массива + } //**************печать незначимых нулей********************************************+03,3С в массиве Т=33 if ((temuld<100)&&(temuld>9)) {myFile.print("0"); myFile.print(temuld/10); myFile.print(","); myFile.print(temuld%10); } if (temuld<10) {myFile.print("00,"); myFile.print(temuld); } //***************************************************************************************** if (temuld>99) { myFile.print(temuld/10); myFile.print(","); myFile.print(temuld%10); } myFile.print("C Hu="); if ((hug[i]<100)&& hug[i]>9) {myFile.print("0"); myFile.print(hug[i]/10); myFile.print(","); myFile.print(hug[i]%10); } if (hug[i]<10) {myFile.print("00,"); myFile.print(hug[i]); } if (hug[i]>99) { myFile.print(hug[i]/10); myFile.print(","); myFile.print(hug[i]%10); } myFile.print("% s="); if (sun[i]<10) { myFile.print("0"); } myFile.print(sun[i]); myFile.println("%"); // myFile.println(pres[i]); // close the file: } byte hh; byte mm; byte d; byte m; word y; d=time1[24]/1000; m=(time1[24]%1000)/10; y=((time1[24]%1000)%10)*10; hh=time1[25]/1000; mm=(time1[25]%1000)/10; y=y+((time1[25]%1000)%10); 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(y); myFile.print(" "); if(hh<10) { myFile.print("0"); myFile.print(hh); } else { myFile.print(hh); } myFile.print(":"); if(mm<10) { myFile.print("0"); myFile.print(mm); } else { myFile.print(mm); } myFile.print(" Tmax=+"); myFile.print(temul[24]/10); myFile.print(","); myFile.print(temul[24]%10); myFile.println("C"); //************min d=time1[26]/1000; m=(time1[26]%1000)/10; y=((time1[26]%1000)%10)*10; hh=time1[27]/1000; mm=(time1[27]%1000)/10; y=y+((time1[27]%1000)%10); 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(y); myFile.print(" "); if(hh<10) { myFile.print("0"); myFile.print(hh); } else { myFile.print(hh); } myFile.print(":"); if(mm<10) { myFile.print("0"); myFile.print(mm); } else { myFile.print(mm); } myFile.print(" "); int Tm; if (temul[25]>1000) { Tm=temul[25]-1000; myFile.print("Tmin=-"); } else { myFile.print("Tmin=+"); Tm=temul[25]; } if ((Tm<100)&&(Tm>9)) {myFile.print("0"); myFile.print(Tm/10); myFile.print(","); myFile.print(Tm%10); } if (Tm<10) {myFile.print("00,"); myFile.print(Tm); } //***************************************************************************************** if (Tm>99) { myFile.print(Tm/10); myFile.print(","); myFile.print(Tm%10); } myFile.println("C"); if(dfl>9) {myFile.print(dfl); } else {myFile.print("0"); myFile.print(dfl); } myFile.print(":00"); myFile.print(" vl="); if(vfl>9) {myFile.print(vfl); } else {myFile.print("0"); myFile.print(vfl); } myFile.print(" t="); if(tfl>9) {myFile.print(tfl); } else {myFile.print("0"); myFile.print(tfl); } myFile.print(" s="); if(osv>9) {myFile.println(osv); } else {myFile.print("0"); myFile.println(osv); } if(dfl2>9) {myFile.print(dfl2); } else {myFile.print("0"); myFile.print(dfl2); } myFile.print(":00"); myFile.print(" vl="); if(vfl2>9) {myFile.print(vfl2); } else {myFile.print("0"); myFile.print(vfl2); } myFile.print(" t="); if(tfl2>9) {myFile.print(tfl2); } else {myFile.print("0"); myFile.print(tfl2); } myFile.print(" s="); if(osv>9) {myFile.println(osv); } else {myFile.print("0"); myFile.println(osv); } if(dfl2>9) {myFile.print(dfl3); } else {myFile.print("0"); myFile.print(dfl3); } myFile.print(":00"); myFile.print(" vl="); if(vfl3>9) {myFile.print(vfl3); } else {myFile.print("0"); myFile.print(vfl3); } myFile.print(" t="); if(tfl3>9) {myFile.print(tfl3); } else {myFile.print("0"); myFile.print(tfl3); } myFile.print(" s="); if(osv>9) {myFile.println(osv); } else {myFile.print("0"); myFile.println(osv); } myFile.close(); sd.chdir("/"); } //****************************чтение файла rab.txt изапись данных в массивы ********************************************** void readmasrab() { byte reader[53];//23:00 T=+25,8C Pmm=756 H=25% Tu=+25,6C Hu=75,6% sd.chdir("/"); delay (100); myFile.open("rab.txt", O_READ); for (int n =0 ; n < 24; n = n++)// колво строк в файле { for (int i =0 ; i < 53; i = i++) // колво байт в строку { byte b= myFile.read(); if (b<48) {reader[i]=b; } else { b=b-48;//получение цифры из байта reader[i]=b; } } //word time[24]=1000,1100,---- //word temdom[24]=256,254, //word pres[24]=756,754, time1[n]=reader[0]*1000+reader[1]*100+reader[3]*10+reader[4]; temdom[n]=reader[9]*100+reader[10]*10+reader[12]; pres[n]=reader[19]*100+reader[20]*10+reader[21]; h[n]=reader[25]*10+reader[26]; sun[n]=reader[50]*10+reader[51]; if (reader[32]==45) {temul[n]=reader[33]*100+reader[34]*10+reader[36]+1000; } else {temul[n]=reader[33]*100+reader[34]*10+reader[36]; } hug[n]=reader[42]*100+reader[43]*10+reader[45]; if (n==0) {tu=reader[33]*10+reader[34]; tud=reader[36]; hu=reader[42]*10+reader[43]; hud=reader[45]; volt=490; if (reader[32]==45) { zn=1; } else {zn=2; } } byte b= myFile.read()-48;//возврат коретки 2 байта b= myFile.read()-48; } for (int n =0 ; n < 3; n = n+2)// колво строк в файле { for (int i =0 ; i < 26; i = i++) // колво байт в строку { byte b= myFile.read(); if (b<48) {reader[i]=b; } else { b=b-48;//получение цифры из байта reader[i]=b; } } time1[n+24]=reader[0]*10000+reader[1]*1000+reader[3]*100+reader[4]*10+reader[6];//max 16.08. 1 16081 time1[n+1+24]=reader[9]*10000+reader[10]*1000+reader[12]*100+reader[13]*10+reader[7];//12:00 4 12004 if (reader[20]==45) {temul[24+n/2]=reader[21]*100+reader[22]*10+reader[24]+1000; } else {temul[24+n/2]=reader[21]*100+reader[22]*10+reader[24]; } byte b= myFile.read()-48;//возврат коретки 2 байта b= myFile.read()-48; } //poliv data for (int i =0 ; i < 21; i = i++) // колво байт в строку { byte b= myFile.read(); if (b<48) {reader[i]=b; } else { b=b-48;//получение цифры из байта reader[i]=b; } } dfl=reader[0]*10+reader[1];// time flower vfl=reader[9]*10+reader[10];// vlaga flower tfl=reader[14]*10+reader[15];// temp flower osv=reader[19]*10+reader[20];// svet flower byte b= myFile.read()-48;//возврат коретки 2 байта b= myFile.read()-48; //poliv data for (int i =0 ; i < 21; i = i++) // колво байт в строку { byte b= myFile.read(); if (b<48) {reader[i]=b; } else { b=b-48;//получение цифры из байта reader[i]=b; } } dfl2=reader[0]*10+reader[1];// time flower vfl2=reader[9]*10+reader[10];// vlaga flower tfl2=reader[14]*10+reader[15];// temp flower // osv=reader[19]*10+reader[20];// svet flower b= myFile.read()-48;//возврат коретки 2 байта b= myFile.read()-48; for (int i =0 ; i < 21; i = i++) // колво байт в строку { byte b= myFile.read(); if (b<48) {reader[i]=b; } else { b=b-48;//получение цифры из байта reader[i]=b; } } dfl3=reader[0]*10+reader[1];// time flower vfl3=reader[9]*10+reader[10];// vlaga flower tfl3=reader[14]*10+reader[15];// temp flower myFile.close(); }