Open rafaelmaeuer opened 3 years ago
Hello, here is an example on how you can read the armed state:
if (activeModes>>MSP_MODE_ARM & 1)
println("ARMED");
else println("NOT ARMED");
I hope I have been helpful.
wow thanks so much - it is working now. Here is my working code if anyone else needs this in the future:
#include <MSP.h>
#include <SoftwareSerial.h>
MSP msp;
SoftwareSerial mspSerial(10, 11); // RX TX
void setup() {
Serial.begin(19200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Start");
mspSerial.begin(19200);
msp.begin(mspSerial);
}
void loop() {
msp_status_ex_t status_ex;
if (msp.request(MSP_STATUS_EX, &status_ex, sizeof(status_ex))) {
uint32_t activeModes = status_ex.flightModeFlags;
if (activeModes>>MSP_MODE_ARM & 1)
Serial.println("ARMED");
else {
Serial.println("NOT ARMED");
}
}
}
So is there a same way to get the IMU calibration state? And is it possible to auto-calibrate the IMU on startup with cleanflight?
Yes, you can read the calibration data requesting the MSP_CALIBRATION_DATA but I don't know if there is a command to do the calibration process.
OK this is strange, I get nothing printed in console when using this code: (Whether calibrating via Cleanflight-Config or remote control...)
void loop()
msp_calibration_data_t calib_data;
if (msp.request(MSP_CALIBRATION_DATA, &calib_data, sizeof(calib_data))) {
int16_t accZeroX = calib_data.accZeroX;
int16_t accZeroY = calib_data.accZeroY;
int16_t accZeroZ = calib_data.accZeroZ;
int16_t accGainX = calib_data.accGainX;
int16_t accGainY = calib_data.accGainY;
int16_t accGainZ = calib_data.accGainZ;
Serial.print("accZeroX: " + String(accZeroX));
Serial.print(" accZeroY: " + String(accZeroY));
Serial.println(" accZeroZ: " + String(accZeroZ));
Serial.print("accGainX: " + String(accGainX));
Serial.print(" accGainY: " + String(accGainY));
Serial.println(" accGainZ: " + String(accGainZ));
}
}
What am I doing wrong???
Hey and thanks very much for this great library.
I tried all day to figure out how to get the armed state with MSP from cleanflight. It seems to be able with the
getActiveModes
function andMSP_MODE_ARM
flag. But I have no idea how to get the value I need.I just want to get a 1 if UAV is armed and otherwise a 0.