Add support for analogs with name different from tag

This commit is contained in:
Raphael Coeffic
2021-12-31 10:53:09 +01:00
parent 91ea5998b7
commit ac3e2a7c88
7 changed files with 120 additions and 111 deletions
@@ -178,3 +178,20 @@ void Firmware::addOptionsGroup(const OptionsGroup & options)
{
this->opts.append(options);
}
int Firmware::getAnalogInputIndex(const char * tag)
{
const StringTagMappingTable& lut = analogInputNamesLookupTable;
auto it =
find_if(lut.begin(), lut.end(), [=](const StringTagMapping& elmt) {
if (elmt.tag == tag) return true;
return false;
});
if (it != lut.end()) {
return it - lut.begin();
}
return -1;
}