feat: allow IMU inversion (#7505)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user