auto-sync

This commit is contained in:
rusEfi 2015-02-18 21:07:49 -06:00
parent a4129ffd10
commit b20e5e3d40
5 changed files with 23 additions and 6 deletions

View File

@ -356,7 +356,7 @@ static void getFloat(int offset) {
/**
* this response is part of dev console API
*/
scheduleMsg(&logger, "float @%d is %f", offset, value);
scheduleMsg(&logger, "float @%d is %..100000f", offset, value);
}
static void setFloat(const char *offsetStr, const char *valueStr) {

View File

@ -23,6 +23,8 @@
EXTERN_ENGINE
;
static Logging *logger;
static bool initialized = false;
/**
@ -131,24 +133,36 @@ void setThermistorConfiguration(ThermistorConf * tc, float tempC1, float r1, flo
}
void prepareThermistorCurve(ThermistorConf * config) {
efiAssertVoid(config!=NULL, "therm config");
float T1 = config->tempC_1 + KELV;
float T2 = config->tempC_2 + KELV;
float T3 = config->tempC_3 + KELV;
scheduleMsg(logger, "T1=%..100000f/T2=%..100000f/T3=%..100000f", T1, T2, T3);
float L1 = logf(config->resistance_1);
float L2 = logf(config->resistance_2);
float L3 = logf(config->resistance_3);
scheduleMsg(logger, "R1=%..100000f/R2=%..100000f/R3=%..100000f", config->resistance_1, config->resistance_2, config->resistance_3);
scheduleMsg(logger, "L1=%..100000f/L2=%..100000f/L3=%..100000f", L1, L2, L3);
float Y1 = 1 / T1;
float Y2 = 1 / T2;
float Y3 = 1 / T3;
scheduleMsg(logger, "Y1=%..100000f/Y2=%..100000f/Y3=%..100000f", Y1, Y2, Y3);
float U2 = (Y2 - Y1) / (L2 - L1);
float U3 = (Y3 - Y1) / (L3 - L1);
scheduleMsg(logger, "U2=%..100000f/U3=%..100000f", U2, U3);
config->s_h_c = (U3 - U2) / (L3 - L2) * pow(L1 + L2 + L3, -1);
config->s_h_b = U2 - config->s_h_c * (L1 * L1 + L1 * L2 + L2 * L2);
config->s_h_a = Y1 - (config->s_h_b + L1 * L1 * config->s_h_c) * L1;
scheduleMsg(logger, "s_h_c=%..100000f/s_h_b=%..100000f/s_h_a=%..100000f", config->s_h_c, config->s_h_b, config->s_h_a);
}
/**
@ -183,17 +197,19 @@ void setCommonNTCSensor(ThermistorConf *thermistorConf) {
setThermistorConfiguration(thermistorConf, -20, 18000, 23.8889, 2100, 120.0, 100.0);
}
static Logging *logger;
#if EFI_PROD_CODE
static void testCltByR(float resistance) {
Thermistor *thermistor = &engine->clt;
float kTemp = getKelvinTemperature(resistance, thermistor->config);
scheduleMsg(logger, "for R=%f we have %f", resistance, (kTemp - KELV));
initThermistorCurve(&engine->clt, &engine->engineConfiguration->clt, engine->engineConfiguration->cltAdcChannel);
}
#endif
void initThermistors(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) {
logger = sharedLogger;
efiAssertVoid(engine!=NULL, "e NULL initThermistors");
efiAssertVoid(engine->engineConfiguration2!=NULL, "e2 NULL initThermistors");
initThermistorCurve(&engine->clt, &engine->engineConfiguration->clt, engine->engineConfiguration->cltAdcChannel);

View File

@ -11,7 +11,7 @@
#include "main.h"
#define _5_VOLTS 5.0
#define KELV 273.15
#define KELV 273.15f
#include "sensor_types.h"
#include "engine.h"

View File

@ -1,5 +1,5 @@
// This file was generated by Version2Header
// Mon Feb 16 16:09:44 EST 2015
// Wed Feb 18 21:12:04 EST 2015
#ifndef VCS_VERSION
#define VCS_VERSION "6883"
#define VCS_VERSION "6940"
#endif

View File

@ -298,6 +298,7 @@ void printMsg(Logging *logger, const char *fmt, ...) {
* in order to reduce memory usage
*/
void scheduleMsg(Logging *logging, const char *fmt, ...) {
efiAssertVoid(logging != NULL, "logging NULL");
int wasLocked = lockAnyContext();
resetLogging(logging); // todo: is 'reset' really needed here?
appendMsgPrefix(logging);