feat: allow IMU inversion (#7505)

This commit is contained in:
3djc
2026-07-04 18:33:29 +10:00
committed by GitHub
parent c070ddda4b
commit 057883da83
20 changed files with 124 additions and 3 deletions
@@ -365,6 +365,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
if (Boards::getCapability(board, Board::HasIMU)) {
node["imuMax"] = rhs.imuMax;
node["imuOffset"] = rhs.imuOffset;
node["imuInvert"] = (rhs.imuInvertX ? 1 : 0) | (rhs.imuInvertY ? 2 : 0);
}
// OneBit sampling (X9D only?)
@@ -714,6 +715,10 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
node["imuMax"] >> rhs.imuMax;
node["imuOffset"] >> rhs.imuOffset;
int imuInvert = 0;
node["imuInvert"] >> imuInvert;
rhs.imuInvertX = imuInvert & 0x1;
rhs.imuInvertY = imuInvert & 0x2;
// OneBit sampling (X9D only?)
node["uartSampleMode"] >> rhs.uartSampleMode;
@@ -384,6 +384,8 @@ class GeneralSettings {
char registrationId[REGISTRATION_ID_LEN + 1];
int imuMax;
int imuOffset;
bool imuInvertX;
bool imuInvertY;
int uartSampleMode;
int pwrOnSpeed;
+19
View File
@@ -107,6 +107,25 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
addParams();
}
if (Boards::getCapability(board, Board::HasIMU)) {
addSection(tr("IMU"));
addLabel("");
addLabel(tr("Invert"));
addParams();
addLabel(tr("X"));
AutoCheckBox *imuInvertX = new AutoCheckBox(this);
imuInvertX->setField(generalSettings.imuInvertX, this);
params->append(imuInvertX);
addParams();
addLabel(tr("Y"));
AutoCheckBox *imuInvertY = new AutoCheckBox(this);
imuInvertY->setField(generalSettings.imuInvertY, this);
params->append(imuInvertY);
addParams();
}
count = Boards::getCapability(board, Board::Inputs);
if (count > 0) {