auto-sync

This commit is contained in:
rusEfi 2014-11-24 12:04:56 -06:00
parent 1391eb4847
commit 740eec2bd1
6 changed files with 48 additions and 3 deletions

View File

@ -16,6 +16,7 @@
#include "engine_configuration.h"
#include "event_registry.h"
#include "trigger_structure.h"
#include "table_helper.h"
class FuelSchedule {
public:
@ -49,6 +50,12 @@ public:
FuelSchedule crankingInjectionEvents;
FuelSchedule injectionEvents;
float sparkAtable[DWELL_CURVE_SIZE];
float sparkBtable[DWELL_CURVE_SIZE];
Table2D sparkTable;
void precalc();
/**
* We are alternating two event lists in order to avoid a potential issue around revolution boundary
* when an event is scheduled within the next revolution.

View File

@ -572,6 +572,12 @@ engine_configuration2_s::engine_configuration2_s() {
engineConfiguration = NULL;
}
void engine_configuration2_s::precalc() {
//sparkTable.init()
//engineConfiguration->sparkDwellBins, engineConfiguration->sparkDwell, DWELL_CURVE_SIZE);
}
void applyNonPersistentConfiguration(Logging * logger, Engine *engine) {
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;

View File

@ -15,11 +15,8 @@
#include "main.h"
#include "interpolation.h"
#define INTERPOLATION_A(x1, y1, x2, y2) ((y1 - y2) / (x1 - x2))
int needInterpolationLogging = TRUE;
FastInterpolation::FastInterpolation(float x1, float y1, float x2, float y2) {
init(x1, y1, x2, y2);
}

View File

@ -8,6 +8,8 @@
#ifndef INTERPOLATION_3D_H_
#define INTERPOLATION_3D_H_
#define INTERPOLATION_A(x1, y1, x2, y2) ((y1 - y2) / (x1 - x2))
int findIndex(float array[], int size, float value);
float interpolate(float x1, float y1, float x2, float y2, float x);
float interpolate2d(float value, float bin[], float values[], int size);

View File

@ -20,6 +20,29 @@ void setTableBin2(float array[], int size, float l, float r, float precision) {
}
}
void Table2D::init(int size, float *aTable, float *bTable) {
this->size = size;
this->aTable = aTable;
this->bTable = bTable;
}
void Table2D::preCalc(float *bin, float *values) {
for (int i = 0; i < size - 1; i++) {
float x1 = bin[i];
float x2 = bin[i + 1];
if (x1 == x2) {
firmwareError("Same x1 and x2 in interpolate: %f/%f", x1, x2);
return;
}
float y1 = values[i];
float y2 = values[i + 1];
aTable[i] = INTERPOLATION_A(x1, y1, x2, y2);
bTable[i] = y1 - aTable[i] * x1;
}
}
void setTableBin(float array[], int size, float l, float r) {
setTableBin2(array, size, l, r, 0.01);
}

View File

@ -9,6 +9,7 @@
#include <math.h>
#include "error_handling.h"
#include "interpolation.h"
// 'random' value to be sure we are not treating any non-zero trash as TRUE
#define MAGIC_TRUE_VALUE 153351512
@ -24,6 +25,15 @@ private:
int initialized;
};
class Table2D {
public:
void init(int size, float *aTable, float *bTable);
void preCalc(float *bin, float *values);
int size;
float *aTable;
float *bTable;
};
template<int RPM_BIN_SIZE, int LOAD_BIN_SIZE>
void Map3D<RPM_BIN_SIZE, LOAD_BIN_SIZE>::init(float table[RPM_BIN_SIZE][LOAD_BIN_SIZE]) {
for (int k = 0; k < LOAD_BIN_SIZE; k++) {