Move cyc source to firmware
This commit is contained in:
committed by
Raphael Coeffic
parent
4c92f9dbc9
commit
ac9ce745bd
@@ -31,16 +31,6 @@ const YamlLookupTable trimSourceLut = {
|
|||||||
{ 5, "TrimT6" },
|
{ 5, "TrimT6" },
|
||||||
};
|
};
|
||||||
|
|
||||||
// SOURCE_TYPE_CYC
|
|
||||||
const YamlLookupTable cycSourceLut = {
|
|
||||||
{ 0, "CYC1" },
|
|
||||||
{ 1, "CYC2" },
|
|
||||||
{ 2, "CYC3" },
|
|
||||||
};
|
|
||||||
|
|
||||||
// SOURCE_TYPE_MAX
|
|
||||||
// { MIXSRC_MAX, "MAX" },
|
|
||||||
|
|
||||||
std::string YamlRawSourceEncode(const RawSource& rhs)
|
std::string YamlRawSourceEncode(const RawSource& rhs)
|
||||||
{
|
{
|
||||||
std::string src_str;
|
std::string src_str;
|
||||||
@@ -74,7 +64,7 @@ std::string YamlRawSourceEncode(const RawSource& rhs)
|
|||||||
src_str += ")";
|
src_str += ")";
|
||||||
break;
|
break;
|
||||||
case SOURCE_TYPE_CYC:
|
case SOURCE_TYPE_CYC:
|
||||||
src_str = YAML::LookupValue(cycSourceLut, rhs.index);
|
src_str = getCurrentFirmware()->getRawSourceCyclicTag(rhs.index);
|
||||||
break;
|
break;
|
||||||
case SOURCE_TYPE_PPM:
|
case SOURCE_TYPE_PPM:
|
||||||
src_str += "tr(";
|
src_str += "tr(";
|
||||||
@@ -236,10 +226,10 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
|||||||
rhs.index = conv.as<int>();
|
rhs.index = conv.as<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
conv = node >> cycSourceLut;
|
int cyc_idx = getCurrentFirmware()->getRawSourceCyclicIndex(src_str.c_str());
|
||||||
if (conv.IsScalar()) {
|
if (cyc_idx >= 0) {
|
||||||
rhs.type = SOURCE_TYPE_CYC;
|
rhs.type = SOURCE_TYPE_CYC;
|
||||||
rhs.index = conv.as<int>();
|
rhs.index = cyc_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sp_idx = getCurrentFirmware()->getRawSourceSpecialTypesIndex(src_str.c_str());
|
int sp_idx = getCurrentFirmware()->getRawSourceSpecialTypesIndex(src_str.c_str());
|
||||||
|
|||||||
@@ -308,3 +308,29 @@ std::string Firmware::getRawSourceSpecialTypesTag(unsigned int index)
|
|||||||
|
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Firmware::getRawSourceCyclicIndex(const char * tag)
|
||||||
|
{
|
||||||
|
const StringTagMappingTable& lut = rawSourceCyclicLookupTable;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Firmware::getRawSourceCyclicTag(unsigned int index)
|
||||||
|
{
|
||||||
|
const StringTagMappingTable& lut = rawSourceCyclicLookupTable;
|
||||||
|
if (index < lut.size())
|
||||||
|
return lut[index].tag;
|
||||||
|
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
|||||||
@@ -295,7 +295,8 @@ class Firmware
|
|||||||
switchesLookupTable(Boards::getSwitchesLookupTable(board)),
|
switchesLookupTable(Boards::getSwitchesLookupTable(board)),
|
||||||
trimSwitchesLookupTable(Boards::getTrimSwitchesLookupTable(board)),
|
trimSwitchesLookupTable(Boards::getTrimSwitchesLookupTable(board)),
|
||||||
rawSwitchTypesLookupTable(RawSwitch::getRawSwitchTypesLookupTable()),
|
rawSwitchTypesLookupTable(RawSwitch::getRawSwitchTypesLookupTable()),
|
||||||
rawSourceSpecialTypesLookupTable(RawSource::getSpecialTypesLookupTable())
|
rawSourceSpecialTypesLookupTable(RawSource::getSpecialTypesLookupTable()),
|
||||||
|
rawSourceCyclicLookupTable(RawSource::getCyclicLookupTable())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,6 +430,11 @@ class Firmware
|
|||||||
return &rawSourceSpecialTypesLookupTable;
|
return &rawSourceSpecialTypesLookupTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const StringTagMappingTable* getRawSourceCyclicLookupTable()
|
||||||
|
{
|
||||||
|
return &rawSourceCyclicLookupTable;
|
||||||
|
}
|
||||||
|
|
||||||
int getAnalogInputIndex(const char * tag);
|
int getAnalogInputIndex(const char * tag);
|
||||||
std::string getAnalogInputTag(unsigned int index);
|
std::string getAnalogInputTag(unsigned int index);
|
||||||
int getSwitchesIndex(const char * tag);
|
int getSwitchesIndex(const char * tag);
|
||||||
@@ -439,6 +445,8 @@ class Firmware
|
|||||||
std::string getRawSwitchTypesTag(unsigned int index);
|
std::string getRawSwitchTypesTag(unsigned int index);
|
||||||
int getRawSourceSpecialTypesIndex(const char * tag);
|
int getRawSourceSpecialTypesIndex(const char * tag);
|
||||||
std::string getRawSourceSpecialTypesTag(unsigned int index);
|
std::string getRawSourceSpecialTypesTag(unsigned int index);
|
||||||
|
int getRawSourceCyclicIndex(const char * tag);
|
||||||
|
std::string getRawSourceCyclicTag(unsigned int index);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString id;
|
QString id;
|
||||||
@@ -452,6 +460,7 @@ class Firmware
|
|||||||
const StringTagMappingTable trimSwitchesLookupTable;
|
const StringTagMappingTable trimSwitchesLookupTable;
|
||||||
const StringTagMappingTable rawSwitchTypesLookupTable;
|
const StringTagMappingTable rawSwitchTypesLookupTable;
|
||||||
const StringTagMappingTable rawSourceSpecialTypesLookupTable;
|
const StringTagMappingTable rawSourceSpecialTypesLookupTable;
|
||||||
|
const StringTagMappingTable rawSourceCyclicLookupTable;
|
||||||
QList<const char *> languages;
|
QList<const char *> languages;
|
||||||
//QList<const char *> ttslanguages;
|
//QList<const char *> ttslanguages;
|
||||||
OptionsList opts;
|
OptionsList opts;
|
||||||
|
|||||||
@@ -439,3 +439,17 @@ tbl.insert(tbl.end(), {
|
|||||||
|
|
||||||
return tbl;
|
return tbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
StringTagMappingTable RawSource::getCyclicLookupTable()
|
||||||
|
{
|
||||||
|
StringTagMappingTable tbl;
|
||||||
|
|
||||||
|
tbl.insert(tbl.end(), {
|
||||||
|
{"0", "CYC1"},
|
||||||
|
{"1", "CYC2"},
|
||||||
|
{"2", "CYC3"},
|
||||||
|
});
|
||||||
|
|
||||||
|
return tbl;
|
||||||
|
}
|
||||||
|
|||||||
@@ -276,6 +276,7 @@ class RawSource {
|
|||||||
QStringList getStickList(Boards board) const;
|
QStringList getStickList(Boards board) const;
|
||||||
QStringList getSwitchList(Boards board) const;
|
QStringList getSwitchList(Boards board) const;
|
||||||
static StringTagMappingTable getSpecialTypesLookupTable();
|
static StringTagMappingTable getSpecialTypesLookupTable();
|
||||||
|
static StringTagMappingTable getCyclicLookupTable();
|
||||||
|
|
||||||
bool operator == ( const RawSource & other) const {
|
bool operator == ( const RawSource & other) const {
|
||||||
return (this->type == other.type) && (this->index == other.index);
|
return (this->type == other.type) && (this->index == other.index);
|
||||||
|
|||||||
Reference in New Issue
Block a user