rusefi-1/firmware/emulation/analog_chart.cpp

64 lines
1.4 KiB
C++
Raw Normal View History

2014-08-29 07:52:33 -07:00
/**
2014-11-03 10:03:03 -08:00
* @file analog_chart.cpp
2014-08-29 07:52:33 -07:00
*
* @date Dec 20, 2013
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#include "main.h"
#include "analog_chart.h"
2014-11-03 10:03:03 -08:00
#include "rpm_calculator.h"
2014-08-29 07:52:33 -07:00
#include "status_loop.h"
#include "engine_configuration.h"
#if EFI_ANALOG_CHART || defined(__DOXYGEN__)
static char LOGGING_BUFFER[5000];
static Logging logging;
static int pendingData = FALSE;
static int initialized = FALSE;
extern engine_configuration_s *engineConfiguration;
void acAddData(float angle, float value) {
2014-09-11 19:02:53 -07:00
if (!initialized) {
2014-08-29 07:52:33 -07:00
return; // this is possible because of initialization sequence
2014-09-11 19:02:53 -07:00
}
2014-08-29 07:52:33 -07:00
2014-09-11 19:02:53 -07:00
if (engineConfiguration->analogChartFrequency < 1) {
2014-08-29 07:52:33 -07:00
//todofirmwareError()
return;
}
if (getRevolutionCounter() % engineConfiguration->analogChartFrequency != 0) {
if (pendingData) {
// message terminator
appendPrintf(&logging, DELIMETER);
// output pending data
if (getFullLog()) {
scheduleLogging(&logging);
2014-09-11 19:02:53 -07:00
}
2014-08-29 07:52:33 -07:00
pendingData = FALSE;
}
return;
}
if (!pendingData) {
pendingData = TRUE;
resetLogging(&logging);
// message header
appendPrintf(&logging, "analog_chart%s", DELIMETER);
}
2014-09-11 19:02:53 -07:00
if (remainingSize(&logging) > 100) {
2014-08-29 07:52:33 -07:00
appendPrintf(&logging, "%f|%f|", angle, value);
2014-09-11 19:02:53 -07:00
}
2014-08-29 07:52:33 -07:00
}
void initAnalogChart(void) {
initLoggingExt(&logging, "analog chart", LOGGING_BUFFER, sizeof(LOGGING_BUFFER));
initialized = TRUE;
}
#endif /* EFI_ANALOG_CHART */