Output knobs config
This commit is contained in:
@@ -112,20 +112,10 @@ namespace YAML {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// YamlStickConfig stickConfig;
|
node["sticksConfig"] = YamlStickConfig(rhs.stickName);
|
||||||
// node["sticksConfig"] = stickConfig;
|
node["switchConfig"] = YamlSwitchConfig(rhs.switchName, rhs.switchConfig);
|
||||||
|
node["potsConfig"] = YamlPotConfig(rhs.potName, rhs.potConfig);
|
||||||
// YamlSwitchConfig switchConfig;
|
node["slidersConfig"] = YamlSliderConfig(rhs.sliderName, rhs.sliderConfig);
|
||||||
// node["switchConfig"] = switchConfig;
|
|
||||||
// switchConfig.copy(rhs.switchName, rhs.switchConfig);
|
|
||||||
|
|
||||||
// YamlPotConfig potsConfig;
|
|
||||||
// node["potsConfig"] = potsConfig;
|
|
||||||
// potsConfig.copy(rhs.potName, rhs.potConfig);
|
|
||||||
|
|
||||||
// YamlSliderConfig slidersConfig;
|
|
||||||
// node["slidersConfig"] = slidersConfig;
|
|
||||||
// slidersConfig.copy(rhs.sliderName, rhs.sliderConfig);
|
|
||||||
|
|
||||||
// Color lcd theme settings are not used in EdgeTx
|
// Color lcd theme settings are not used in EdgeTx
|
||||||
// RadioTheme::ThemeData themeData;
|
// RadioTheme::ThemeData themeData;
|
||||||
|
|||||||
@@ -62,3 +62,4 @@ const YamlLookupTable sliderConfigLut = {
|
|||||||
{Board::SLIDER_NONE, "none"},
|
{Board::SLIDER_NONE, "none"},
|
||||||
{Board::SLIDER_WITH_DETENT, "with_detent"},
|
{Board::SLIDER_WITH_DETENT, "with_detent"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,28 +22,47 @@
|
|||||||
|
|
||||||
#include "yaml_ops.h"
|
#include "yaml_ops.h"
|
||||||
#include "generalsettings.h"
|
#include "generalsettings.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
template<unsigned int N, const YamlLookupTable& name_lut>
|
template <unsigned int N, const YamlLookupTable& name_lut>
|
||||||
struct YamlNameConfig {
|
struct YamlNameConfig {
|
||||||
|
|
||||||
char name[N][HARDWARE_NAME_LEN + 1];
|
char name[N][HARDWARE_NAME_LEN + 1];
|
||||||
|
|
||||||
void copy(char out_names[N][HARDWARE_NAME_LEN + 1]) {
|
YamlNameConfig() { memset(name, 0, sizeof(name)); }
|
||||||
memcpy(out_names, name, sizeof(name));
|
|
||||||
|
YamlNameConfig(const char in_names[N][HARDWARE_NAME_LEN + 1])
|
||||||
|
{
|
||||||
|
memcpy(name, in_names, sizeof(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
void copy(char out_names[N][HARDWARE_NAME_LEN + 1])
|
||||||
|
{
|
||||||
|
memcpy(out_names, name, sizeof(name));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const YamlLookupTable sticksLut;
|
extern const YamlLookupTable sticksLut;
|
||||||
typedef YamlNameConfig<CPN_MAX_SWITCHES, sticksLut> YamlStickConfig;
|
typedef YamlNameConfig<CPN_MAX_SWITCHES, sticksLut> YamlStickConfig;
|
||||||
|
|
||||||
template<unsigned int N, const YamlLookupTable& name_lut, const YamlLookupTable& cfg_lut>
|
template <unsigned int N, const YamlLookupTable& name_lut,
|
||||||
|
const YamlLookupTable& cfg_lut>
|
||||||
struct YamlKnobConfig : public YamlNameConfig<N, name_lut> {
|
struct YamlKnobConfig : public YamlNameConfig<N, name_lut> {
|
||||||
|
|
||||||
unsigned int config[N];
|
unsigned int config[N];
|
||||||
|
|
||||||
void copy(char out_names[N][HARDWARE_NAME_LEN + 1], unsigned int out_configs[N]) {
|
YamlKnobConfig() { memset(config, 0, sizeof(config)); }
|
||||||
YamlNameConfig<N, name_lut>::copy(out_names);
|
|
||||||
memcpy(out_configs, config, sizeof(config));
|
YamlKnobConfig(const char in_names[N][HARDWARE_NAME_LEN + 1],
|
||||||
|
const unsigned int in_configs[N]) :
|
||||||
|
YamlNameConfig<N, name_lut>(in_names)
|
||||||
|
{
|
||||||
|
memset(config, 0, sizeof(config));
|
||||||
|
}
|
||||||
|
|
||||||
|
void copy(char out_names[N][HARDWARE_NAME_LEN + 1],
|
||||||
|
unsigned int out_configs[N])
|
||||||
|
{
|
||||||
|
YamlNameConfig<N, name_lut>::copy(out_names);
|
||||||
|
memcpy(out_configs, config, sizeof(config));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,26 +71,36 @@ struct YamlKnobConfig : public YamlNameConfig<N, name_lut> {
|
|||||||
// name:
|
// name:
|
||||||
extern const YamlLookupTable switchesLut;
|
extern const YamlLookupTable switchesLut;
|
||||||
extern const YamlLookupTable switchConfigLut;
|
extern const YamlLookupTable switchConfigLut;
|
||||||
typedef YamlKnobConfig<CPN_MAX_SWITCHES, switchesLut, switchConfigLut> YamlSwitchConfig;
|
typedef YamlKnobConfig<CPN_MAX_SWITCHES, switchesLut, switchConfigLut>
|
||||||
|
YamlSwitchConfig;
|
||||||
|
|
||||||
// S1:
|
// S1:
|
||||||
// type: with_detent
|
// type: with_detent
|
||||||
// name:
|
// name:
|
||||||
extern const YamlLookupTable potsLut;
|
extern const YamlLookupTable potsLut;
|
||||||
extern const YamlLookupTable potConfigLut;
|
extern const YamlLookupTable potConfigLut;
|
||||||
typedef YamlKnobConfig<CPN_MAX_KNOBS, potsLut, potConfigLut> YamlPotConfig;
|
typedef YamlKnobConfig<CPN_MAX_KNOBS, potsLut, potConfigLut> YamlPotConfig;
|
||||||
|
|
||||||
// S1:
|
// S1:
|
||||||
// type: with_detent
|
// type: with_detent
|
||||||
// name:
|
// name:
|
||||||
extern const YamlLookupTable slidersLut;
|
extern const YamlLookupTable slidersLut;
|
||||||
extern const YamlLookupTable sliderConfigLut;
|
extern const YamlLookupTable sliderConfigLut;
|
||||||
typedef YamlKnobConfig<CPN_MAX_SLIDERS, slidersLut, sliderConfigLut> YamlSliderConfig;
|
typedef YamlKnobConfig<CPN_MAX_SLIDERS, slidersLut, sliderConfigLut>
|
||||||
|
YamlSliderConfig;
|
||||||
|
|
||||||
namespace YAML
|
namespace YAML
|
||||||
{
|
{
|
||||||
template <unsigned int N, const YamlLookupTable& name_lut>
|
template <unsigned int N, const YamlLookupTable& name_lut>
|
||||||
struct convert<YamlNameConfig<N, name_lut> > {
|
struct convert<YamlNameConfig<N, name_lut> > {
|
||||||
|
static Node encode(const YamlNameConfig<N, name_lut>& rhs)
|
||||||
|
{
|
||||||
|
Node node;
|
||||||
|
for (const auto& kv : name_lut) {
|
||||||
|
node[kv.second]["name"] = rhs.name[kv.first];
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
static bool decode(const Node& node, YamlNameConfig<N, name_lut>& rhs)
|
static bool decode(const Node& node, YamlNameConfig<N, name_lut>& rhs)
|
||||||
{
|
{
|
||||||
if (!node.IsMap()) return false;
|
if (!node.IsMap()) return false;
|
||||||
@@ -84,9 +113,20 @@ struct convert<YamlNameConfig<N, name_lut> > {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <unsigned int N, const YamlLookupTable& name_lut, const YamlLookupTable& cfg_lut>
|
template <unsigned int N, const YamlLookupTable& name_lut,
|
||||||
|
const YamlLookupTable& cfg_lut>
|
||||||
struct convert<YamlKnobConfig<N, name_lut, cfg_lut> > {
|
struct convert<YamlKnobConfig<N, name_lut, cfg_lut> > {
|
||||||
static bool decode(const Node& node, YamlKnobConfig<N, name_lut, cfg_lut>& rhs)
|
static Node encode(const YamlKnobConfig<N, name_lut, cfg_lut>& rhs)
|
||||||
|
{
|
||||||
|
Node node;
|
||||||
|
for (const auto& kv : name_lut) {
|
||||||
|
node[kv.second]["type"] = cfg_lut << rhs.config[kv.first];
|
||||||
|
node[kv.second]["name"] = rhs.name[kv.first];
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
static bool decode(const Node& node,
|
||||||
|
YamlKnobConfig<N, name_lut, cfg_lut>& rhs)
|
||||||
{
|
{
|
||||||
if (!node.IsMap()) return false;
|
if (!node.IsMap()) return false;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user