Used rouding like arm radios (#4683)

This commit is contained in:
3djc
2017-03-25 13:04:33 +01:00
committed by Bertrand Songis
parent 1f7dd5a5bc
commit 98388a7ec8
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -368,6 +368,11 @@ inline int divRoundClosest(const int n, const int d)
return ((n < 0) ^ (d < 0)) ? ((n - d/2)/d) : ((n + d/2)/d);
}
inline int calcRESXto100(int x)
{
return divRoundClosest(x*100, 1024);
}
#define CHECK_IN_ARRAY(T, index) ((unsigned int)index < DIM(T) ? T[(unsigned int)index] : "???")
extern QList<EEPROMInterface *> eepromInterfaces;
@@ -313,7 +313,7 @@ void RadioOutputsWidget::setValues()
for (ch = m_channelsMap.constBegin(); ch != m_channelsMap.constEnd(); ++ch) {
if (ch.key() >= CPN_MAX_CHNOUT)
continue;
ch.value().first->setText(QString("%1%").arg((outputs.chans[ch.key()] * 100 + 512) / 1024));
ch.value().first->setText(QString("%1%").arg(calcRESXto100(outputs.chans[ch.key()])));
ch.value().second->setValue(qMin(1024, qMax(-1024, outputs.chans[ch.key()])));
}
}