reduce flash footprint by smarter code generation #4163
This commit is contained in:
parent
f50bada981
commit
15d7085bce
|
@ -6,6 +6,24 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
struct plain_get_integer_s {
|
||||||
|
const char *token;
|
||||||
|
int *value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct plain_get_short_s {
|
||||||
|
const char *token;
|
||||||
|
uint16_t *value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct plain_get_float_s {
|
||||||
|
const char *token;
|
||||||
|
float *value;
|
||||||
|
};
|
||||||
|
|
||||||
|
plain_get_float_s * findFloat(const char *name);
|
||||||
|
|
||||||
float getConfigValueByName(const char *name);
|
float getConfigValueByName(const char *name);
|
||||||
void setConfigValueByName(const char *name, float value);
|
void setConfigValueByName(const char *name, float value);
|
||||||
float getOutputValueByName(const char *name);
|
float getOutputValueByName(const char *name);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "idle_thread.h"
|
#include "idle_thread.h"
|
||||||
#include "alternator_controller.h"
|
#include "alternator_controller.h"
|
||||||
#include "trigger_emulator_algo.h"
|
#include "trigger_emulator_algo.h"
|
||||||
|
#include "value_lookup.h"
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
#include "rtc_helper.h"
|
#include "rtc_helper.h"
|
||||||
|
@ -840,29 +841,13 @@ static void printAllInfo() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
struct plain_get_integer_s {
|
|
||||||
const char *token;
|
|
||||||
int *value;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct plain_get_short_s {
|
|
||||||
const char *token;
|
|
||||||
uint16_t *value;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct plain_get_float_s {
|
|
||||||
const char *token;
|
|
||||||
float *value;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#if ! EFI_UNIT_TEST
|
#if ! EFI_UNIT_TEST
|
||||||
const plain_get_short_s getS_plain[] = {
|
const plain_get_short_s getS_plain[] = {
|
||||||
{"idle_pid_min", (uint16_t *)&engineConfiguration->idleRpmPid.minValue},
|
{"idle_pid_min", (uint16_t *)&engineConfiguration->idleRpmPid.minValue},
|
||||||
{"idle_pid_max", (uint16_t *)&engineConfiguration->idleRpmPid.maxValue},
|
{"idle_pid_max", (uint16_t *)&engineConfiguration->idleRpmPid.maxValue},
|
||||||
};
|
};
|
||||||
|
|
||||||
const plain_get_integer_s getI_plain[] = {
|
static plain_get_integer_s getI_plain[] = {
|
||||||
// {"cranking_rpm", &engineConfiguration->cranking.rpm},
|
// {"cranking_rpm", &engineConfiguration->cranking.rpm},
|
||||||
// {"cranking_injection_mode", setCrankingInjectionMode},
|
// {"cranking_injection_mode", setCrankingInjectionMode},
|
||||||
// {"injection_mode", setInjectionMode},
|
// {"injection_mode", setInjectionMode},
|
||||||
|
@ -891,7 +876,7 @@ const plain_get_integer_s getI_plain[] = {
|
||||||
// {"idle_rpm", setTargetIdleRpm},
|
// {"idle_rpm", setTargetIdleRpm},
|
||||||
};
|
};
|
||||||
|
|
||||||
const plain_get_float_s getF_plain[] = {
|
static plain_get_float_s getF_plain[] = {
|
||||||
{"adcVcc", &engineConfiguration->adcVcc},
|
{"adcVcc", &engineConfiguration->adcVcc},
|
||||||
{"cranking_dwell", &engineConfiguration->ignitionDwellForCrankingMs},
|
{"cranking_dwell", &engineConfiguration->ignitionDwellForCrankingMs},
|
||||||
{"idle_position", &engineConfiguration->manIdlePosition},
|
{"idle_position", &engineConfiguration->manIdlePosition},
|
||||||
|
@ -906,27 +891,44 @@ const plain_get_float_s getF_plain[] = {
|
||||||
#endif /* EFI_UNIT_TEST */
|
#endif /* EFI_UNIT_TEST */
|
||||||
|
|
||||||
|
|
||||||
|
static plain_get_float_s * findFloat2(const char *name) {
|
||||||
|
plain_get_float_s *currentF = &getF_plain[0];
|
||||||
|
while (currentF < getF_plain + sizeof(getF_plain)/sizeof(getF_plain[0])) {
|
||||||
|
if (strEqualCaseInsensitive(name, currentF->token)) {
|
||||||
|
return currentF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static plain_get_integer_s *findInt(const char *name) {
|
||||||
|
plain_get_integer_s *currentI = &getI_plain[0];
|
||||||
|
while (currentI < getI_plain + sizeof(getI_plain)/sizeof(getI_plain[0])) {
|
||||||
|
if (strEqualCaseInsensitive(name, currentI->token)) {
|
||||||
|
return currentI;
|
||||||
|
}
|
||||||
|
currentI++;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
static void getValue(const char *paramStr) {
|
static void getValue(const char *paramStr) {
|
||||||
#if ! EFI_UNIT_TEST
|
#if ! EFI_UNIT_TEST
|
||||||
{
|
{
|
||||||
const plain_get_integer_s *currentI = &getI_plain[0];
|
plain_get_integer_s *known = findInt(paramStr);
|
||||||
while (currentI < getI_plain + sizeof(getI_plain)/sizeof(getI_plain[0])) {
|
if (known != nullptr) {
|
||||||
if (strEqualCaseInsensitive(paramStr, currentI->token)) {
|
efiPrintf("%s value: %d", known->token, *known->value);
|
||||||
efiPrintf("%s value: %d", currentI->token, *currentI->value);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
currentI++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const plain_get_float_s *currentF = &getF_plain[0];
|
{
|
||||||
while (currentF < getF_plain + sizeof(getF_plain)/sizeof(getF_plain[0])) {
|
plain_get_float_s * known = findFloat2(paramStr);
|
||||||
if (strEqualCaseInsensitive(paramStr, currentF->token)) {
|
if (known != nullptr) {
|
||||||
float value = *currentF->value;
|
float value = *known->value;
|
||||||
efiPrintf("%s value: %.2f", currentF->token, value);
|
efiPrintf("%s value: %.2f", known->token, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentF++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue