reduce flash footprint by smarter code generation #4163
This commit is contained in:
parent
fcf9997a75
commit
458b92e6d9
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue