2010-08-28 13:07:33 -03:00
|
|
|
/*
|
|
|
|
www.ArduCopter.com - www.DIYDrones.com
|
|
|
|
Copyright (c) 2010. All rights reserved.
|
|
|
|
An Open Source Arduino based multicopter.
|
|
|
|
|
|
|
|
File : GCS.pde
|
|
|
|
Version : v1.0, Aug 27, 2010
|
|
|
|
Author(s): ArduCopter Team
|
2010-10-17 14:34:17 -03:00
|
|
|
Ted Carancho (aeroquad), Jose Julio, Jordi Muñoz,
|
|
|
|
Jani Hirvinen, Ken McEwans, Roberto Navoni,
|
|
|
|
Sandro Benigno, Chris Anderson
|
2010-08-28 13:07:33 -03:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-10-17 14:34:17 -03:00
|
|
|
|
|
|
|
* ************************************************************** *
|
|
|
|
ChangeLog:
|
|
|
|
|
|
|
|
|
|
|
|
* ************************************************************** *
|
|
|
|
TODO:
|
|
|
|
|
|
|
|
|
|
|
|
* ************************************************************** */
|
2010-08-28 13:07:33 -03:00
|
|
|
//
|
|
|
|
// Function : send_message()
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// byte severity - Debug level
|
|
|
|
// char str - Text to write
|
|
|
|
//
|
|
|
|
// Returns : - none
|
|
|
|
|
|
|
|
void send_message(byte severity, const char *str) // This is the instance of send_message for message 0x05
|
|
|
|
{
|
2010-10-17 14:34:17 -03:00
|
|
|
if(severity >= DEBUG_LEVEL){
|
|
|
|
SerPri("MSG: ");
|
|
|
|
SerPrln(str);
|
|
|
|
}
|
2010-08-28 13:07:33 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// Function : readSerialCommand()
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// - none
|
|
|
|
//
|
|
|
|
// Returns : - none
|
|
|
|
//
|
|
|
|
void readSerialCommand() {
|
|
|
|
// Check for serial message
|
2010-10-17 13:18:14 -03:00
|
|
|
if (SerAva()) {
|
2010-10-17 14:34:17 -03:00
|
|
|
queryType = SerRea();
|
2010-08-28 13:07:33 -03:00
|
|
|
switch (queryType) {
|
|
|
|
case 'A': // Stable PID
|
|
|
|
KP_QUAD_ROLL = readFloatSerial();
|
|
|
|
KI_QUAD_ROLL = readFloatSerial();
|
2010-10-11 09:35:05 -03:00
|
|
|
STABLE_MODE_KP_RATE_ROLL = readFloatSerial();
|
2010-08-28 13:07:33 -03:00
|
|
|
KP_QUAD_PITCH = readFloatSerial();
|
|
|
|
KI_QUAD_PITCH = readFloatSerial();
|
2010-10-11 09:35:05 -03:00
|
|
|
STABLE_MODE_KP_RATE_PITCH = readFloatSerial();
|
2010-08-28 13:07:33 -03:00
|
|
|
KP_QUAD_YAW = readFloatSerial();
|
|
|
|
KI_QUAD_YAW = readFloatSerial();
|
2010-10-11 09:35:05 -03:00
|
|
|
STABLE_MODE_KP_RATE_YAW = readFloatSerial();
|
|
|
|
STABLE_MODE_KP_RATE = readFloatSerial(); // NOT USED NOW
|
2010-08-28 13:07:33 -03:00
|
|
|
MAGNETOMETER = readFloatSerial();
|
|
|
|
break;
|
|
|
|
case 'C': // Receive GPS PID
|
|
|
|
KP_GPS_ROLL = readFloatSerial();
|
|
|
|
KI_GPS_ROLL = readFloatSerial();
|
|
|
|
KD_GPS_ROLL = readFloatSerial();
|
|
|
|
KP_GPS_PITCH = readFloatSerial();
|
|
|
|
KI_GPS_PITCH = readFloatSerial();
|
|
|
|
KD_GPS_PITCH = readFloatSerial();
|
|
|
|
GPS_MAX_ANGLE = readFloatSerial();
|
|
|
|
GEOG_CORRECTION_FACTOR = readFloatSerial();
|
|
|
|
break;
|
|
|
|
case 'E': // Receive altitude PID
|
|
|
|
KP_ALTITUDE = readFloatSerial();
|
|
|
|
KI_ALTITUDE = readFloatSerial();
|
2010-12-10 15:07:21 -04:00
|
|
|
KD_ALTITUDE = readFloatSerial();
|
2010-08-28 13:07:33 -03:00
|
|
|
break;
|
|
|
|
case 'G': // Receive drift correction PID
|
|
|
|
Kp_ROLLPITCH = readFloatSerial();
|
|
|
|
Ki_ROLLPITCH = readFloatSerial();
|
|
|
|
Kp_YAW = readFloatSerial();
|
|
|
|
Ki_YAW = readFloatSerial();
|
|
|
|
break;
|
|
|
|
case 'I': // Receive sensor offset
|
|
|
|
gyro_offset_roll = readFloatSerial();
|
|
|
|
gyro_offset_pitch = readFloatSerial();
|
|
|
|
gyro_offset_yaw = readFloatSerial();
|
|
|
|
acc_offset_x = readFloatSerial();
|
|
|
|
acc_offset_y = readFloatSerial();
|
|
|
|
acc_offset_z = readFloatSerial();
|
|
|
|
break;
|
2010-10-30 11:38:52 -03:00
|
|
|
case 'K': // Camera mode
|
|
|
|
// 1 = Tilt / Roll without
|
|
|
|
cam_mode = readFloatSerial();
|
|
|
|
//BATTLOW = readFloatSerial();
|
2010-10-17 14:34:17 -03:00
|
|
|
break;
|
2010-08-28 13:07:33 -03:00
|
|
|
case 'M': // Receive debug motor commands
|
|
|
|
frontMotor = readFloatSerial();
|
|
|
|
backMotor = readFloatSerial();
|
|
|
|
rightMotor = readFloatSerial();
|
|
|
|
leftMotor = readFloatSerial();
|
|
|
|
motorArmed = readFloatSerial();
|
2010-10-17 14:34:17 -03:00
|
|
|
break;
|
2010-08-28 13:07:33 -03:00
|
|
|
case 'O': // Rate Control PID
|
|
|
|
Kp_RateRoll = readFloatSerial();
|
|
|
|
Ki_RateRoll = readFloatSerial();
|
|
|
|
Kd_RateRoll = readFloatSerial();
|
|
|
|
Kp_RatePitch = readFloatSerial();
|
|
|
|
Ki_RatePitch = readFloatSerial();
|
|
|
|
Kd_RatePitch = readFloatSerial();
|
|
|
|
Kp_RateYaw = readFloatSerial();
|
|
|
|
Ki_RateYaw = readFloatSerial();
|
|
|
|
Kd_RateYaw = readFloatSerial();
|
|
|
|
xmitFactor = readFloatSerial();
|
|
|
|
break;
|
2010-10-30 11:38:52 -03:00
|
|
|
case 'W': // Write all user configurable values to EEPROM
|
2010-08-28 13:07:33 -03:00
|
|
|
writeUserConfig();
|
|
|
|
break;
|
|
|
|
case 'Y': // Initialize EEPROM with default values
|
|
|
|
defaultUserConfig();
|
2010-11-23 21:30:41 -04:00
|
|
|
#if AIRFRAME == HELI
|
|
|
|
heli_defaultUserConfig();
|
|
|
|
#endif
|
2010-08-28 13:07:33 -03:00
|
|
|
break;
|
|
|
|
case '1': // Receive transmitter calibration values
|
|
|
|
ch_roll_slope = readFloatSerial();
|
|
|
|
ch_roll_offset = readFloatSerial();
|
|
|
|
ch_pitch_slope = readFloatSerial();
|
|
|
|
ch_pitch_offset = readFloatSerial();
|
|
|
|
ch_yaw_slope = readFloatSerial();
|
|
|
|
ch_yaw_offset = readFloatSerial();
|
|
|
|
ch_throttle_slope = readFloatSerial();
|
|
|
|
ch_throttle_offset = readFloatSerial();
|
|
|
|
ch_aux_slope = readFloatSerial();
|
|
|
|
ch_aux_offset = readFloatSerial();
|
|
|
|
ch_aux2_slope = readFloatSerial();
|
|
|
|
ch_aux2_offset = readFloatSerial();
|
2010-10-17 14:34:17 -03:00
|
|
|
break;
|
2010-10-19 12:22:58 -03:00
|
|
|
case '5': // Special debug features
|
2010-10-30 11:38:52 -03:00
|
|
|
|
2010-10-19 12:22:58 -03:00
|
|
|
|
|
|
|
break;
|
2010-08-28 13:07:33 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sendSerialTelemetry() {
|
|
|
|
float aux_float[3]; // used for sensor calibration
|
|
|
|
switch (queryType) {
|
|
|
|
case '=': // Reserved debug command to view any variable from Serial Monitor
|
2010-10-17 14:34:17 -03:00
|
|
|
/* SerPri(("throttle =");
|
|
|
|
SerPrln(ch_throttle);
|
|
|
|
SerPri("control roll =");
|
|
|
|
SerPrln(control_roll-CHANN_CENTER);
|
|
|
|
SerPri("control pitch =");
|
|
|
|
SerPrln(control_pitch-CHANN_CENTER);
|
|
|
|
SerPri("control yaw =");
|
|
|
|
SerPrln(control_yaw-CHANN_CENTER);
|
|
|
|
SerPri("front left yaw =");
|
|
|
|
SerPrln(frontMotor);
|
|
|
|
SerPri("front right yaw =");
|
|
|
|
SerPrln(rightMotor);
|
|
|
|
SerPri("rear left yaw =");
|
|
|
|
SerPrln(leftMotor);
|
|
|
|
SerPri("rear right motor =");
|
|
|
|
SerPrln(backMotor);
|
|
|
|
SerPrln();
|
|
|
|
|
|
|
|
SerPri("current roll rate =");
|
|
|
|
SerPrln(read_adc(0));
|
|
|
|
SerPri("current pitch rate =");
|
|
|
|
SerPrln(read_adc(1));
|
|
|
|
SerPri("current yaw rate =");
|
|
|
|
SerPrln(read_adc(2));
|
|
|
|
SerPri("command rx yaw =");
|
|
|
|
SerPrln(command_rx_yaw);
|
|
|
|
SerPrln();
|
|
|
|
queryType = 'X';*/
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(APM_RC.InputCh(0));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_roll_slope);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_roll_offset);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
|
|
|
SerPrln(ch_roll);
|
|
|
|
break;
|
|
|
|
case 'B': // Send roll, pitch and yaw PID values
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KP_QUAD_ROLL, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KI_QUAD_ROLL, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(STABLE_MODE_KP_RATE_ROLL, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KP_QUAD_PITCH, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KI_QUAD_PITCH, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(STABLE_MODE_KP_RATE_PITCH, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KP_QUAD_YAW, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KI_QUAD_YAW, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(STABLE_MODE_KP_RATE_YAW, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(STABLE_MODE_KP_RATE, 3); // NOT USED NOW
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
|
|
|
SerPrln(MAGNETOMETER, 3);
|
|
|
|
queryType = 'X';
|
|
|
|
break;
|
|
|
|
case 'D': // Send GPS PID
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KP_GPS_ROLL, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KI_GPS_ROLL, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KD_GPS_ROLL, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KP_GPS_PITCH, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KI_GPS_PITCH, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KD_GPS_PITCH, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(GPS_MAX_ANGLE, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
|
|
|
SerPrln(GEOG_CORRECTION_FACTOR, 3);
|
|
|
|
queryType = 'X';
|
|
|
|
break;
|
|
|
|
case 'F': // Send altitude PID
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KP_ALTITUDE, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(KI_ALTITUDE, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
|
|
|
SerPrln(KD_ALTITUDE, 3);
|
|
|
|
queryType = 'X';
|
|
|
|
break;
|
|
|
|
case 'H': // Send drift correction PID
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Kp_ROLLPITCH, 4);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Ki_ROLLPITCH, 7);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Kp_YAW, 4);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
|
|
|
SerPrln(Ki_YAW, 6);
|
|
|
|
queryType = 'X';
|
|
|
|
break;
|
|
|
|
case 'J': // Send sensor offset
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(gyro_offset_roll);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(gyro_offset_pitch);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(gyro_offset_yaw);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(acc_offset_x);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(acc_offset_y);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
|
|
|
SerPrln(acc_offset_z);
|
|
|
|
AN_OFFSET[3] = acc_offset_x;
|
|
|
|
AN_OFFSET[4] = acc_offset_y;
|
|
|
|
AN_OFFSET[5] = acc_offset_z;
|
|
|
|
queryType = 'X';
|
|
|
|
break;
|
2010-10-30 11:38:52 -03:00
|
|
|
case 'L': // Camera settings and
|
|
|
|
SerPri(cam_mode, DEC);
|
|
|
|
tab();
|
|
|
|
SerPri(BATTLOW, DEC);
|
|
|
|
tab();
|
2010-08-28 13:07:33 -03:00
|
|
|
queryType = 'X';
|
|
|
|
break;
|
|
|
|
case 'N': // Send magnetometer config
|
|
|
|
queryType = 'X';
|
|
|
|
break;
|
|
|
|
case 'P': // Send rate control PID
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Kp_RateRoll, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Ki_RateRoll, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Kd_RateRoll, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Kp_RatePitch, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Ki_RatePitch, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Kd_RatePitch, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Kp_RateYaw, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Ki_RateYaw, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(Kd_RateYaw, 3);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
|
|
|
SerPrln(xmitFactor, 3);
|
|
|
|
queryType = 'X';
|
|
|
|
break;
|
|
|
|
case 'Q': // Send sensor data
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(0));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(1));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(2));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(4));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(3));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(5));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(err_roll);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(err_pitch);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(degrees(roll));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(degrees(pitch));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
|
|
|
SerPrln(degrees(yaw));
|
|
|
|
break;
|
|
|
|
case 'R': // Send raw sensor data
|
|
|
|
break;
|
|
|
|
case 'S': // Send all flight data
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(timer-timer_old);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(0));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(1));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(2));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_throttle);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(control_roll);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(control_pitch);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(control_yaw);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(frontMotor); // Front Motor
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(backMotor); // Back Motor
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(rightMotor); // Right Motor
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(leftMotor); // Left Motor
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(4));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(read_adc(3));
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-30 11:38:52 -03:00
|
|
|
SerPri(read_adc(5));
|
2010-12-17 21:39:12 -04:00
|
|
|
|
|
|
|
comma();
|
2010-12-12 10:05:31 -04:00
|
|
|
SerPri(AP_Compass.heading, 4);
|
2010-10-30 11:38:52 -03:00
|
|
|
comma();
|
2010-12-12 10:05:31 -04:00
|
|
|
SerPri(AP_Compass.heading_x, 4);
|
2010-10-30 11:38:52 -03:00
|
|
|
comma();
|
2010-12-12 10:05:31 -04:00
|
|
|
SerPri(AP_Compass.heading_y, 4);
|
2010-10-30 11:38:52 -03:00
|
|
|
comma();
|
2010-12-12 10:05:31 -04:00
|
|
|
SerPri(AP_Compass.mag_x);
|
2010-10-30 11:38:52 -03:00
|
|
|
comma();
|
2010-12-12 10:05:31 -04:00
|
|
|
SerPri(AP_Compass.mag_y);
|
2010-10-30 11:38:52 -03:00
|
|
|
comma();
|
2010-12-12 10:05:31 -04:00
|
|
|
SerPri(AP_Compass.mag_z);
|
2010-12-17 21:39:12 -04:00
|
|
|
// comma();
|
2010-11-28 06:56:27 -04:00
|
|
|
|
2010-10-30 11:38:52 -03:00
|
|
|
SerPriln();
|
2010-08-28 13:07:33 -03:00
|
|
|
break;
|
|
|
|
case 'T': // Spare
|
|
|
|
break;
|
|
|
|
case 'U': // Send receiver values
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_roll); // Aileron
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_pitch); // Elevator
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_yaw); // Yaw
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_throttle); // Throttle
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_aux); // AUX1 (Mode)
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_aux2); // AUX2
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(roll_mid); // Roll MID value
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(pitch_mid); // Pitch MID value
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
|
|
|
SerPrln(yaw_mid); // Yaw MID Value
|
|
|
|
break;
|
|
|
|
case 'V': // Spare
|
|
|
|
break;
|
|
|
|
case 'X': // Stop sending messages
|
|
|
|
break;
|
|
|
|
case '!': // Send flight software version
|
|
|
|
SerPrln(VER);
|
|
|
|
queryType = 'X';
|
|
|
|
break;
|
|
|
|
case '2': // Send transmitter calibration values
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_roll_slope);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_roll_offset);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_pitch_slope);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_pitch_offset);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_yaw_slope);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_yaw_offset);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_throttle_slope);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_throttle_offset);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_aux_slope);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_aux_offset);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(ch_aux2_slope);
|
2010-08-28 13:07:33 -03:00
|
|
|
comma();
|
|
|
|
SerPrln(ch_aux2_offset);
|
|
|
|
queryType = 'X';
|
2010-10-17 14:34:17 -03:00
|
|
|
break;
|
2010-10-30 11:38:52 -03:00
|
|
|
case '3': // Jani's debugs
|
|
|
|
SerPri(yaw);
|
|
|
|
tab();
|
|
|
|
SerPri(command_rx_yaw);
|
|
|
|
tab();
|
|
|
|
SerPri(control_yaw);
|
|
|
|
tab();
|
|
|
|
SerPri(err_yaw);
|
|
|
|
tab();
|
|
|
|
SerPri(AN[0]);
|
|
|
|
tab();
|
|
|
|
SerPri(AN[1]);
|
|
|
|
tab();
|
|
|
|
SerPri(AN[2] - gyro_offset_yaw);
|
|
|
|
tab();
|
|
|
|
SerPri(gyro_offset_yaw - AN[2]);
|
|
|
|
tab();
|
|
|
|
SerPri(gyro_offset_yaw);
|
|
|
|
tab();
|
|
|
|
SerPri(1500 - (gyro_offset_yaw - AN[2]));
|
|
|
|
tab();
|
|
|
|
SerPriln();
|
|
|
|
break;
|
2010-11-28 06:56:27 -04:00
|
|
|
#ifdef IsGPS
|
|
|
|
case '4': // Jani's debugs
|
|
|
|
// Log_Write_GPS(GPS.Time, GPS.Lattitude, GPS.Longitude, GPS.Altitude, GPS.Altitude, GPS.Ground_Speed, GPS.Ground_Course, GPS.Fix, GPS.NumSats);
|
|
|
|
|
|
|
|
SerPri(GPS.Time);
|
|
|
|
tab();
|
|
|
|
SerPri(GPS.Lattitude);
|
|
|
|
tab();
|
|
|
|
SerPri(GPS.Longitude);
|
|
|
|
tab();
|
|
|
|
SerPri(GPS.Altitude);
|
|
|
|
tab();
|
|
|
|
SerPri(GPS.Ground_Speed);
|
|
|
|
tab();
|
|
|
|
SerPri(GPS.Ground_Course);
|
|
|
|
tab();
|
|
|
|
SerPri(GPS.Fix);
|
|
|
|
tab();
|
|
|
|
SerPri(GPS.NumSats);
|
|
|
|
|
|
|
|
tab();
|
|
|
|
SerPriln();
|
|
|
|
break;
|
|
|
|
#endif
|
2010-08-28 13:07:33 -03:00
|
|
|
case '.': // Modify GPS settings, print directly to GPS Port
|
|
|
|
Serial1.print("$PGCMD,16,0,0,0,0,0*6A\r\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void comma() {
|
2010-10-17 13:18:14 -03:00
|
|
|
SerPri(',');
|
2010-08-28 13:07:33 -03:00
|
|
|
}
|
|
|
|
|
2010-10-30 05:30:46 -03:00
|
|
|
void tab() {
|
|
|
|
SerPri("\t");
|
|
|
|
}
|
2010-08-28 13:07:33 -03:00
|
|
|
|
|
|
|
// Used to read floating point values from the serial port
|
|
|
|
float readFloatSerial() {
|
|
|
|
byte index = 0;
|
|
|
|
byte timeout = 0;
|
|
|
|
char data[128] = "";
|
|
|
|
|
|
|
|
do {
|
2010-10-17 13:18:14 -03:00
|
|
|
if (SerAva() == 0) {
|
2010-08-28 13:07:33 -03:00
|
|
|
delay(10);
|
|
|
|
timeout++;
|
|
|
|
}
|
|
|
|
else {
|
2010-10-17 13:18:14 -03:00
|
|
|
data[index] = SerRea();
|
2010-08-28 13:07:33 -03:00
|
|
|
timeout = 0;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while ((data[constrain(index-1, 0, 128)] != ';') && (timeout < 5) && (index < 128));
|
|
|
|
return atof(data);
|
2010-10-17 13:18:14 -03:00
|
|
|
}
|
2010-10-17 14:34:17 -03:00
|
|
|
|
2010-12-17 21:39:12 -04:00
|
|
|
|