Add screen / topbar data
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "yaml_logicalswitchdata.h"
|
||||
#include "yaml_customfunctiondata.h"
|
||||
#include "yaml_sensordata.h"
|
||||
#include "yaml_screendata.h"
|
||||
|
||||
#include "modeldata.h"
|
||||
#include "output_data.h"
|
||||
@@ -526,9 +527,13 @@ Node convert<ModelData>::encode(const ModelData& rhs)
|
||||
|
||||
node["toplcdTimer"] = rhs.toplcdTimer;
|
||||
|
||||
// B&W only
|
||||
// customScreens
|
||||
// topBarData
|
||||
for (int i=0; i<MAX_CUSTOM_SCREENS; i++) {
|
||||
const auto& csd = rhs.customScreens.customScreenData[i];
|
||||
if (!csd.isEmpty()) {
|
||||
node["screenData"][std::to_string(i)] = csd;
|
||||
}
|
||||
}
|
||||
node["topbarData"] = rhs.topBarData;
|
||||
|
||||
node["view"] = rhs.view;
|
||||
node["modelRegistrationID"] = rhs.registrationId;
|
||||
@@ -616,6 +621,9 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
|
||||
|
||||
// customScreens
|
||||
// topBarData
|
||||
node["screenData"] >> rhs.customScreens.customScreenData;
|
||||
node["topbarData"] >> rhs.topBarData;
|
||||
|
||||
node["view"] >> rhs.view;
|
||||
node["modelRegistrationID"] >> rhs.registrationId;
|
||||
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "yaml_screendata.h"
|
||||
#include "yaml_rawsource.h"
|
||||
#include "yaml_ops.h"
|
||||
|
||||
static const YamlLookupTable zoneOptionValueEnum = {
|
||||
{ZOV_Unsigned, "Unsigned"}, {ZOV_Signed, "Signed"}, {ZOV_Bool, "Bool"},
|
||||
{ZOV_String, "String"}, {ZOV_Source, "Source"}, {ZOV_Color, "Color"},
|
||||
};
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
ENUM_CONVERTER(ZoneOptionValueEnum, zoneOptionValueEnum);
|
||||
|
||||
Node convert<ZoneOptionValueTyped>::encode(const ZoneOptionValueTyped& rhs)
|
||||
{
|
||||
Node node, value;
|
||||
node["type"] = rhs.type;
|
||||
|
||||
switch (rhs.type) {
|
||||
case ZOV_Unsigned:
|
||||
value["unsignedValue"] = rhs.value.unsignedValue;
|
||||
break;
|
||||
case ZOV_Signed:
|
||||
value["signedValue"] = rhs.value.signedValue;
|
||||
break;
|
||||
case ZOV_Bool:
|
||||
value["boolValue"] = rhs.value.boolValue;
|
||||
break;
|
||||
case ZOV_Source:
|
||||
value["sourceValue"] = rhs.value.sourceValue;
|
||||
break;
|
||||
case ZOV_Color:
|
||||
value["colorValue"] = rhs.value.colorValue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
node["value"] = value;
|
||||
return node;
|
||||
}
|
||||
|
||||
bool convert<ZoneOptionValueTyped>::decode(const Node& node,
|
||||
ZoneOptionValueTyped& rhs)
|
||||
{
|
||||
node["type"] >> rhs.type;
|
||||
if (node["value"]) {
|
||||
Node value = node["value"];
|
||||
if (value.IsMap()) {
|
||||
value["unsignedValue"] >> rhs.value.unsignedValue;
|
||||
value["signedValue"] >> rhs.value.signedValue;
|
||||
value["boolValue"] >> rhs.value.boolValue;
|
||||
value["stringValue"] >> rhs.value.stringValue;
|
||||
value["sourceValue"] >> rhs.value.sourceValue;
|
||||
value["colorValue"] >> rhs.value.colorValue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <>
|
||||
struct convert<WidgetPersistentData> {
|
||||
static Node encode(const WidgetPersistentData& rhs)
|
||||
{
|
||||
Node node;
|
||||
for (int i=0; i<MAX_WIDGET_OPTIONS; i++) {
|
||||
if (!rhs.options[i].isEmpty()) {
|
||||
node["options"][std::to_string(i)] = rhs.options[i];
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, WidgetPersistentData& rhs)
|
||||
{
|
||||
node["options"] >> rhs.options;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Node convert<ZonePersistentData>::encode(const ZonePersistentData& rhs)
|
||||
{
|
||||
Node node;
|
||||
node["widgetName"] = rhs.widgetName;
|
||||
node["widgetData"] = rhs.widgetData;
|
||||
return node;
|
||||
}
|
||||
|
||||
bool convert<ZonePersistentData>::decode(const Node& node, ZonePersistentData& rhs)
|
||||
{
|
||||
node["widgetName"] >> rhs.widgetName;
|
||||
node["widgetData"] >> rhs.widgetData;
|
||||
return true;
|
||||
}
|
||||
|
||||
Node convert<ScreenData>::encode(const ScreenData& rhs)
|
||||
{
|
||||
Node node;
|
||||
node["LayoutId"] = rhs.layoutId;
|
||||
node["layoutData"] = rhs.layoutPersistentData;
|
||||
return node;
|
||||
}
|
||||
|
||||
bool convert<ScreenData>::decode(const Node& node, ScreenData& rhs)
|
||||
{
|
||||
node["LayoutId"] >> rhs.layoutId;
|
||||
node["layoutData"] >> rhs.layoutPersistentData;
|
||||
return true;
|
||||
}
|
||||
} // namespace YAML
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "yaml_ops.h"
|
||||
#include "customisation_data.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
template <>
|
||||
struct convert<ZonePersistentData> {
|
||||
static Node encode(const ZonePersistentData& rhs);
|
||||
static bool decode(const Node& node, ZonePersistentData& rhs);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct convert<ZoneOptionValueTyped> {
|
||||
static Node encode(const ZoneOptionValueTyped& rhs);
|
||||
static bool decode(const Node& node, ZoneOptionValueTyped& rhs);
|
||||
};
|
||||
|
||||
template <int N, int O>
|
||||
struct convert<WidgetsContainerPersistentData<N,O> > {
|
||||
typedef WidgetsContainerPersistentData<N,O> PersistentData;
|
||||
static Node encode(const PersistentData& rhs)
|
||||
{
|
||||
Node node;
|
||||
for (int i=0; i<N; i++) {
|
||||
if (strlen(rhs.zones[i].widgetName) > 0) {
|
||||
node["zones"][std::to_string(i)] = rhs.zones[i];
|
||||
}
|
||||
}
|
||||
for(int i=0; i<O; i++) {
|
||||
if (!rhs.options[i].isEmpty()) {
|
||||
node["options"][std::to_string(i)] = rhs.options[i];
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, PersistentData& rhs)
|
||||
{
|
||||
node["zones"] >> rhs.zones;
|
||||
node["options"] >> rhs.options;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
typedef RadioLayout::CustomScreenData ScreenData;
|
||||
|
||||
template <>
|
||||
struct convert<ScreenData> {
|
||||
static Node encode(const ScreenData& rhs);
|
||||
static bool decode(const Node& node, ScreenData& rhs);
|
||||
};
|
||||
} // namespace YAML
|
||||
Reference in New Issue
Block a user