mpu offsets

This commit is contained in:
jusax23 2022-08-22 12:44:16 +02:00
parent 1658daaaf9
commit f1ed2b8cfc

View file

@ -1,3 +1,10 @@
typedef struct{
byte type = 1;
byte command;
float X;
float Y;
float Z;
} mpuSendData;
void handelSerial(){ void handelSerial(){
String serialin = Serial.readStringUntil('\n'); String serialin = Serial.readStringUntil('\n');
@ -91,6 +98,91 @@ void handelSerial(){
} }
return; return;
} }
if(command=="MPUoffestSettings"){
if (NRFisConnected == 1)
{
uint16_t buf = 3;
uint16_t kind = goonin.toInt();
if (kind > 6)
{
Serial.println("<MPUoffestSett>error");
return;
}
buf |= (kind+0x10) << 8;
if (sendRCdata(&buf, 2))
{
Serial.println("<MPUoffestSett>send");
}
else
{
Serial.println("<MPUoffestSett>lost");
}
}
else
{
Serial.println("<MPUoffestSett>noconn");
}
return;
}
if(command=="MPUsetOffsetsAcc"){
if (NRFisConnected == 1)
{
mpuSendData buf;
buf.command = 0x17;
unsigned int cutpos = cutcheck(goonin.indexOf("|"), goonin.length());
String vX = goonin.substring(0, cutpos);
goonin = goonin.substring(cutpos + 1);
String vY = goonin.substring(0, cutpos);
String vZ = goonin.substring(cutpos + 1);
buf.X = vX.toFloat();
buf.Y = vY.toFloat();
buf.Z = vZ.toFloat();
if (sendRCdata(&buf, 2)){
Serial.println("<MPUsetOffsetsAcc>send");
}else{
Serial.println("<MPUsetOffsetsAcc>lost");
}
}
else
{
Serial.println("<MPUsetOffsetsAcc>noconn");
}
return;
}
if(command=="MPUsetOffsetsGyro"){
if (NRFisConnected == 1)
{
mpuSendData buf;
buf.command = 0x18;
unsigned int cutpos = cutcheck(goonin.indexOf("|"), goonin.length());
String vX = goonin.substring(0, cutpos);
goonin = goonin.substring(cutpos + 1);
String vY = goonin.substring(0, cutpos);
String vZ = goonin.substring(cutpos + 1);
buf.X = vX.toFloat();
buf.Y = vY.toFloat();
buf.Z = vZ.toFloat();
if (sendRCdata(&buf, 2)){
Serial.println("<MPUsetOffsetsGyro>send");
}else{
Serial.println("<MPUsetOffsetsGyro>lost");
}
}
else
{
Serial.println("<MPUsetOffsetsGyro>noconn");
}
return;
}
if(command=="readAnalogDesc"){ if(command=="readAnalogDesc"){
if(NRFisConnected==1){ if(NRFisConnected==1){
uint16_t buf = 50; uint16_t buf = 50;