Copter: implement user auxswitch functions

This commit is contained in:
SergeyBokhantsev 2018-05-25 15:10:53 +03:00 committed by Randy Mackay
parent 1377943eb3
commit ea3de59107
5 changed files with 38 additions and 0 deletions

View File

@ -65,3 +65,4 @@
//#define USERHOOK_MEDIUMLOOP userhook_MediumLoop(); // for code to be run at 10hz
//#define USERHOOK_SLOWLOOP userhook_SlowLoop(); // for code to be run at 3.3hz
//#define USERHOOK_SUPERSLOWLOOP userhook_SuperSlowLoop(); // for code to be run at 1hz
//#define USERHOOK_AUXSWITCH ENABLED // for code to handle user aux switches

View File

@ -937,6 +937,9 @@ private:
void userhook_MediumLoop();
void userhook_SlowLoop();
void userhook_SuperSlowLoop();
void userhook_auxSwitch1(uint8_t ch_flag);
void userhook_auxSwitch2(uint8_t ch_flag);
void userhook_auxSwitch3(uint8_t ch_flag);
#include "mode.h"

View File

@ -42,3 +42,20 @@ void Copter::userhook_SuperSlowLoop()
// put your 1Hz code here
}
#endif
#ifdef USERHOOK_AUXSWITCH
void Copter::userhook_auxSwitch1(uint8_t ch_flag)
{
// put your aux switch #1 handler here (CHx_OPT = 47)
}
void Copter::userhook_auxSwitch2(uint8_t ch_flag)
{
// put your aux switch #2 handler here (CHx_OPT = 48)
}
void Copter::userhook_auxSwitch3(uint8_t ch_flag)
{
// put your aux switch #3 handler here (CHx_OPT = 49)
}
#endif

View File

@ -75,6 +75,9 @@ enum aux_sw_func {
AUXSW_WINCH_ENABLE = 44, // winch enable/disable
AUXSW_WINCH_CONTROL = 45, // winch control
AUXSW_RC_OVERRIDE_ENABLE = 46, // enable RC Override
AUXSW_USER_FUNC1 = 47, // user function #1
AUXSW_USER_FUNC2 = 48, // user function #2
AUXSW_USER_FUNC3 = 49, // user function #3
AUXSW_SWITCH_MAX,
};

View File

@ -727,6 +727,20 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
}
}
break;
#ifdef USERHOOK_AUXSWITCH
case AUXSW_USER_FUNC1:
userhook_auxSwitch1(ch_flag);
break;
case AUXSW_USER_FUNC2:
userhook_auxSwitch2(ch_flag);
break;
case AUXSW_USER_FUNC3:
userhook_auxSwitch3(ch_flag);
break;
#endif
}
}