Small fixes
This commit is contained in:
@@ -163,18 +163,19 @@ struct YamlSwitchWarningState {
|
||||
static constexpr size_t MASK = (1 << MASK_LEN) - 1;
|
||||
|
||||
std::string src_str;
|
||||
uint64_t enabled;
|
||||
unsigned int enabled;
|
||||
|
||||
YamlSwitchWarningState() = default;
|
||||
|
||||
YamlSwitchWarningState(uint64_t cpn_value, unsigned int switchWarningEnable)
|
||||
: enabled(~switchWarningEnable)
|
||||
{
|
||||
uint64_t states = cpn_value;
|
||||
|
||||
std::stringstream ss;
|
||||
for (int i = 0; i < Boards::getCapability(getCurrentBoard(), Board::Switches); i++) {
|
||||
//TODO: exclude 2-pos toggle from switch warnings
|
||||
if (!(switchWarningEnable & (1 << i))) {
|
||||
if (enabled & (1 << i)) {
|
||||
std::string tag = getCurrentFirmware()->getSwitchesTag(i);
|
||||
const char *sw = tag.data();
|
||||
|
||||
@@ -870,17 +871,15 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
|
||||
{
|
||||
if (!node.IsMap()) return false;
|
||||
|
||||
unsigned int modelIds[CPN_MAX_MODULES];
|
||||
memset(modelIds, 0, sizeof(modelIds));
|
||||
|
||||
if (node["header"]) {
|
||||
const auto& header = node["header"];
|
||||
if (header.IsMap()) {
|
||||
header["name"] >> rhs.name;
|
||||
header["bitmap"] >> rhs.bitmap;
|
||||
|
||||
unsigned int modelIds[CPN_MAX_MODULES];
|
||||
header["modelId"] >> modelIds;
|
||||
for (int i=0; i<CPN_MAX_MODULES; i++) {
|
||||
rhs.moduleData[i].modelId = modelIds[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -984,9 +983,13 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
|
||||
}
|
||||
|
||||
node["rssiAlarms"] >> rhs.rssiAlarms;
|
||||
|
||||
node["trainerMode"] >> trainerModeLut >> rhs.trainerMode;
|
||||
|
||||
node["moduleData"] >> rhs.moduleData;
|
||||
for (int i=0; i<CPN_MAX_MODULES; i++) {
|
||||
rhs.moduleData[i].modelId = modelIds[i];
|
||||
}
|
||||
|
||||
node["scriptData"] >> rhs.scriptData;
|
||||
node["telemetrySensors"] >> rhs.sensorData;
|
||||
|
||||
|
||||
@@ -188,6 +188,9 @@ void convertEtxProtocolToMulti(int *protocol, int *subprotocol)
|
||||
}
|
||||
}
|
||||
|
||||
static int exportPpmDelay(int delay) { return (delay - 300) / 50; }
|
||||
static int importPpmDelay(int delay) { return 300 + 50 * delay; }
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
Node convert<ModuleData>::encode(const ModuleData& rhs)
|
||||
@@ -284,9 +287,9 @@ Node convert<ModuleData>::encode(const ModuleData& rhs)
|
||||
// TODO: afhds3, flysky
|
||||
default: {
|
||||
Node ppm;
|
||||
ppm["delay"] = rhs.ppm.delay;
|
||||
ppm["pulsePol"] = rhs.ppm.pulsePol;
|
||||
ppm["outputType"] = rhs.ppm.outputType;
|
||||
ppm["delay"] = exportPpmDelay(rhs.ppm.delay);
|
||||
ppm["pulsePol"] = (int)rhs.ppm.pulsePol;
|
||||
ppm["outputType"] = (int)rhs.ppm.outputType;
|
||||
ppm["frameLength"] = rhs.ppm.frameLength;
|
||||
mod["ppm"] = ppm;
|
||||
} break;
|
||||
@@ -347,10 +350,11 @@ bool convert<ModuleData>::decode(const Node& node, ModuleData& rhs)
|
||||
node["failsafeMode"] >> failsafeLut >> rhs.failsafeMode;
|
||||
|
||||
if (node["mod"]) {
|
||||
Node mod = node["mod"];
|
||||
const Node& mod = node["mod"];
|
||||
if (mod["ppm"]) {
|
||||
Node ppm = mod["ppm"];
|
||||
const Node& ppm = mod["ppm"];
|
||||
ppm["delay"] >> rhs.ppm.delay;
|
||||
rhs.ppm.delay = importPpmDelay(rhs.ppm.delay);
|
||||
ppm["pulsePol"] >> rhs.ppm.pulsePol;
|
||||
ppm["outputType"] >> rhs.ppm.outputType;
|
||||
ppm["frameLength"] >> rhs.ppm.frameLength;
|
||||
|
||||
@@ -102,7 +102,12 @@ void operator>>(const YAML::Node& node, T (&value)[N])
|
||||
int idx = std::stoi(elmt.first.Scalar());
|
||||
if (idx < 0 || idx >= (int)N) return;
|
||||
|
||||
elmt.second >> value[idx];
|
||||
if (elmt.second.IsMap() && (elmt.second.size() == 1) &&
|
||||
elmt.second["val"]) {
|
||||
elmt.second["val"] >> value[idx];
|
||||
} else {
|
||||
elmt.second >> value[idx];
|
||||
}
|
||||
} catch (...) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1321,6 +1321,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
Board::SwitchInfo switchInfo = Boards::getSwitchInfo(board, i);
|
||||
switchInfo.config = Board::SwitchType(generalSettings.switchConfig[i]);
|
||||
if (switchInfo.config == Board::SWITCH_NOT_AVAILABLE || switchInfo.config == Board::SWITCH_TOGGLE) {
|
||||
model.switchWarningEnable |= (1 << i);
|
||||
continue;
|
||||
}
|
||||
RawSource src(RawSourceType::SOURCE_TYPE_SWITCH, i);
|
||||
|
||||
Reference in New Issue
Block a user