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