rusefi-1/firmware/util/math/avg_values.h

28 lines
619 B
C

/*
* avg_values.h
*
* @date Jul 23, 2013
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#pragma once
#define AVG_TAB_SIZE 48
#define MAX_RPM 8000
#define MAX_KEY 5
typedef struct {
float values[AVG_TAB_SIZE][AVG_TAB_SIZE];
int counts[AVG_TAB_SIZE][AVG_TAB_SIZE];
} AvgTable;
void avgReset(AvgTable *table);
void avgFill(AvgTable *table, int count, float value);
void avgAddValue(AvgTable *table, int rpm, float key, float value);
float avgGetValueByIndexes(AvgTable *table, int i, int j);
float avgGetValue(AvgTable *table, int rpm, float key);
int avgGetValuesCount(AvgTable *table, int rpm, float key);