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
|
2015-01-12 15:04:10 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2015
|
2014-08-29 07:52:33 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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
|
|
|
}
|
2015-01-19 07:03:57 -08:00
|
|
|
pendingData = false;
|
2014-08-29 07:52:33 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!pendingData) {
|
2015-01-19 07:03:57 -08:00
|
|
|
pendingData = true;
|
2014-08-29 07:52:33 -07:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-01-19 07:03:57 -08:00
|
|
|
static void setAnalogChartFrequency(int value) {
|
|
|
|
engineConfiguration->analogChartFrequency = value;
|
|
|
|
}
|
|
|
|
|
2014-08-29 07:52:33 -07:00
|
|
|
void initAnalogChart(void) {
|
|
|
|
initLoggingExt(&logging, "analog chart", LOGGING_BUFFER, sizeof(LOGGING_BUFFER));
|
2015-01-19 07:03:57 -08:00
|
|
|
|
|
|
|
addConsoleActionI("set_analog_chart_freq", setAnalogChartFrequency);
|
|
|
|
|
|
|
|
initialized = true;
|
2014-08-29 07:52:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* EFI_ANALOG_CHART */
|