protegemed, aquisição via A/D simples utilizando interrupção do timer

Dependencies:   EthernetInterface NTPClient mbed-rtos mbed

Fork of ptgm_semDMA by Marcelo Rebonatto

Committer:
rebonatto
Date:
Tue Jan 05 11:47:35 2016 +0000
Revision:
0:fac116e94d44
Vers?o est?vel sem DMA e FFT. 128 amostras.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rebonatto 0:fac116e94d44 1 /*
rebonatto 0:fac116e94d44 2 * Settings.cpp
rebonatto 0:fac116e94d44 3 *
rebonatto 0:fac116e94d44 4 * Created on: 19/jan/2015
rebonatto 0:fac116e94d44 5 * Author: Marcos A. Lucas
rebonatto 0:fac116e94d44 6 */
rebonatto 0:fac116e94d44 7
rebonatto 0:fac116e94d44 8 #include "PmedLog.h"
rebonatto 0:fac116e94d44 9
rebonatto 0:fac116e94d44 10 int PmedLog::m_entry = 0;
rebonatto 0:fac116e94d44 11 time_t PmedLog::m_lastMark = 0;
rebonatto 0:fac116e94d44 12
rebonatto 0:fac116e94d44 13 void PmedLog::WriteEntry(const char *value)
rebonatto 0:fac116e94d44 14 {
rebonatto 0:fac116e94d44 15 time_t seconds = time(NULL);
rebonatto 0:fac116e94d44 16
rebonatto 0:fac116e94d44 17 char buffer[32];
rebonatto 0:fac116e94d44 18 strftime(buffer, 32, "%T", localtime(&seconds));
rebonatto 0:fac116e94d44 19
rebonatto 0:fac116e94d44 20 printf("LOG : %s : %.5d : %s \n", buffer, m_entry, value);
rebonatto 0:fac116e94d44 21
rebonatto 0:fac116e94d44 22 FILE *f = fopen(LOGFILE,"a");
rebonatto 0:fac116e94d44 23
rebonatto 0:fac116e94d44 24 if(f == NULL)
rebonatto 0:fac116e94d44 25 {
rebonatto 0:fac116e94d44 26 printf("Error creating log file\r\n");
rebonatto 0:fac116e94d44 27 return;
rebonatto 0:fac116e94d44 28 }
rebonatto 0:fac116e94d44 29
rebonatto 0:fac116e94d44 30 fprintf(f, "%s : %.5d : %s\n", buffer, m_entry, value);
rebonatto 0:fac116e94d44 31
rebonatto 0:fac116e94d44 32 fclose(f);
rebonatto 0:fac116e94d44 33
rebonatto 0:fac116e94d44 34 m_entry++;
rebonatto 0:fac116e94d44 35 }
rebonatto 0:fac116e94d44 36
rebonatto 0:fac116e94d44 37 void PmedLog::Mark()
rebonatto 0:fac116e94d44 38 {
rebonatto 0:fac116e94d44 39 if (!get_LogMarks()) return;
rebonatto 0:fac116e94d44 40
rebonatto 0:fac116e94d44 41 time_t seconds = time(NULL);
rebonatto 0:fac116e94d44 42 time_t difference = seconds - m_lastMark;
rebonatto 0:fac116e94d44 43
rebonatto 0:fac116e94d44 44 if ( difference >= get_LogMarksInterval() ) {
rebonatto 0:fac116e94d44 45 m_lastMark = seconds;
rebonatto 0:fac116e94d44 46 WriteEntry(" . -- === MARK === -- . ");
rebonatto 0:fac116e94d44 47 }
rebonatto 0:fac116e94d44 48 }