Issue #857 - Better rounding also in Companion. Warning removed in
simulator
This commit is contained in:
@@ -1370,6 +1370,11 @@ inline unsigned int GetCurrentFirmwareVariant()
|
|||||||
return current_firmware_variant.variant;
|
return current_firmware_variant.variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int divRoundClosest(const int n, const int d)
|
||||||
|
{
|
||||||
|
return ((n < 0) ^ (d < 0)) ? ((n - d/2)/d) : ((n + d/2)/d);
|
||||||
|
}
|
||||||
|
|
||||||
#define CHECK_IN_ARRAY(T, index) ((unsigned int)index < (unsigned int)(sizeof(T)/sizeof(T[0])) ? T[(unsigned int)index] : "???")
|
#define CHECK_IN_ARRAY(T, index) ((unsigned int)index < (unsigned int)(sizeof(T)/sizeof(T[0])) ? T[(unsigned int)index] : "???")
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -950,7 +950,7 @@ class MixField: public TransformedField {
|
|||||||
|
|
||||||
if (IS_TARANIS(board) || version < 216) {
|
if (IS_TARANIS(board) || version < 216) {
|
||||||
if (mix.sOffset >= -500 && mix.sOffset <= 500 && mix.weight >= -500 && mix.weight <= 500) {
|
if (mix.sOffset >= -500 && mix.sOffset <= 500 && mix.weight >= -500 && mix.weight <= 500) {
|
||||||
mix.sOffset = ((mix.sOffset * mix.weight) + 50) / 100;
|
mix.sOffset = divRoundClosest(mix.sOffset * mix.weight, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,14 +101,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
RegisterFirmwares();
|
RegisterFirmwares();
|
||||||
SimulatorDialog *dialog;
|
SimulatorDialog *dialog;
|
||||||
char * eepromFileName;
|
const char * eepromFileName;
|
||||||
|
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setWindowTitle("Radio type");
|
msgBox.setWindowTitle("Radio type");
|
||||||
msgBox.setText("Which radio type do you want to simulate?");
|
msgBox.setText("Which radio type do you want to simulate?");
|
||||||
msgBox.setIcon(QMessageBox::Question);
|
msgBox.setIcon(QMessageBox::Question);
|
||||||
QAbstractButton *taranisButton = msgBox.addButton("Taranis", QMessageBox::ActionRole);
|
QAbstractButton *taranisButton = msgBox.addButton("Taranis", QMessageBox::ActionRole);
|
||||||
QAbstractButton *stdButton = msgBox.addButton("9X", QMessageBox::ActionRole);
|
msgBox.addButton("9X", QMessageBox::ActionRole);
|
||||||
QPushButton *exitButton = msgBox.addButton(QMessageBox::Close);
|
QPushButton *exitButton = msgBox.addButton(QMessageBox::Close);
|
||||||
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
|
|||||||
Reference in New Issue
Block a user