diff --git a/firmware/controllers/lua/value_lookup.h b/firmware/controllers/lua/value_lookup.h index 94fd5152c6..b7a27163cb 100644 --- a/firmware/controllers/lua/value_lookup.h +++ b/firmware/controllers/lua/value_lookup.h @@ -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 +T* findPair(const char *name, T array[], size_t count) { + for (int i = 0;itoken)) { + return current; + } + } + return nullptr; +} + plain_get_float_s * findFloat(const char *name); float getConfigValueByName(const char *name); diff --git a/unit_tests/tests/lua/test_lookup.cpp b/unit_tests/tests/lua/test_lookup.cpp index f950615585..e3b94a4d14 100644 --- a/unit_tests/tests/lua/test_lookup.cpp +++ b/unit_tests/tests/lua/test_lookup.cpp @@ -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)); + } }