diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 2cc820f3d..d1cabb2c6 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -1370,6 +1370,11 @@ inline unsigned int GetCurrentFirmwareVariant() 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] : "???") #endif diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 17ed1d087..d9c9d7d8a 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -950,7 +950,7 @@ class MixField: public TransformedField { if (IS_TARANIS(board) || version < 216) { 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); } } } diff --git a/companion/src/simulator.cpp b/companion/src/simulator.cpp index d06e3ecf2..3f9a2362f 100644 --- a/companion/src/simulator.cpp +++ b/companion/src/simulator.cpp @@ -101,14 +101,14 @@ int main(int argc, char *argv[]) RegisterFirmwares(); SimulatorDialog *dialog; - char * eepromFileName; + const char * eepromFileName; QMessageBox msgBox; msgBox.setWindowTitle("Radio type"); msgBox.setText("Which radio type do you want to simulate?"); msgBox.setIcon(QMessageBox::Question); 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); msgBox.exec();