I found a discussion for getting 5 switch positions out of channel 5 on a DX6i and it also works on my JR XP6102. What I want to do is add 2 more switchable modes to Ardupilot 2.7.1 which currently uses these 3 position outputs from channel 5. I looked in Ardupilot and see it uses a Case statement to switch between 3 modes, but I cant find anywhere where the low level stuff for channel 5 is even described.
It'd be nice if all I had to do was add 2 more #defines and 2 more case statements, but I get the feeling that the PWM values of the additional switch positions need to be stated somewhere.
Any clues where I need to make some changes.?
Replies
Here's the function that reads the switch and its found in the control modes tab.
void read_control_switch()
{
byte switchPosition = readSwitch();
if (oldSwitchPosition != switchPosition){
switch(switchPosition)
{
case 1: // First position
set_mode(POSITION_1);
break;
case 2: // middle position
/*
if (GPS_fix != FAILED_GPS){
set_mode(RTL);
}else{
set_mode(CIRCLE);
}
*/
set_mode(POSITION_2);
break;
case 3: // last position
set_mode(POSITION_3);
break;
}
Somewhere the PWM of POSITION_# is setup and that's what I'm looking for. I'm thinking that mystery location is where I could tell it there are 5 different PWM values and then I could go in to the control modes tab and add 2 more cases.