Used rouding like arm radios (#4683)
This commit is contained in:
@@ -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);
|
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] : "???")
|
#define CHECK_IN_ARRAY(T, index) ((unsigned int)index < DIM(T) ? T[(unsigned int)index] : "???")
|
||||||
|
|
||||||
extern QList<EEPROMInterface *> eepromInterfaces;
|
extern QList<EEPROMInterface *> eepromInterfaces;
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ void RadioOutputsWidget::setValues()
|
|||||||
for (ch = m_channelsMap.constBegin(); ch != m_channelsMap.constEnd(); ++ch) {
|
for (ch = m_channelsMap.constBegin(); ch != m_channelsMap.constEnd(); ++ch) {
|
||||||
if (ch.key() >= CPN_MAX_CHNOUT)
|
if (ch.key() >= CPN_MAX_CHNOUT)
|
||||||
continue;
|
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()])));
|
ch.value().second->setValue(qMin(1024, qMax(-1024, outputs.chans[ch.key()])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user