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/savedat.ino

344 lines
7.4 KiB

void savetdat()
{ // myFile.print(c);//t1+103c375v299h9
//byte ntdat;номер датчика
//byte zndat;знак температуры 0+
//int tdat;температура
//int hdat;влажность
//int vdat;напряж батареи датчика
int hourd;//время прихода данных час
int mind;//мин
int tdatc;
int tdatd;
int hdatc;
int hdatd;
int vdat;
if(ntdat==1)
{ hourd1=t.hour;
mind1=t.min;
hourd=t.hour;
mind=t.min;
tdatc=t11/10;
tdatd=t11%10;
hdatc=h11/10;
hdatd=h11%10;
vdat=bat[0];
}
if(ntdat==2)
{ hourd2=t.hour;
mind2=t.min;
hourd=t.hour;
mind=t.min;
tdatc=t12/10;
tdatd=t12%10;
hdatc=h12/10;
hdatd=h12%10;
vdat=bat[1];
}
if(ntdat==3)
{ hourd3=t.hour;
mind3=t.min;
hourd=t.hour;
mind=t.min;
tdatc=t13/10;
tdatd=t13%10;
hdatc=h13/10;
hdatd=h13%10;
vdat=bat[2];
}
if(ntdat==4)
{ hourd4=t.hour;
mind4=t.min;
hourd=t.hour;
mind=t.min;
tdatc=t14/10;
tdatd=t14%10;
hdatc=h14/10;
hdatd=h14%10;
vdat=bat[3];
}
if(ntdat==5)
{ hourd5=t.hour;
mind5=t.min;
hourd=t.hour;
mind=t.min;
tdatc=t15/10;
tdatd=t15%10;
hdatc=h15/10;
hdatd=h15%10;
vdat=bat[4];
}
myGLCD.setColor(VGA_WHITE);
myGLCD.setBackColor(0,172,238);
myGLCD.setFont(BigFont);
myGLCD.print(" " ,80, 457);//20
myGLCD.printNumI(ntdat ,80, 457);
myGLCD.print("t_T=" ,80+16, 457);//*16
if (zndat==0)
{myGLCD.print("+" ,80+90, 457);
}
else
{myGLCD.print("-" ,80+90, 457);//pos*16
}
if (tdatc<10)
{myGLCD.printNumI(tdatc ,80+90+16+16, 457);
}
else
{myGLCD.printNumI(tdatc ,80+90+16, 457);//pos*16
}
myGLCD.print("," ,80+90+16+16+16, 457);
myGLCD.printNumI(tdatd ,80+90+16+16+16+16, 457);
myGLCD.print("C_H=" ,80+90+16+16+16+16+16+16, 457);//498
if (hdatc<10)
{myGLCD.printNumI(hdatc ,314+16+16, 457);
}
else
{myGLCD.printNumI(hdatc ,314+16, 457);//pos*16
}
myGLCD.print("," ,314+16+16+16, 457);
myGLCD.printNumI(hdatd ,314+16+16+16+16, 457);
myGLCD.print("%_U=" ,314+16+16+16+16+16, 457);//610
myGLCD.printNumI(vdat/100 ,458-16, 457);
myGLCD.print("," ,458, 457);
myGLCD.printNumI(vdat%100 ,458+16, 457);
myGLCD.print("v " ,458+64-16, 457);
if (hourd<10)
{myGLCD.print("0" ,474+64, 457);
myGLCD.printNumI(hourd,474+64+16, 457);
}
else
{ myGLCD.printNumI(hourd,474+64, 457);
}
myGLCD.print(":",474+64+32, 457);
if (mind<10)
{myGLCD.print("0",474+64+32+16, 457);
myGLCD.printNumI(mind,474+64+32+32, 457);
}
else
{ myGLCD.printNumI(mind,474+64+32+16, 457);
}
if(fh==0)
{ //запись на флешку
char* strd[] = {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
char* strm[] = {"JAN","FEBR","MARCH","APRIL","MAY","JUNE","JULY","AUG","SEPT","OCT","NOV","DEC"};
char* stry[] = {"2014","2015","2016","2017","D-2018","D-2019","D-2020","D-2021","D-2022","D-2023","D-2024","D-2025","D-2026","D-2027","D-2028","D-2029","D-2030","D-2031","D-2032","D-2033","D-2034","D-2035"};
char* strdat[] = {"T1.txt","T2.txt","T3.txt","T4.txt","T5.txt","T6.txt","T7.txt","T8.txt","T9.txt","T10.txt"};
char* name;
sd.chdir("/");//корневая директория
delay (100);
// if (!sd.chdir("tdat"))//если поддериктория не создана , то создаем
// {sd.mkdir("tdat");
// }
// delay (100);
//sd.chdir("tdat");
//------------------------------------------------------------------------------------------------------
t = rtc.getTime();
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);
name= strd[t.date-1];
if (!sd.chdir(name))
{sd.mkdir(name);
}
sd.chdir(name);//установка раб директории
delay (100);
//-----------------------------------------------------------------------------------------------------------------------------------
//delay (100);
name= strdat[ntdat-1];// имя файла
myFile.open(name, O_RDWR | O_CREAT | O_AT_END);//15:22 T=+25,2C H=45,6% U=2,7v
if (hourd<10)
{myFile.print("0");
myFile.print(hourd);
}
else
{ myFile.print(hourd);
}
myFile.print(":");
if (mind<10)
{myFile.print("0");
myFile.print(mind);
}
else
{ myFile.print(mind);
}
if (zndat==0)
{myFile.print("T=+");
}
else
{myFile.print("T=-");
}
if (tdatc<10)
{myFile.print("0");
myFile.print(tdatc);
}
else
{myFile.print(tdatc);
}
myFile.print(",");
myFile.print(tdatd);
myFile.print("C H=");
if (hdatc<10)
{myFile.print("0");
myFile.print(hdatc);
}
else
{myFile.print(hdatc);
}
myFile.print(",");
myFile.print(hdatd);
myFile.print("% U=");
myFile.print(vdat/100);
myFile.print(",");
if (vdat%100<10)
{myFile.print("0");
myFile.print(vdat%100);
}
else
{ myFile.print(vdat%100);
}
myFile.println("v");
myFile.close();
sd.chdir("/");
}
}
//******************************************************************************************
void printdat ()
{
myGLCD.setColor(VGA_WHITE);
myGLCD.setBackColor(0,172,238);
myGLCD.setFont(BigFont);
myGLCD.print(" " ,80, 457);//20
myGLCD.printNumI(ntdat ,80, 457);
myGLCD.print("t_T=" ,80+16, 457);//*16
if (zndat==0)
{myGLCD.print("+" ,80+90, 457);
}
else
{myGLCD.print("-" ,80+90, 457);//pos*16
}
int hourd;//время прихода данных час
int mind;//мин
int tdatc;
int tdatd;
int hdatc;
int hdatd;
int vdat;
if(ntdat==1)
{
hourd=hourd1;
mind=mind1;
tdatc=t11/10;
tdatd=t11%10;
hdatc=h11/10;
hdatd=h11%10;
vdat=bat[0];
}
if(ntdat==2)
{ hourd=hourd2;
mind=mind2;
tdatc=t12/10;
tdatd=t12%10;
hdatc=h12/10;
hdatd=h12%10;
vdat=bat[1];
}
if(ntdat==3)
{ hourd=hourd3;
mind=mind3;
tdatc=t13/10;
tdatd=t13%10;
hdatc=h13/10;
hdatd=h13%10;
vdat=bat[2];
}
if(ntdat==4)
{ hourd=hourd4;
mind=mind4;
tdatc=t14/10;
tdatd=t14%10;
hdatc=h14/10;
hdatd=h14%10;
vdat=bat[3];
}
if(ntdat==5)
{ hourd=hourd5;
mind=mind5;
tdatc=t15/10;
tdatd=t15%10;
hdatc=h15/10;
hdatd=h15%10;
vdat=bat[4];
}
if (tdatc<10)
{myGLCD.printNumI(tdatc ,80+90+16+16, 457);
}
else
{myGLCD.printNumI(tdatc ,80+90+16, 457);//pos*16
}
myGLCD.print("," ,80+90+16+16+16, 457);
myGLCD.printNumI(tdatd ,80+90+16+16+16+16, 457);
myGLCD.print("C_H=" ,80+90+16+16+16+16+16+16, 457);//498
if (hdatc<10)
{myGLCD.printNumI(hdatc ,314+16+16, 457);
}
else
{myGLCD.printNumI(hdatc ,314+16, 457);//pos*16
}
myGLCD.print("," ,314+16+16+16, 457);
myGLCD.printNumI(hdatd ,314+16+16+16+16, 457);
myGLCD.print("%_U=" ,314+16+16+16+16+16, 457);//610
myGLCD.printNumI(vdat/100 ,458-16, 457);
myGLCD.print("," ,458, 457);
myGLCD.printNumI(vdat%100 ,458+16, 457);
myGLCD.print("v " ,458+64-16, 457);
if (hourd<10)
{myGLCD.print("0" ,474+64, 457);
myGLCD.printNumI(hourd,474+64+16, 457);
}
else
{ myGLCD.printNumI(hourd,474+64, 457);
}
myGLCD.print(":",474+64+32, 457);
if (mind<10)
{myGLCD.print("0",474+64+32+16, 457);
myGLCD.printNumI(mind,474+64+32+32, 457);
}
else
{ myGLCD.printNumI(mind,474+64+32+16, 457);
}
delay (1000);
}