mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-24 00:35:14 +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));
|
||||
}
|
||||
|
||||
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 result;
|
||||
|
|
|
@ -292,9 +292,7 @@ class RawSourceRange
|
|||
{
|
||||
}
|
||||
|
||||
float getValue(int value) {
|
||||
return min + float(value) * step;
|
||||
}
|
||||
float getValue(int value);
|
||||
|
||||
int decimals;
|
||||
double min;
|
||||
|
|
|
@ -399,9 +399,12 @@ void TelemetryCustomScreen::updateBar(int line)
|
|||
RawSource source = screen.body.bars[line].source;
|
||||
if (source.type != SOURCE_TYPE_NONE) {
|
||||
RawSourceRange range = source.getRange(model, generalSettings, RANGE_SINGLE_PRECISION);
|
||||
int max = round((range.max - range.min) / range.step);
|
||||
if (int(255-screen.body.bars[line].barMax) > max)
|
||||
screen.body.bars[line].barMax = 255 - max;
|
||||
if (!IS_ARM(GetCurrentFirmware()->getBoard())) {
|
||||
int max = round((range.max - range.min) / range.step);
|
||||
if (int(255-screen.body.bars[line].barMax) > max) {
|
||||
screen.body.bars[line].barMax = 255 - max;
|
||||
}
|
||||
}
|
||||
minSB[line]->setEnabled(true);
|
||||
minSB[line]->setDecimals(range.decimals);
|
||||
minSB[line]->setMinimum(range.min);
|
||||
|
@ -413,7 +416,12 @@ void TelemetryCustomScreen::updateBar(int line)
|
|||
maxSB[line]->setMinimum(range.min);
|
||||
maxSB[line]->setMaximum(range.max);
|
||||
maxSB[line]->setSingleStep(range.step);
|
||||
maxSB[line]->setValue(range.getValue(255 - screen.body.bars[line].barMax));
|
||||
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));
|
||||
}
|
||||
}
|
||||
else {
|
||||
minSB[line]->setDisabled(true);
|
||||
|
@ -468,7 +476,10 @@ void TelemetryCustomScreen::barMinChanged(double value)
|
|||
{
|
||||
if (!lock) {
|
||||
int line = sender()->property("index").toInt();
|
||||
screen.body.bars[line].barMin = round((value-minSB[line]->minimum()) / minSB[line]->singleStep());
|
||||
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());
|
||||
// TODO set min (maxSB)
|
||||
emit modified();
|
||||
}
|
||||
|
@ -478,7 +489,10 @@ void TelemetryCustomScreen::barMaxChanged(double value)
|
|||
{
|
||||
if (!lock) {
|
||||
int line = sender()->property("index").toInt();
|
||||
screen.body.bars[line].barMax = 255 - round((value-minSB[line]->minimum()) / maxSB[line]->singleStep());
|
||||
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());
|
||||
// TODO set max (minSB)
|
||||
emit modified();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue