Add independent servos option

pull/1/head
Mathis et Yohan 2021-12-01 18:58:16 +01:00
rodzic 489171ffad
commit 4653f7cbe6
1 zmienionych plików z 39 dodań i 20 usunięć

Wyświetl plik

@ -14,9 +14,9 @@
#define i_want_to_fly false // Simulated servo movement to test the servo movement :)) #define i_want_to_fly false // Simulated servo movement to test the servo movement :))
#define buzzer_turn true // Buzzer sounds as function of the turn command #define buzzer_turn true // Buzzer sounds as function of the turn command
#define no_init false // Skip init, for testing only purposes #define no_init false // Skip init, for testing only purposes
#define pitch true // RC control with pitch and roll, or only roll #define rc_mode 2 // 0 = only roll, 1 = pitch and roll mixed, 2 = pitch and roll separated
#define autopilot_mode 1 // Control linear or with "hands up" #define autopilot_mode 1 // Control linear or with "hands up"
#define drop false // R2Home's version, drop or motorised #define drop false // R2Home's version, drop or motorised
#define record_home false // only record autopilot #define record_home false // only record autopilot
#define dep_alt 100 // m above ground #define dep_alt 100 // m above ground
#define vup 1.5 // m/s #define vup 1.5 // m/s
@ -30,7 +30,7 @@
#define blow 3.5 #define blow 3.5
#define no_batt 4.0 #define no_batt 4.0
#define servo_man_min 1100 #define servo_man_min 1100
#define servo_man_max 1900 #define servo_man_max 1900
#define servo_auto_min 1100 #define servo_auto_min 1100
@ -971,37 +971,56 @@ void applycmd() {
case 1: case 1:
case 6: case 6:
if (failSafe == false) { if (failSafe == false) {
if (pitch == false) { switch (rc_mode) {
servo_left = roll_man; servo_right = 3000-roll_man;
} case 0:
else {
servo_left = roll_man; servo_left = roll_man;
servo_right = 3000-roll_man; servo_right = 3000-roll_man;
break;
case 1:
servo_left = roll_man;
servo_right = 3000-roll_man;
servo_left = servo_left+(pitch_man-1500); servo_left = servo_left+(pitch_man-1500);
servo_right = servo_right+(pitch_man-1500); servo_right = servo_right+(pitch_man-1500);
servo_left = constrain(servo_left, servo_man_min, servo_man_max); servo_left = constrain(servo_left, servo_man_min, servo_man_max);
servo_right = constrain(servo_left, servo_man_min, servo_man_max); servo_right = constrain(servo_left, servo_man_min, servo_man_max);
break;
case 2:
servo_left = roll_man;
servo_right = pitch_man;
break;
} }
} }
else { servo_left = 1500; servo_right = 1500; } else { servo_left = 1500; servo_right = 1500; }
break; break;
case 8: case 8:
if (pitch == false) { switch (rc_mode) {
servo_left = roll_man; servo_right = 3000-roll_man; case 0:
} servo_left = roll_man;
else { servo_right = 3000-roll_man;
servo_left = roll_man; break;
servo_right = 3000-roll_man;
case 1:
servo_left = roll_man;
servo_right = 3000-roll_man;
servo_left = servo_left+(pitch_man-1500);
servo_right = servo_right+(pitch_man-1500);
servo_left = servo_left+(pitch_man-1500); servo_left = constrain(servo_left, servo_man_min, servo_man_max);
servo_right = servo_right+(pitch_man-1500); servo_right = constrain(servo_left, servo_man_min, servo_man_max);
break;
servo_left = constrain(servo_left, servo_man_min, servo_man_max);
servo_right = constrain(servo_left, servo_man_min, servo_man_max); case 2:
} servo_left = roll_man;
servo_right = pitch_man;
break;
}
break; break;
case 9: case 9: