main/task_sdcard.c

changeset 33
dd52aecfc19d
parent 26
373a33699605
child 54
7b134c27fadb
equal deleted inserted replaced
32:c3c2fd13cf3b 33:dd52aecfc19d
45 const int TASK_SDCARD_LOG_CLEAN = BIT0; ///< Clean spiffs logfile directory 45 const int TASK_SDCARD_LOG_CLEAN = BIT0; ///< Clean spiffs logfile directory
46 const int TASK_SDCARD_LOG_CLOSE = BIT1; ///< Close the logfile. 46 const int TASK_SDCARD_LOG_CLOSE = BIT1; ///< Close the logfile.
47 47
48 extern time_t now; 48 extern time_t now;
49 extern struct tm timeinfo; 49 extern struct tm timeinfo;
50 50 extern uint32_t TimeBrewing;
51 51
52 52
53 void log_begin(time_t t) 53 void log_begin(time_t t)
54 { 54 {
55 struct tm timeinfo; 55 struct tm timeinfo;
141 { 141 {
142 char filename[32]; 142 char filename[32];
143 char bordercolor[9], color[9], pos[8]; 143 char bordercolor[9], color[9], pos[8];
144 FILE *f; 144 FILE *f;
145 bool addcomma = true; 145 bool addcomma = true;
146 int Hour = (TimeBrewing / 3600);
147 int Minute = ((TimeBrewing % 3600) / 60);
146 148
147 if (strlen(sdcard_state->logfile)) { 149 if (strlen(sdcard_state->logfile)) {
148 sprintf(filename, "/spiffs/log/%s.anno", sdcard_state->logfile); 150 sprintf(filename, "/spiffs/log/%s.anno", sdcard_state->logfile);
149 151
150 switch (annotation_type) { 152 switch (annotation_type) {
170 addcomma = false; 172 addcomma = false;
171 } else { 173 } else {
172 fclose(f); 174 fclose(f);
173 } 175 }
174 176
177 snprintf(json_log->time, 8, "%02d:%02d", Hour, Minute);
175 f = fopen(filename, "a"); 178 f = fopen(filename, "a");
176 if (f) { 179 if (f) {
177 if (addcomma) { 180 if (addcomma) {
178 fprintf(f, ",\n"); 181 fprintf(f, ",\n");
179 } 182 }

mercurial