mpu offsets
This commit is contained in:
parent
1658daaaf9
commit
f1ed2b8cfc
1 changed files with 92 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
|||
typedef struct{
|
||||
byte type = 1;
|
||||
byte command;
|
||||
float X;
|
||||
float Y;
|
||||
float Z;
|
||||
} mpuSendData;
|
||||
|
||||
void handelSerial(){
|
||||
String serialin = Serial.readStringUntil('\n');
|
||||
|
@ -91,6 +98,91 @@ void handelSerial(){
|
|||
}
|
||||
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(NRFisConnected==1){
|
||||
uint16_t buf = 50;
|
||||
|
|
Loading…
Reference in a new issue