slow down the temperatur log to file

This commit is contained in:
phyto 2019-04-10 17:13:54 +02:00
parent 6583891486
commit 32f7e6ad70
1 changed files with 14 additions and 6 deletions

20
essai.c
View File

@ -24,7 +24,8 @@ char ligne[200];
int Idatas[4]; int Idatas[4];
float Fdatas[4]; float Fdatas[4];
FILE *fp; FILE *fp;
time_t temps; time_t temps,
old_temps = (time_t)0L;
/* XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX */ /* XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX */
@ -53,18 +54,25 @@ for (idx=0; idx<nbloops; idx++) {
for (foo=0; foo<3; foo++) { for (foo=0; foo<3; foo++) {
sprintf(ligne, "%4d", Idatas[foo]); sprintf(ligne, "%4d", Idatas[foo]);
minidigit_affstr(stdscr, 6+(12*foo), 8, ligne); minidigit_affstr(stdscr, 12+(12*foo), 8, ligne);
aff7segs_float(stdscr, 3+(12*foo), 55, Fdatas[foo]); aff7segs_float(stdscr, 8+(12*foo), 55, Fdatas[foo]);
} }
/* here we are trying to log all that temps values */
if (NULL!=fp) { if (NULL!=fp) {
temps = time(NULL); temps = time(NULL);
fprintf(fp, "%ld %f %f %f %f\n", temps, if ((temps-old_temps) > 60) {
Fdatas[0], Fdatas[1], Fdatas[2], Fdatas[3]); fprintf(fp, "%ld %f %f %f %f\n", temps,
fflush(fp); Fdatas[0], Fdatas[1], Fdatas[2], Fdatas[3]);
fflush(fp);
old_temps = temps;
}
} }
} }
fclose(fp);
return 0; return 0;
} }
/* --------------------------------------------------------------- */ /* --------------------------------------------------------------- */