mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-11 17:13:56 -03:00
flight orientation selection by DIP1 switch
git-svn-id: https://arducopter.googlecode.com/svn/trunk@693 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
parent
f5cd4e45f9
commit
74674b638b
@ -83,7 +83,7 @@ TODO:
|
|||||||
#define AUX_MID 1500
|
#define AUX_MID 1500
|
||||||
|
|
||||||
#define CHANN_CENTER 1500 // Channel center, legacy
|
#define CHANN_CENTER 1500 // Channel center, legacy
|
||||||
#define MIN_THROTTLE 1080 // Throttle pulse width at minimun...
|
#define MIN_THROTTLE 1040 // Throttle pulse width at minimun...
|
||||||
|
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
// General definitions
|
// General definitions
|
||||||
|
@ -335,6 +335,7 @@ int leftMotor;
|
|||||||
int rightMotor;
|
int rightMotor;
|
||||||
byte motorArmed = 0;
|
byte motorArmed = 0;
|
||||||
int minThrottle = 0;
|
int minThrottle = 0;
|
||||||
|
boolean flightOrientation = 0; // 0 = +, 1 = x this is read from DIP1 switch during system bootup
|
||||||
|
|
||||||
// Serial communication
|
// Serial communication
|
||||||
char queryType;
|
char queryType;
|
||||||
|
@ -84,9 +84,11 @@
|
|||||||
// Flight & Electronics orientation
|
// Flight & Electronics orientation
|
||||||
|
|
||||||
// Frame build condiguration
|
// Frame build condiguration
|
||||||
#define FLIGHT_MODE_+ // Traditional "one arm as nose" frame configuration
|
//#define FLIGHT_MODE_+ // Traditional "one arm as nose" frame configuration
|
||||||
//#define FLIGHT_MODE_X // Frame orientation 45 deg to CCW, nose between two arms
|
//#define FLIGHT_MODE_X // Frame orientation 45 deg to CCW, nose between two arms
|
||||||
|
// 19-10-10 by JP
|
||||||
|
// This feature has been disabled for now, if you want to change between flight orientations
|
||||||
|
// just use DIP switch for that. DIP1 down = X, DIP1 up = +
|
||||||
|
|
||||||
// Magneto orientation and corrections.
|
// Magneto orientation and corrections.
|
||||||
// If you don't have magneto actiavted, It is safe to ignore these
|
// If you don't have magneto actiavted, It is safe to ignore these
|
||||||
@ -202,6 +204,10 @@ void setup() {
|
|||||||
// external command/telemetry
|
// external command/telemetry
|
||||||
// Battery monitor
|
// Battery monitor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ***************************************************** */
|
||||||
|
// Main loop
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
//int aux;
|
//int aux;
|
||||||
|
@ -65,16 +65,17 @@ void read_radio()
|
|||||||
if (flightMode==STABLE_MODE) // IN STABLE MODE we convert stick positions to absoulte angles
|
if (flightMode==STABLE_MODE) // IN STABLE MODE we convert stick positions to absoulte angles
|
||||||
{
|
{
|
||||||
// In Stable mode stick position defines the desired angle in roll, pitch and yaw
|
// In Stable mode stick position defines the desired angle in roll, pitch and yaw
|
||||||
#ifdef FLIGHT_MODE_X
|
// #ifdef FLIGHT_MODE_X
|
||||||
|
if(!flightOrientation) {
|
||||||
// For X mode we make a mix in the input
|
// For X mode we make a mix in the input
|
||||||
float aux_roll = (ch_roll-roll_mid) / STICK_TO_ANGLE_FACTOR;
|
float aux_roll = (ch_roll-roll_mid) / STICK_TO_ANGLE_FACTOR;
|
||||||
float aux_pitch = (ch_pitch-pitch_mid) / STICK_TO_ANGLE_FACTOR;
|
float aux_pitch = (ch_pitch-pitch_mid) / STICK_TO_ANGLE_FACTOR;
|
||||||
command_rx_roll = aux_roll - aux_pitch;
|
command_rx_roll = aux_roll - aux_pitch;
|
||||||
command_rx_pitch = aux_roll + aux_pitch;
|
command_rx_pitch = aux_roll + aux_pitch;
|
||||||
#else
|
} else {
|
||||||
command_rx_roll = (ch_roll-roll_mid) / STICK_TO_ANGLE_FACTOR; // Convert stick position to absolute angles
|
command_rx_roll = (ch_roll-roll_mid) / STICK_TO_ANGLE_FACTOR; // Convert stick position to absolute angles
|
||||||
command_rx_pitch = (ch_pitch-pitch_mid) / STICK_TO_ANGLE_FACTOR;
|
command_rx_pitch = (ch_pitch-pitch_mid) / STICK_TO_ANGLE_FACTOR;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// YAW
|
// YAW
|
||||||
if (abs(ch_yaw-yaw_mid)>6) // Take into account a bit of "dead zone" on yaw
|
if (abs(ch_yaw-yaw_mid)>6) // Take into account a bit of "dead zone" on yaw
|
||||||
|
@ -93,7 +93,23 @@ void APM_Init() {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
readUserConfig(); // Load user configurable items from EEPROM
|
// Read DIP Switches and other important values. DIP switches needs special functions to
|
||||||
|
// read due they are not defined as normal pins like other GPIO's are.
|
||||||
|
SW_DIP1 = APMPinRead(PINE, 7);
|
||||||
|
SW_DIP2 = APMPinRead(PINE, 6);
|
||||||
|
SW_DIP3 = APMPinRead(PINL, 6);
|
||||||
|
SW_DIP4 = APMPinRead(PINL, 7);
|
||||||
|
|
||||||
|
/* Works, tested 18-10-10 JP
|
||||||
|
if(SW_DIP1) {
|
||||||
|
SerPrln("+ mode");
|
||||||
|
} else {
|
||||||
|
SerPrln("x mode");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
flightOrientation = SW_DIP1; // DIP1 off = we are in + mode, DIP1 on = we are in x mode
|
||||||
|
readUserConfig(); // Load user configurable items from EEPROM
|
||||||
|
|
||||||
// Safety measure for Channel mids
|
// Safety measure for Channel mids
|
||||||
if(roll_mid < 1400 || roll_mid > 1600) roll_mid = 1500;
|
if(roll_mid < 1400 || roll_mid > 1600) roll_mid = 1500;
|
||||||
@ -155,22 +171,6 @@ void APM_Init() {
|
|||||||
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
// Read DIP Switches and other important values. DIP switches needs special functions to
|
|
||||||
// read due they are not defined as normal pins like other GPIO's are.
|
|
||||||
SW_DIP1 = APMPinRead(PINE, 7);
|
|
||||||
SW_DIP2 = APMPinRead(PINE, 6);
|
|
||||||
SW_DIP3 = APMPinRead(PINL, 6);
|
|
||||||
SW_DIP4 = APMPinRead(PINL, 7);
|
|
||||||
|
|
||||||
/* Works, tested 18-10-10 JP
|
|
||||||
if(SW_DIP1) {
|
|
||||||
SerPrln("+ mode");
|
|
||||||
} else {
|
|
||||||
SerPrln("x mode");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
DataFlash.StartWrite(1); // Start a write session on page 1
|
DataFlash.StartWrite(1); // Start a write session on page 1
|
||||||
//timer = millis();
|
//timer = millis();
|
||||||
//tlmTimer = millis();
|
//tlmTimer = millis();
|
||||||
|
Loading…
Reference in New Issue
Block a user