auto-sync

This commit is contained in:
rusEfi 2015-07-11 16:01:31 -04:00
parent dcd8652842
commit 5fc54f3101
5 changed files with 12 additions and 13 deletions

View File

@ -55,8 +55,6 @@
#include "settings.h"
#include "rusefi_outputs.h"
extern float knockVolts;
extern bool_t main_loop_started;
#if EFI_PROD_CODE || defined(__DOXYGEN__)
@ -187,7 +185,7 @@ static void printSensors(Logging *log, bool fileFormat) {
#endif /* EFI_PROD_CODE */
reportSensorF(log, fileFormat, "ks", "count", engine->knockCount, 0);
reportSensorF(log, fileFormat, "kv", "v", knockVolts, 2);
reportSensorF(log, fileFormat, "kv", "v", engine->knockVolts, 2);
// reportSensorF(log, fileFormat, "vref", "V", getVRef(engineConfiguration), 2);
@ -595,7 +593,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->baroCorrection = engine->engineState.baroCorrection;
tsOutputChannels->pedalPosition = getPedalPosition(PASS_ENGINE_PARAMETER_F);
tsOutputChannels->knockCount = engine->knockCount;
tsOutputChannels->knockLevel = knockVolts;
tsOutputChannels->knockLevel = engine->knockVolts;
tsOutputChannels->injectorDutyCycle = getInjectorDutyCycle(rpm PASS_ENGINE_PARAMETER);
tsOutputChannels->fuelLevel = engine->engineState.fuelLevel;
tsOutputChannels->hasFatalError = hasFirmwareError();

View File

@ -85,6 +85,8 @@ Engine::Engine(persistent_config_s *config) {
knockEver = false;
knockCount = 0;
knockDebug = false;
knockVolts = 0;
timeOfLastKnockEvent = 0;
injectorLagMs = fuelMs = 0;
clutchDownState = clutchUpState = false;
@ -144,6 +146,7 @@ void Engine::printKnockState(void) {
}
void Engine::knockLogic(float knockVolts) {
this->knockVolts = knockVolts;
knockNow = knockVolts > engineConfiguration->knockVThreshold;
/**
* KnockCount is directly proportional to the degrees of ignition

View File

@ -211,6 +211,8 @@ public:
*/
int knockCount;
float knockVolts;
bool_t knockDebug;
efitimeus_t timeOfLastKnockEvent;

View File

@ -33,8 +33,6 @@ static MenuItem ROOT(NULL, NULL);
static MenuTree tree(&ROOT);
extern float knockVolts; // todo: nicer getter
static MenuItem miRpm(tree.root, LL_RPM);
static MenuItem miSensors(tree.root, "sensors");
static MenuItem miBench(tree.root, "bench test");
@ -239,7 +237,7 @@ static void showLine(lcd_line_e line, int screenY) {
return;
case LL_KNOCK:
getPinNameByAdcChannel(engineConfiguration->hipOutputChannel, buffer);
lcdPrintf("Knock %s %fv", buffer, knockVolts);
lcdPrintf("Knock %s %fv", buffer, engine->knockVolts);
return;
#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)

View File

@ -58,8 +58,6 @@ static int settingUpdateCount = 0;
static int totalKnockEventsCount = 0;
static int currentPrescaler;
static float hipValueMax = 0;
// todo: move this to engine state
float knockVolts = 0;
static int spiCount = 0;
static unsigned char tx_buff[1];
@ -150,7 +148,7 @@ static void showHipInfo(void) {
scheduleMsg(logger, "CS@%s updateCount=%d", hwPortname(boardConfiguration->hip9011CsPin), settingUpdateCount);
scheduleMsg(logger, "hip %fv/last=%f@%s/max=%f spiCount=%d adv=%d",
knockVolts,
engine->knockVolts,
getVoltage("hipinfo", engineConfiguration->hipOutputChannel),
getPinNameByAdcChannel(engineConfiguration->hipOutputChannel, pinNameBuffer),
hipValueMax,
@ -274,9 +272,9 @@ void hipAdcCallback(adcsample_t value) {
if (state == WAITING_FOR_ADC_TO_SKIP) {
state = WAITING_FOR_RESULT_ADC;
} else if (state == WAITING_FOR_RESULT_ADC) {
knockVolts = adcToVoltsDivided(value);
hipValueMax = maxF(knockVolts, hipValueMax);
engine->knockLogic(knockVolts);
engine->knockVolts = adcToVoltsDivided(value);
hipValueMax = maxF(engine->knockVolts, hipValueMax);
engine->knockLogic(engine->knockVolts);
float angleWindowWidth =
engineConfiguration->knockDetectionWindowEnd - engineConfiguration->knockDetectionWindowStart;