reduce flash footprint by smarter code generation #4163

This commit is contained in:
rusefillc 2022-05-16 00:00:47 -04:00
parent fcf9997a75
commit 458b92e6d9
2 changed files with 22 additions and 0 deletions

View File

@ -17,11 +17,27 @@ struct plain_get_short_s {
uint16_t *value;
};
struct plain_get_u8_s {
const char *token;
uint8_t *value;
};
struct plain_get_float_s {
const char *token;
float *value;
};
template<typename T>
T* findPair(const char *name, T array[], size_t count) {
for (int i = 0;i<count;i++) {
T *current = &array[i];
if (strEqualCaseInsensitive(name, current->token)) {
return current;
}
}
return nullptr;
}
plain_get_float_s * findFloat(const char *name);
float getConfigValueByName(const char *name);

View File

@ -24,4 +24,10 @@ TEST(LuaBasic, configLookup) {
setConfigValueByName(name, 103);
ASSERT_EQ(103.0, getConfigValueByName(name));
}
{
const char * name = "multisparkMaxSparkingAngle";
setConfigValueByName(name, 13);
ASSERT_EQ(13.0, getConfigValueByName(name));
}
}