Add value shifts and factors
This commit is contained in:
@@ -82,12 +82,12 @@ namespace YAML {
|
|||||||
node["telemetryBaudrate"] >> rhs.telemetryBaudrate; // TODO: conversion???
|
node["telemetryBaudrate"] >> rhs.telemetryBaudrate; // TODO: conversion???
|
||||||
node["splashMode"] >> rhs.splashMode; // TODO: B&W only
|
node["splashMode"] >> rhs.splashMode; // TODO: B&W only
|
||||||
node["templateSetup"] >> rhs.templateSetup;
|
node["templateSetup"] >> rhs.templateSetup;
|
||||||
node["hapticLength"] >> rhs.hapticLength; // TODO: conversion???
|
node["hapticLength"] >> ioffset_int(rhs.hapticLength, 2);
|
||||||
node["speakerPitch"] >> rhs.speakerPitch; // TODO: conversion???
|
node["speakerPitch"] >> ifactor<unsigned int>(rhs.speakerPitch, 15);
|
||||||
node["hapticStrength"] >> rhs.hapticStrength; // TODO: conversion???
|
node["hapticStrength"] >> ioffset_int(rhs.hapticStrength, 2);
|
||||||
node["beepLength"] >> rhs.beeperLength; // TODO: conversion???
|
node["beepLength"] >> ioffset_int(rhs.beeperLength, 2);
|
||||||
node["gpsFormat"] >> rhs.gpsFormat;
|
node["gpsFormat"] >> rhs.gpsFormat;
|
||||||
node["speakerVolume"] >> rhs.speakerVolume; // TODO: conversion???
|
node["speakerVolume"] >> ioffset_int(rhs.speakerVolume, 12);
|
||||||
node["backlightBright"] >> rhs.backlightBright;
|
node["backlightBright"] >> rhs.backlightBright;
|
||||||
node["switchesDelay"] >> rhs.switchesDelay;
|
node["switchesDelay"] >> rhs.switchesDelay;
|
||||||
node["globalTimer"] >> rhs.globalTimer;
|
node["globalTimer"] >> rhs.globalTimer;
|
||||||
@@ -100,13 +100,13 @@ namespace YAML {
|
|||||||
node["keysBacklight"] >> rhs.keysBacklight;
|
node["keysBacklight"] >> rhs.keysBacklight;
|
||||||
node["imperial"] >> rhs.imperial;
|
node["imperial"] >> rhs.imperial;
|
||||||
node["ttsLanguage"] >> rhs.ttsLanguage;
|
node["ttsLanguage"] >> rhs.ttsLanguage;
|
||||||
node["beepVolume"] >> rhs.beepVolume; // TODO: conversion???
|
node["beepVolume"] >> ioffset_int(rhs.beepVolume, 2);
|
||||||
node["wavVolume"] >> rhs.wavVolume;
|
node["wavVolume"] >> ioffset_int(rhs.wavVolume, 2);
|
||||||
node["varioVolume"] >> rhs.varioVolume;
|
node["varioVolume"] >> ioffset_int(rhs.varioVolume, 2);
|
||||||
node["varioPitch"] >> rhs.varioPitch;
|
node["varioPitch"] >> ifactor<int>(rhs.varioPitch, 10);
|
||||||
node["varioRange"] >> rhs.varioRange;
|
node["varioRange"] >> ifactor<int>(rhs.varioRange, 15);
|
||||||
node["varioRepeat"] >> rhs.varioRepeat;
|
node["varioRepeat"] >> rhs.varioRepeat;
|
||||||
node["backgroundVolume"] >> rhs.backgroundVolume;
|
node["backgroundVolume"] >> ioffset_int(rhs.backgroundVolume, 2);
|
||||||
node["auxSerialMode"] >> uartModeLut >> rhs.auxSerialMode;
|
node["auxSerialMode"] >> uartModeLut >> rhs.auxSerialMode;
|
||||||
node["aux2SerialMode"] >> uartModeLut >> rhs.aux2SerialMode;
|
node["aux2SerialMode"] >> uartModeLut >> rhs.aux2SerialMode;
|
||||||
node["antennaMode"] >> antennaModeLut >> rhs.antennaMode;
|
node["antennaMode"] >> antennaModeLut >> rhs.antennaMode;
|
||||||
|
|||||||
@@ -41,10 +41,35 @@ private:
|
|||||||
int offset;
|
int offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class ifactor {
|
||||||
|
|
||||||
|
public:
|
||||||
|
ifactor(T& val, int factor)
|
||||||
|
: value(val), factor(factor)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void assign(T newValue) const {
|
||||||
|
value = newValue / factor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
T& value;
|
||||||
|
T factor;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
YAML::Node operator >> (const YAML::Node& node, const YamlLookupTable& lut);
|
YAML::Node operator >> (const YAML::Node& node, const YamlLookupTable& lut);
|
||||||
void operator >> (const YAML::Node& node, const ioffset_int& value);
|
void operator >> (const YAML::Node& node, const ioffset_int& value);
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void operator >> (const YAML::Node& node, const ifactor<T>& value)
|
||||||
|
{
|
||||||
|
if (node && node.IsScalar()) {
|
||||||
|
value.assign(node.as<T>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void operator >> (const YAML::Node& node, T& value)
|
void operator >> (const YAML::Node& node, T& value)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user