mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-25 01:05:08 +03:00
Fixes #2491
This commit is contained in:
parent
654dac1acc
commit
34731af074
3 changed files with 29 additions and 9 deletions
|
@ -161,6 +161,14 @@ bool RawSource::isTimeBased() const
|
||||||
return (type==SOURCE_TYPE_TELEMETRY && (index==TELEMETRY_SOURCE_TX_TIME || index==TELEMETRY_SOURCE_TIMER1 || index==TELEMETRY_SOURCE_TIMER2 || index==TELEMETRY_SOURCE_TIMER3));
|
return (type==SOURCE_TYPE_TELEMETRY && (index==TELEMETRY_SOURCE_TX_TIME || index==TELEMETRY_SOURCE_TIMER1 || index==TELEMETRY_SOURCE_TIMER2 || index==TELEMETRY_SOURCE_TIMER3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float RawSourceRange::getValue(int value)
|
||||||
|
{
|
||||||
|
if (IS_ARM(GetCurrentFirmware()->getBoard()))
|
||||||
|
return float(value) * step;
|
||||||
|
else
|
||||||
|
return min + float(value) * step;
|
||||||
|
}
|
||||||
|
|
||||||
RawSourceRange RawSource::getRange(const ModelData * model, const GeneralSettings & settings, unsigned int flags) const
|
RawSourceRange RawSource::getRange(const ModelData * model, const GeneralSettings & settings, unsigned int flags) const
|
||||||
{
|
{
|
||||||
RawSourceRange result;
|
RawSourceRange result;
|
||||||
|
|
|
@ -292,9 +292,7 @@ class RawSourceRange
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
float getValue(int value) {
|
float getValue(int value);
|
||||||
return min + float(value) * step;
|
|
||||||
}
|
|
||||||
|
|
||||||
int decimals;
|
int decimals;
|
||||||
double min;
|
double min;
|
||||||
|
|
|
@ -399,9 +399,12 @@ void TelemetryCustomScreen::updateBar(int line)
|
||||||
RawSource source = screen.body.bars[line].source;
|
RawSource source = screen.body.bars[line].source;
|
||||||
if (source.type != SOURCE_TYPE_NONE) {
|
if (source.type != SOURCE_TYPE_NONE) {
|
||||||
RawSourceRange range = source.getRange(model, generalSettings, RANGE_SINGLE_PRECISION);
|
RawSourceRange range = source.getRange(model, generalSettings, RANGE_SINGLE_PRECISION);
|
||||||
|
if (!IS_ARM(GetCurrentFirmware()->getBoard())) {
|
||||||
int max = round((range.max - range.min) / range.step);
|
int max = round((range.max - range.min) / range.step);
|
||||||
if (int(255-screen.body.bars[line].barMax) > max)
|
if (int(255-screen.body.bars[line].barMax) > max) {
|
||||||
screen.body.bars[line].barMax = 255 - max;
|
screen.body.bars[line].barMax = 255 - max;
|
||||||
|
}
|
||||||
|
}
|
||||||
minSB[line]->setEnabled(true);
|
minSB[line]->setEnabled(true);
|
||||||
minSB[line]->setDecimals(range.decimals);
|
minSB[line]->setDecimals(range.decimals);
|
||||||
minSB[line]->setMinimum(range.min);
|
minSB[line]->setMinimum(range.min);
|
||||||
|
@ -413,8 +416,13 @@ void TelemetryCustomScreen::updateBar(int line)
|
||||||
maxSB[line]->setMinimum(range.min);
|
maxSB[line]->setMinimum(range.min);
|
||||||
maxSB[line]->setMaximum(range.max);
|
maxSB[line]->setMaximum(range.max);
|
||||||
maxSB[line]->setSingleStep(range.step);
|
maxSB[line]->setSingleStep(range.step);
|
||||||
|
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
|
||||||
|
maxSB[line]->setValue(range.getValue(screen.body.bars[line].barMax));
|
||||||
|
}
|
||||||
|
else {
|
||||||
maxSB[line]->setValue(range.getValue(255 - screen.body.bars[line].barMax));
|
maxSB[line]->setValue(range.getValue(255 - screen.body.bars[line].barMax));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
minSB[line]->setDisabled(true);
|
minSB[line]->setDisabled(true);
|
||||||
maxSB[line]->setDisabled(true);
|
maxSB[line]->setDisabled(true);
|
||||||
|
@ -468,6 +476,9 @@ void TelemetryCustomScreen::barMinChanged(double value)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int line = sender()->property("index").toInt();
|
int line = sender()->property("index").toInt();
|
||||||
|
if (IS_ARM(GetCurrentFirmware()->getBoard()))
|
||||||
|
screen.body.bars[line].barMin = round(value / minSB[line]->singleStep());
|
||||||
|
else
|
||||||
screen.body.bars[line].barMin = round((value-minSB[line]->minimum()) / minSB[line]->singleStep());
|
screen.body.bars[line].barMin = round((value-minSB[line]->minimum()) / minSB[line]->singleStep());
|
||||||
// TODO set min (maxSB)
|
// TODO set min (maxSB)
|
||||||
emit modified();
|
emit modified();
|
||||||
|
@ -478,6 +489,9 @@ void TelemetryCustomScreen::barMaxChanged(double value)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int line = sender()->property("index").toInt();
|
int line = sender()->property("index").toInt();
|
||||||
|
if (IS_ARM(GetCurrentFirmware()->getBoard()))
|
||||||
|
screen.body.bars[line].barMax = round((value) / maxSB[line]->singleStep());
|
||||||
|
else
|
||||||
screen.body.bars[line].barMax = 255 - round((value-minSB[line]->minimum()) / maxSB[line]->singleStep());
|
screen.body.bars[line].barMax = 255 - round((value-minSB[line]->minimum()) / maxSB[line]->singleStep());
|
||||||
// TODO set max (minSB)
|
// TODO set max (minSB)
|
||||||
emit modified();
|
emit modified();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue