1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-16 21:05:26 +03:00

A1- to A4- inaccessible

This commit is contained in:
bsongis 2014-06-21 19:18:23 +02:00
parent 8d6ab5c123
commit f707035af5
2 changed files with 28 additions and 23 deletions

View file

@ -136,26 +136,14 @@ RawSourceRange RawSource::getRange(const ModelData & model, const GeneralSetting
case TELEMETRY_SOURCE_A2_MIN:
case TELEMETRY_SOURCE_A3_MIN:
case TELEMETRY_SOURCE_A4_MIN:
index -= TELEMETRY_SOURCE_A1_MIN;
index += TELEMETRY_SOURCE_A1;
// no break;
result = model.frsky.channels[index-TELEMETRY_SOURCE_A1_MIN].getRange();
break;
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A2:
case TELEMETRY_SOURCE_A3:
case TELEMETRY_SOURCE_A4:
{
const FrSkyChannelData & channel = model.frsky.channels[index-TELEMETRY_SOURCE_A1];
float ratio = channel.getRatio();
if (channel.type==0 || channel.type==1 || channel.type==2)
result.decimals = 2;
else
result.decimals = 0;
result.step = ratio / 255;
result.min = channel.offset * result.step;
result.max = ratio + result.min;
result.unit = QObject::tr("V");
result = model.frsky.channels[index-TELEMETRY_SOURCE_A1].getRange();
break;
}
case TELEMETRY_SOURCE_ALT:
case TELEMETRY_SOURCE_ALT_MIN:
case TELEMETRY_SOURCE_ALT_MAX:
@ -1077,6 +1065,29 @@ int GeneralSettings::getDefaultChannel(unsigned int stick) const
return -1;
}
float FrSkyChannelData::getRatio() const
{
if (type==0 || type==1 || type==2)
return float(ratio << multiplier) / 10.0;
else
return ratio << multiplier;
}
RawSourceRange FrSkyChannelData::getRange() const
{
RawSourceRange result;
float ratio = getRatio();
if (type==0 || type==1 || type==2)
result.decimals = 2;
else
result.decimals = 0;
result.step = ratio / 255;
result.min = offset * result.step;
result.max = ratio + result.min;
result.unit = QObject::tr("V");
return result;
}
void FrSkyData::clear()
{
memset(this, 0, sizeof(FrSkyData));

View file

@ -821,14 +821,8 @@ class FrSkyChannelData {
unsigned int multiplier;
FrSkyAlarmData alarms[2];
float getRatio() const
{
if (type==0 || type==1 || type==2)
return float(ratio << multiplier) / 10.0;
else
return ratio << multiplier;
}
float getRatio() const;
RawSourceRange getRange() const;
void clear() { memset(this, 0, sizeof(FrSkyChannelData)); }
};