auto-sync

This commit is contained in:
rusEfi 2016-01-20 17:01:53 -05:00
parent 3040ec3995
commit fbf8510ad6
5 changed files with 29 additions and 35 deletions

View File

@ -29,7 +29,7 @@ typedef struct {
typedef struct {
// primary instrument cluster gauges
int rpm; // size 4, offset 0
float coolant_temperature; // size 4, offset 4
float coolantTemperature; // size 4, offset 4
float intakeAirTemperature; // size 4, offset 8
float throttlePositon; // size 4, offset 12
float massAirFlowVoltage; // size 4, offset 16
@ -39,7 +39,7 @@ typedef struct {
short int tpsADC; // size 2, offset 32
short int alignment; // size 2, offset 34
float baroPressure; // size 4, offset 36
float manifold_air_pressure; // size 4, offset 40
float manifoldAirPressure; // size 4, offset 40
float crankingFuelMs;
/**
* This is the raw value we take from the fuel map or base fuel algorithm, before the corrections
@ -53,16 +53,16 @@ typedef struct {
* With all corrections. See also baseFuel
*/
float pulseWidthMs; // 64
float warmUpEnrich; // 68
float unused68; // 68
/**
* Yes, I do not really enjoy packing bits into integers but we simply have too many boolean flags and I cannot
* water 4 bytes per traffic - I want gauges to work as fast as possible
*/
unsigned int hasSdCard : 1; // bit 0
unsigned int isIgnitionEnabled : 1; // bit 1
unsigned int injection_enabled : 1; // bit 2
unsigned int cylinder_cleanup_enabled : 1; // bit 3
unsigned int cylinder_cleanup_activated : 1; // bit 4
unsigned int isInjectionEnabled : 1; // bit 2
unsigned int isCylinderCleanupEnabled : 1; // bit 3
unsigned int isCylinderCleanupActivated : 1; // bit 4
unsigned int isFuelPumpOn : 1; // bit 5
unsigned int isFanOn : 1; // bit 6
unsigned int isO2HeaterOn : 1; // bit 7
@ -84,7 +84,7 @@ typedef struct {
int tsConfigVersion;
egt_values_s egtValues;
float rpmAcceleration;
float massAirFlowValue;
float massAirFlow;
float veValue; // current volumetric efficiency, offset 112
/**
* TPS value delta within specified number of cycles

View File

@ -357,7 +357,7 @@ void updateDevConsoleState(Engine *engine) {
#endif
#if (EFI_PROD_CODE && HAL_USE_ADC) || defined(__DOXYGEN__)
pokeAdcInputs();
printFullAdcReportIfNeeded();
#endif
if (!fullLog) {
@ -574,11 +574,11 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
// engine state
tsOutputChannels->rpm = rpm;
tsOutputChannels->coolant_temperature = coolant;
tsOutputChannels->coolantTemperature = coolant;
tsOutputChannels->intakeAirTemperature = intake;
tsOutputChannels->throttlePositon = tps;
tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMaf() : 0;
tsOutputChannels->massAirFlowValue = hasMafSensor() ? getRealMaf() : 0;
tsOutputChannels->massAirFlow = hasMafSensor() ? getRealMaf() : 0;
tsOutputChannels->veValue = veMap.getValue(getMap(), rpm);
tsOutputChannels->currentTargetAfr = afrMap.getValue(getMap(), rpm);
@ -590,7 +590,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
tsOutputChannels->baroPressure = hasBaroSensor() ? getBaroPressure() : 0;
#endif /* EFI_ANALOG_SENSORS */
tsOutputChannels->manifold_air_pressure = getMap();
tsOutputChannels->manifoldAirPressure = getMap();
tsOutputChannels->engineLoad = engineLoad;
tsOutputChannels->rpmAcceleration = engine->rpmCalculator.getRpmAcceleration();
tsOutputChannels->deltaTps = engine->tpsAccelEnrichment.getDelta();
@ -634,9 +634,9 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->isFanOn = enginePins.fanRelay.getLogicValue();
tsOutputChannels->isO2HeaterOn = enginePins.o2heater.getLogicValue();
tsOutputChannels->isIgnitionEnabled = engineConfiguration->isIgnitionEnabled;
tsOutputChannels->injection_enabled = engineConfiguration->isInjectionEnabled;
tsOutputChannels->cylinder_cleanup_enabled = engineConfiguration->isCylinderCleanupEnabled;
tsOutputChannels->cylinder_cleanup_activated = engine->isCylinderCleanupMode;
tsOutputChannels->isInjectionEnabled = engineConfiguration->isInjectionEnabled;
tsOutputChannels->isCylinderCleanupEnabled = engineConfiguration->isCylinderCleanupEnabled;
tsOutputChannels->isCylinderCleanupActivated = engine->isCylinderCleanupMode;
tsOutputChannels->secondTriggerChannelEnabled = engineConfiguration->secondTriggerChannelEnabled;
#if EFI_VEHICLE_SPEED || defined(__DOXYGEN__)
tsOutputChannels->vehicleSpeedKph = getVehicleSpeed();

View File

@ -105,6 +105,9 @@ extern WallFuel wallFuel;
static ALWAYS_INLINE void handleFuelInjectionEvent(bool limitedFuel, InjectionEvent *event,
int rpm DECLARE_ENGINE_PARAMETER_S) {
if (limitedFuel)
return; // todo: move this check up
/**
* todo: this is a bit tricky with batched injection. is it? Does the same
* wetting coefficient works the same way for any injection mode, or is something
@ -147,16 +150,12 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(bool limitedFuel, InjectionEv
scheduling_s * sUp = &signal->signalTimerUp[index];
scheduling_s * sDown = &signal->signalTimerDown[index];
if (!limitedFuel) {
scheduleTask("out up", sUp, (int) injectionStartDelayUs, (schfunc_t) &startSimultaniousInjection, engine);
scheduleTask("out down", sDown, (int) injectionStartDelayUs + MS2US(injectionDuration),
scheduleTask("out up", sUp, (int) injectionStartDelayUs, (schfunc_t) &startSimultaniousInjection, engine);
scheduleTask("out down", sDown, (int) injectionStartDelayUs + MS2US(injectionDuration),
(schfunc_t) &endSimultaniousInjection, engine);
}
} else {
if (!limitedFuel) {
scheduleOutput(&event->actuator, getTimeNowUs(), injectionStartDelayUs, MS2US(injectionDuration));
}
scheduleOutput(&event->actuator, getTimeNowUs(), injectionStartDelayUs, MS2US(injectionDuration));
}
}

View File

@ -15,7 +15,7 @@
#if HAL_USE_ADC || defined(__DOXYGEN__)
#include "engine_configuration.h"
#include "engine.h"
#include "adc_inputs.h"
#include "AdcConfiguration.h"
#include "mpu_util.h"
@ -64,9 +64,10 @@ AdcDevice::AdcDevice(ADCConversionGroup* hwConfig) {
static char LOGGING_BUFFER[500];
static Logging logger("ADC", LOGGING_BUFFER, sizeof(LOGGING_BUFFER));
static int adcCallbackCounter_slow = 0;
static int adcSlowCallbackCounter = 0;
static int adcDebugReporting = FALSE;
// todo: move this flag to Engine god object
static int adcDebugReporting = false;
extern engine_configuration_s *engineConfiguration;
extern board_configuration_s *boardConfiguration;
@ -441,13 +442,9 @@ static void printFullAdcReport(void) {
}
}
static void printStatus(void) {
scheduleMsg(&logger, "adcDebug=%d", adcDebugReporting);
}
static void setAdcDebugReporting(int value) {
adcDebugReporting = value;
printStatus();
scheduleMsg(&logger, "adcDebug=%d", adcDebugReporting);
}
static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
@ -459,7 +456,7 @@ static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
if (adcp->state == ADC_COMPLETE) {
/* Calculates the average values from the ADC samples.*/
adcCallbackCounter_slow++;
adcSlowCallbackCounter++;
// newState.time = chimeNow();
for (int i = 0; i < slowAdc.size(); i++) {
@ -511,9 +508,7 @@ void initAdcInputs(bool boardTestMode) {
configureInputs();
printStatus();
// migrate to 'enable adcdebug'
addConsoleActionI("adcDebug", &setAdcDebugReporting);
#if EFI_INTERNAL_ADC
@ -572,7 +567,7 @@ void initAdcInputs(bool boardTestMode) {
#endif
}
void pokeAdcInputs() {
void printFullAdcReportIfNeeded(void) {
if (!adcDebugReporting)
return;
printFullAdcReport();

View File

@ -23,7 +23,7 @@ adc_channel_e getAdcChannel(brain_pin_e pin);
int getAdcHardwareIndexByInternalIndex(int index);
void pokeAdcInputs(void);
void printFullAdcReportIfNeeded(void);
int getInternalAdcValue(const char *msg, adc_channel_e index);
/* Depth of the conversion buffer, channels are sampled X times each.*/